OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_mac.h" | 5 #include "base/base_paths_mac.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 #include <mach-o/dyld.h> | 9 #include <mach-o/dyld.h> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/mac/foundation_util.h" | 15 #include "base/mac/foundation_util.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // The name of this file relative to the source root. This is used for checking | |
22 // that the source checkout is in the correct place. | |
23 static const char kThisSourceFile[] = "base/base_paths_mac.mm"; | |
24 | |
21 bool GetNSExecutablePath(FilePath* path) WARN_UNUSED_RESULT; | 25 bool GetNSExecutablePath(FilePath* path) WARN_UNUSED_RESULT; |
22 | 26 |
23 bool GetNSExecutablePath(FilePath* path) { | 27 bool GetNSExecutablePath(FilePath* path) { |
24 DCHECK(path); | 28 DCHECK(path); |
25 // Executable path can have relative references ("..") depending on | 29 // Executable path can have relative references ("..") depending on |
26 // how the app was launched. | 30 // how the app was launched. |
27 uint32_t executable_length = 0; | 31 uint32_t executable_length = 0; |
28 _NSGetExecutablePath(NULL, &executable_length); | 32 _NSGetExecutablePath(NULL, &executable_length); |
29 DCHECK_GE(executable_length, 1u); | 33 DCHECK_GE(executable_length, 1u); |
30 std::string executable_path; | 34 std::string executable_path; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 *result = result->DirName(); | 79 *result = result->DirName(); |
76 if (base::mac::AmIBundled()) { | 80 if (base::mac::AmIBundled()) { |
77 // The bundled app executables (Chromium, TestShell, etc) live five | 81 // The bundled app executables (Chromium, TestShell, etc) live five |
78 // levels down, eg: | 82 // levels down, eg: |
79 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium | 83 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium |
80 *result = result->DirName().DirName().DirName().DirName().DirName(); | 84 *result = result->DirName().DirName().DirName().DirName().DirName(); |
81 } else { | 85 } else { |
82 // Unit tests execute two levels deep from the source root, eg: | 86 // Unit tests execute two levels deep from the source root, eg: |
83 // src/xcodebuild/{Debug|Release}/base_unittests | 87 // src/xcodebuild/{Debug|Release}/base_unittests |
84 *result = result->DirName().DirName(); | 88 *result = result->DirName().DirName(); |
89 // In a case of a WebKit-only checkout, using make instead of | |
90 // xcodebuild, we should return <root of | |
91 // checkout>/Source/WebKit/chromium. | |
92 if (!file_util::PathExists(result->Append(kThisSourceFile))) | |
93 *result = result->Append("Source/WebKit/chromium"); | |
Nico
2011/11/17 14:54:11
Do you know why this is necessary? Does the make b
| |
85 } | 94 } |
86 return true; | 95 return true; |
87 } | 96 } |
88 default: | 97 default: |
89 return false; | 98 return false; |
90 } | 99 } |
91 } | 100 } |
92 | 101 |
93 } // namespace base | 102 } // namespace base |
OLD | NEW |