diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-19 16:50:52 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-19 16:50:52 +0000 |
commit | e9bf4fcb470f7220306c39827fc3fd9be0a27741 (patch) | |
tree | 59d2c4de7ab1964d6c421dd014b629ce9bd961e1 /tools/gn/filesystem_utils.cc | |
parent | 252e6603f3012cdc8de4a212999ef62660769be7 (diff) | |
download | chromium_src-e9bf4fcb470f7220306c39827fc3fd9be0a27741.zip chromium_src-e9bf4fcb470f7220306c39827fc3fd9be0a27741.tar.gz chromium_src-e9bf4fcb470f7220306c39827fc3fd9be0a27741.tar.bz2 |
Add directory extraction to GN path handling.
Some of the mojo templates want to put generated files in the directory
corresponding to the source file, rather than the directory containing the
BUILD file. Previously, this required putting the BUILD files in the same
directory.
This patch adds the ability to specify the generated file directory
corresponding to the input file in the action_foreach file templates so this
can be expressed naturally.
For parity, it also adds qquerying for this information via get_path_info.
BUG=
R=cjhopman@chromium.org
Review URL: https://codereview.chromium.org/334333005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/filesystem_utils.cc')
-rw-r--r-- | tools/gn/filesystem_utils.cc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tools/gn/filesystem_utils.cc b/tools/gn/filesystem_utils.cc index 4cfefa9..ca45625 100644 --- a/tools/gn/filesystem_utils.cc +++ b/tools/gn/filesystem_utils.cc @@ -720,10 +720,12 @@ SourceDir GetOutputDirForSourceDir(const Settings* settings, toolchain.SwapValue(&ret); ret.append("obj/"); - // The source dir should be source-absolute, so we trim off the two leading - // slashes to append to the toolchain object directory. - DCHECK(source_dir.is_source_absolute()); - ret.append(&source_dir.value()[2], source_dir.value().size() - 2); + if (source_dir.is_source_absolute()) { + // The source dir is source-absolute, so we trim off the two leading + // slashes to append to the toolchain object directory. + ret.append(&source_dir.value()[2], source_dir.value().size() - 2); + } + // (Put system-absolute stuff in the root obj directory.) return SourceDir(SourceDir::SWAP_IN, &ret); } @@ -735,10 +737,13 @@ SourceDir GetGenDirForSourceDir(const Settings* settings, std::string ret; toolchain.SwapValue(&ret); - // The source dir should be source-absolute, so we trim off the two leading - // slashes to append to the toolchain object directory. - DCHECK(source_dir.is_source_absolute()); - ret.append(&source_dir.value()[2], source_dir.value().size() - 2); + if (source_dir.is_source_absolute()) { + // The source dir should be source-absolute, so we trim off the two leading + // slashes to append to the toolchain object directory. + DCHECK(source_dir.is_source_absolute()); + ret.append(&source_dir.value()[2], source_dir.value().size() - 2); + } + // (Put system-absolute stuff in the root gen directory.) return SourceDir(SourceDir::SWAP_IN, &ret); } |