summaryrefslogtreecommitdiffstats
path: root/base/base_paths_posix.cc
diff options
context:
space:
mode:
authormmoss@google.com <mmoss@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-21 23:28:43 +0000
committermmoss@google.com <mmoss@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-21 23:28:43 +0000
commit632be2f06943e1b6d68965bea0d14c403c7d61bb (patch)
tree6d0d16a9dafd8655742f696aa1325f5a0c110be8 /base/base_paths_posix.cc
parent5a802c707a3784fcc63d9b57e46b0e8eca56610d (diff)
downloadchromium_src-632be2f06943e1b6d68965bea0d14c403c7d61bb.zip
chromium_src-632be2f06943e1b6d68965bea0d14c403c7d61bb.tar.gz
chromium_src-632be2f06943e1b6d68965bea0d14c403c7d61bb.tar.bz2
Add support for user-defined source root directory.
This fixes a problem on the Linux Module builders where tests built as sub-projects (gyp r814) can't find the source root because they're more than 2 levels deep (http://build.chromium.org/buildbot/waterfall/builders/Modules%20Linux%20(dbg)/builds/24363/steps/base_unittests/logs/stdio). Review URL: http://codereview.chromium.org/1690004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45260 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/base_paths_posix.cc')
-rw-r--r--base/base_paths_posix.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/base/base_paths_posix.cc b/base/base_paths_posix.cc
index e44028e..ad50318 100644
--- a/base/base_paths_posix.cc
+++ b/base/base_paths_posix.cc
@@ -42,7 +42,21 @@ bool PathProviderPosix(int key, FilePath* result) {
*result = FilePath(bin_dir);
return true;
}
- case base::DIR_SOURCE_ROOT:
+ case base::DIR_SOURCE_ROOT: {
+ // Allow passing this in the environment, for more flexibility in build
+ // tree configurations (sub-project builds, gyp --output_dir, etc.)
+ scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create());
+ std::string cr_source_root;
+ if (env->GetEnv("CR_SOURCE_ROOT", &cr_source_root)) {
+ path = FilePath(cr_source_root);
+ if (file_util::PathExists(path.Append("base/base_paths_posix.cc"))) {
+ *result = path;
+ return true;
+ } else {
+ LOG(WARNING) << "CR_SOURCE_ROOT is set, but it appears to not "
+ << "point to the correct source root directory.";
+ }
+ }
// On POSIX, unit tests execute two levels deep from the source root.
// For example: sconsbuild/{Debug|Release}/net_unittest
if (PathService::Get(base::DIR_EXE, &path)) {
@@ -62,6 +76,7 @@ bool PathProviderPosix(int key, FilePath* result) {
LOG(ERROR) << "Couldn't find your source root. "
<< "Try running from your chromium/src directory.";
return false;
+ }
case base::DIR_USER_CACHE:
scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create());
FilePath cache_dir(base::GetXDGDirectory(env.get(), "XDG_CACHE_HOME",