summaryrefslogtreecommitdiffstats
path: root/tools/gn/path_output.cc
diff options
context:
space:
mode:
authorzeuthen <zeuthen@chromium.org>2014-11-11 13:01:13 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-11 21:01:37 +0000
commit6f9c6456a4358ec6ccb7b1c9d4e64a796633faae (patch)
tree103fa7df9652270af936abff8932af01f993b1f7 /tools/gn/path_output.cc
parent6f5fbedad1178b25754bc3c3291efdfdd27924bb (diff)
downloadchromium_src-6f9c6456a4358ec6ccb7b1c9d4e64a796633faae.zip
chromium_src-6f9c6456a4358ec6ccb7b1c9d4e64a796633faae.tar.gz
chromium_src-6f9c6456a4358ec6ccb7b1c9d4e64a796633faae.tar.bz2
gn: Support build directories outside the source tree.
The main use-case is to support using a fast SSD or ramdisk for the build directory, but a slower persistent disk for the source code. The general idea behind this change is modifying - RebaseSourceAbsolutePath() - SourceDir::ResolveRelativeFile() - SourceDir::ResolveRelativeDir() - GetOutputDirForSourceDirAsOutputFile() - PathOutput to work with paths reaching out of the source directory. Thanks to jam@ for the Windows-fixes. BUG=343728 TEST=New unit tests + Unit tests pass. TEST=`gn gen /ssd/out/Debug && ninja -C /ssd/out/Debug` work as expected. Review URL: https://codereview.chromium.org/630223002 Cr-Commit-Position: refs/heads/master@{#303719}
Diffstat (limited to 'tools/gn/path_output.cc')
-rw-r--r--tools/gn/path_output.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/gn/path_output.cc b/tools/gn/path_output.cc
index de398ec..5b333d8 100644
--- a/tools/gn/path_output.cc
+++ b/tools/gn/path_output.cc
@@ -4,19 +4,19 @@
#include "tools/gn/path_output.h"
+#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "tools/gn/filesystem_utils.h"
#include "tools/gn/output_file.h"
#include "tools/gn/string_utils.h"
-PathOutput::PathOutput(const SourceDir& current_dir, EscapingMode escaping)
+PathOutput::PathOutput(const SourceDir& current_dir,
+ const base::StringPiece& source_root,
+ EscapingMode escaping)
: current_dir_(current_dir) {
- CHECK(current_dir.is_source_absolute())
- << "Currently this only supports writing to output directories inside "
- "the source root. There needs to be some tweaks to PathOutput to make "
- "doing this work correctly.";
- inverse_current_dir_ = InvertDir(current_dir_);
-
+ inverse_current_dir_ = RebasePath("//", current_dir, source_root);
+ if (!EndsWithSlash(inverse_current_dir_))
+ inverse_current_dir_.push_back('/');
options_.mode = escaping;
}