OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/base_paths.h" | 5 #include "base/base_paths.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // There is currently no way to get the executable path on OpenBSD | 67 // There is currently no way to get the executable path on OpenBSD |
68 char *cpath; | 68 char *cpath; |
69 if ((cpath = getenv("CHROME_EXE_PATH")) != NULL) | 69 if ((cpath = getenv("CHROME_EXE_PATH")) != NULL) |
70 *result = FilePath(cpath); | 70 *result = FilePath(cpath); |
71 else | 71 else |
72 *result = FilePath("/usr/local/chrome/chrome"); | 72 *result = FilePath("/usr/local/chrome/chrome"); |
73 return true; | 73 return true; |
74 #endif | 74 #endif |
75 } | 75 } |
76 case base::DIR_SOURCE_ROOT: { | 76 case base::DIR_SOURCE_ROOT: { |
| 77 // Allow passing this in the environment, for more flexibility in build |
| 78 // tree configurations (sub-project builds, gyp --output_dir, etc.) |
| 79 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 80 std::string cr_source_root; |
| 81 if (env->GetVar("CR_SOURCE_ROOT", &cr_source_root)) { |
| 82 path = FilePath(cr_source_root); |
| 83 if (file_util::PathExists(path)) { |
| 84 *result = path; |
| 85 return true; |
| 86 } else { |
| 87 DLOG(WARNING) << "CR_SOURCE_ROOT is set, but it appears to not " |
| 88 << "point to a directory."; |
| 89 } |
| 90 } |
77 // On POSIX, unit tests execute two levels deep from the source root. | 91 // On POSIX, unit tests execute two levels deep from the source root. |
78 // For example: out/{Debug|Release}/net_unittest | 92 // For example: out/{Debug|Release}/net_unittest |
79 if (PathService::Get(base::DIR_EXE, &path)) { | 93 if (PathService::Get(base::DIR_EXE, &path)) { |
80 *result = path.DirName().DirName(); | 94 *result = path.DirName().DirName(); |
81 return true; | 95 return true; |
82 } | 96 } |
83 | 97 |
84 DLOG(ERROR) << "Couldn't find your source root. " | 98 DLOG(ERROR) << "Couldn't find your source root. " |
85 << "Try running from your chromium/src directory."; | 99 << "Try running from your chromium/src directory."; |
86 return false; | 100 return false; |
87 } | 101 } |
88 case base::DIR_CACHE: | 102 case base::DIR_CACHE: |
89 scoped_ptr<base::Environment> env(base::Environment::Create()); | 103 scoped_ptr<base::Environment> env(base::Environment::Create()); |
90 FilePath cache_dir(base::nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", | 104 FilePath cache_dir(base::nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", |
91 ".cache")); | 105 ".cache")); |
92 *result = cache_dir; | 106 *result = cache_dir; |
93 return true; | 107 return true; |
94 } | 108 } |
95 return false; | 109 return false; |
96 } | 110 } |
97 | 111 |
98 } // namespace base | 112 } // namespace base |
OLD | NEW |