summaryrefslogtreecommitdiffstats
path: root/tools/gn/filesystem_utils.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-23 00:26:56 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-23 00:26:56 +0000
commitac1128e3801134c30a848eed0db7298826f8449b (patch)
tree947dcfceb075a78ed31561a61f57a40f5eb98566 /tools/gn/filesystem_utils.h
parenteb9f0e842aaaa18355e5b2908f0da7f761c89dca (diff)
downloadchromium_src-ac1128e3801134c30a848eed0db7298826f8449b.zip
chromium_src-ac1128e3801134c30a848eed0db7298826f8449b.tar.gz
chromium_src-ac1128e3801134c30a848eed0db7298826f8449b.tar.bz2
This make the GN current dir be set on thte scope. This fixes a bug where a template execution uses the directory of the file containing the template declaration. This makes it impossible to refer to the input files which are normally specified relative to the invoking file.
I added a defined() function that returns true if a variable has been defined. This needed some magic function invocation help because we don't actually want to evaluate the argument. I added an optional second argument to assert for an error message. We now tolerate absolute file paths for sources and outputs. Grit was outputtings these, which was confusiong some of our assertions. We'll now check if such locations are inside our source tree and fix them up accordingly. I fixed a bug in the "desc" command where a target would be listed as a dependent of itself. I also added the target type to the output. Note that I didn't implement MakeAbsolutePathRelativeIfPossible on Windows. I will do this on Windows in a second pass. Currently it's an #error. There are several fixes to custom script target outputs and fixes to variables leftover from when I converted paths to start with two slashes. BUG= R=scottmg@chromium.org Review URL: https://codereview.chromium.org/23396002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219161 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/filesystem_utils.h')
-rw-r--r--tools/gn/filesystem_utils.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/gn/filesystem_utils.h b/tools/gn/filesystem_utils.h
index 38d64be..4ab4ec5 100644
--- a/tools/gn/filesystem_utils.h
+++ b/tools/gn/filesystem_utils.h
@@ -99,6 +99,22 @@ bool EnsureStringIsInOutputDir(const SourceDir& dir,
// ----------------------------------------------------------------------------
+// Returns true if the input string is absolute. Double-slashes at the
+// beginning are treated as source-relative paths. On Windows, this handles
+// paths of both the native format: "C:/foo" and ours "/C:/foo"
+bool IsPathAbsolute(const base::StringPiece& path);
+
+// Given an absolute path, checks to see if is it is inside the source root.
+// If it is, fills a source-absolute path into the given output and returns
+// true. If it isn't, clears the dest and returns false.
+//
+// The source_root should be a base::FilePath converted to UTF-8. On Windows,
+// it should begin with a "C:/" rather than being our SourceFile's style
+// ("/C:/"). The source root can end with a slash or not.
+bool MakeAbsolutePathRelativeIfPossible(const base::StringPiece& source_root,
+ const base::StringPiece& path,
+ std::string* dest);
+
// Converts a directory to its inverse (e.g. "/foo/bar/" -> "../../").
// This will be the empty string for the root directories ("/" and "//"), and
// in all other cases, this is guaranteed to end in a slash.