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 } | |
91 // On POSIX, unit tests execute two levels deep from the source root. | 77 // On POSIX, unit tests execute two levels deep from the source root. |
92 // For example: out/{Debug|Release}/net_unittest | 78 // For example: out/{Debug|Release}/net_unittest |
93 if (PathService::Get(base::DIR_EXE, &path)) { | 79 if (PathService::Get(base::DIR_EXE, &path)) { |
94 *result = path.DirName().DirName(); | 80 *result = path.DirName().DirName(); |
95 return true; | 81 return true; |
96 } | 82 } |
97 | 83 |
98 DLOG(ERROR) << "Couldn't find your source root. " | 84 DLOG(ERROR) << "Couldn't find your source root. " |
99 << "Try running from your chromium/src directory."; | 85 << "Try running from your chromium/src directory."; |
100 return false; | 86 return false; |
101 } | 87 } |
102 case base::DIR_CACHE: | 88 case base::DIR_CACHE: |
103 scoped_ptr<base::Environment> env(base::Environment::Create()); | 89 scoped_ptr<base::Environment> env(base::Environment::Create()); |
104 FilePath cache_dir(base::nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", | 90 FilePath cache_dir(base::nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", |
105 ".cache")); | 91 ".cache")); |
106 *result = cache_dir; | 92 *result = cache_dir; |
107 return true; | 93 return true; |
108 } | 94 } |
109 return false; | 95 return false; |
110 } | 96 } |
111 | 97 |
112 } // namespace base | 98 } // namespace base |
OLD | NEW |