OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This is really Posix minus Mac. Mac code is in base_paths_mac.mm. | 5 // This is really Posix minus Mac. Mac code is in base_paths_mac.mm. |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 | 8 |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 #if defined(OS_FREEBSD) | 10 #if defined(OS_FREEBSD) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 // On POSIX, unit tests execute two levels deep from the source root. | 76 // On POSIX, unit tests execute two levels deep from the source root. |
77 // For example: sconsbuild/{Debug|Release}/net_unittest | 77 // For example: sconsbuild/{Debug|Release}/net_unittest |
78 if (PathService::Get(base::DIR_EXE, &path)) { | 78 if (PathService::Get(base::DIR_EXE, &path)) { |
79 path = path.DirName().DirName(); | 79 path = path.DirName().DirName(); |
80 if (file_util::PathExists(path.Append("base/base_paths_posix.cc"))) { | 80 if (file_util::PathExists(path.Append("base/base_paths_posix.cc"))) { |
81 *result = path; | 81 *result = path; |
82 return true; | 82 return true; |
83 } | 83 } |
84 } | 84 } |
| 85 // In a case of WebKit-only checkout, executable files are put into |
| 86 // WebKit/out/{Debug|Release}, and we should return WebKit/WebKit/chromium |
| 87 // for DIR_SOURCE_ROOT. |
| 88 if (PathService::Get(base::DIR_EXE, &path)) { |
| 89 path = path.DirName().DirName().Append("WebKit/chromium"); |
| 90 if (file_util::PathExists(path.Append("base/base_paths_posix.cc"))) { |
| 91 *result = path; |
| 92 return true; |
| 93 } |
| 94 } |
85 // If that failed (maybe the build output is symlinked to a different | 95 // If that failed (maybe the build output is symlinked to a different |
86 // drive) try assuming the current directory is the source root. | 96 // drive) try assuming the current directory is the source root. |
87 if (file_util::GetCurrentDirectory(&path) && | 97 if (file_util::GetCurrentDirectory(&path) && |
88 file_util::PathExists(path.Append("base/base_paths_posix.cc"))) { | 98 file_util::PathExists(path.Append("base/base_paths_posix.cc"))) { |
89 *result = path; | 99 *result = path; |
90 return true; | 100 return true; |
91 } | 101 } |
92 LOG(ERROR) << "Couldn't find your source root. " | 102 LOG(ERROR) << "Couldn't find your source root. " |
93 << "Try running from your chromium/src directory."; | 103 << "Try running from your chromium/src directory."; |
94 return false; | 104 return false; |
95 } | 105 } |
96 case base::DIR_USER_CACHE: | 106 case base::DIR_USER_CACHE: |
97 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); | 107 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); |
98 FilePath cache_dir(base::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", | 108 FilePath cache_dir(base::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", |
99 ".cache")); | 109 ".cache")); |
100 *result = cache_dir; | 110 *result = cache_dir; |
101 return true; | 111 return true; |
102 } | 112 } |
103 return false; | 113 return false; |
104 } | 114 } |
105 | 115 |
106 } // namespace base | 116 } // namespace base |
OLD | NEW |