OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 #ifdef WIN32 | 53 #ifdef WIN32 |
54 const char* kPathDelimiter = "\\"; | 54 const char* kPathDelimiter = "\\"; |
55 #else | 55 #else |
56 const char* kPathDelimiter = "/"; | 56 const char* kPathDelimiter = "/"; |
57 #endif | 57 #endif |
58 | 58 |
59 #ifdef WEBRTC_ANDROID | 59 #ifdef WEBRTC_ANDROID |
60 const char* kRootDirName = "/sdcard/chromium_tests_root/"; | 60 const char* kRootDirName = "/sdcard/chromium_tests_root/"; |
61 #else | 61 #else |
62 // The file we're looking for to identify the project root dir. | |
63 const char* kProjectRootFileName = "DEPS"; | |
64 #if !defined(WEBRTC_IOS) | 62 #if !defined(WEBRTC_IOS) |
65 const char* kOutputDirName = "out"; | 63 const char* kOutputDirName = "out"; |
66 #endif | 64 #endif |
67 const char* kFallbackPath = "./"; | 65 const char* kFallbackPath = "./"; |
68 #endif // !defined(WEBRTC_ANDROID) | 66 #endif // !defined(WEBRTC_ANDROID) |
69 | 67 |
70 #if !defined(WEBRTC_IOS) | 68 #if !defined(WEBRTC_IOS) |
71 const char* kResourcesDirName = "resources"; | 69 const char* kResourcesDirName = "resources"; |
72 #endif | 70 #endif |
73 | 71 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 return kRootDirName; | 116 return kRootDirName; |
119 } | 117 } |
120 | 118 |
121 #else // WEBRTC_ANDROID | 119 #else // WEBRTC_ANDROID |
122 | 120 |
123 std::string ProjectRootPath() { | 121 std::string ProjectRootPath() { |
124 std::string path = WorkingDir(); | 122 std::string path = WorkingDir(); |
125 if (path == kFallbackPath) { | 123 if (path == kFallbackPath) { |
126 return kCannotFindProjectRootDir; | 124 return kCannotFindProjectRootDir; |
127 } | 125 } |
128 if (relative_dir_path_set) { | 126 if (relative_dir_path_set && strcmp(relative_dir_path, ".") != 0) { |
129 path = path + kPathDelimiter + relative_dir_path; | 127 path = path + kPathDelimiter + relative_dir_path; |
130 } | 128 } |
131 // Check for our file that verifies the root dir. | 129 // Remove two directory levels from the path, i.e. a path like |
| 130 // /absolute/path/src/out/Debug will become /absolute/path/src/ |
132 size_t path_delimiter_index = path.find_last_of(kPathDelimiter); | 131 size_t path_delimiter_index = path.find_last_of(kPathDelimiter); |
133 while (path_delimiter_index != std::string::npos) { | 132 if (path_delimiter_index != std::string::npos) { |
134 std::string root_filename = path + kPathDelimiter + kProjectRootFileName; | |
135 if (FileExists(root_filename)) { | |
136 return path + kPathDelimiter; | |
137 } | |
138 // Move up one directory in the directory tree. | 133 // Move up one directory in the directory tree. |
139 path = path.substr(0, path_delimiter_index); | 134 path = path.substr(0, path_delimiter_index); |
140 path_delimiter_index = path.find_last_of(kPathDelimiter); | 135 path_delimiter_index = path.find_last_of(kPathDelimiter); |
| 136 if (path_delimiter_index != std::string::npos) { |
| 137 // Move up another directory in the directory tree. We should now be at |
| 138 // the project root. |
| 139 return path.substr(0, path_delimiter_index) + kPathDelimiter; |
| 140 } |
141 } | 141 } |
142 // Reached the root directory. | |
143 fprintf(stderr, "Cannot find project root directory!\n"); | 142 fprintf(stderr, "Cannot find project root directory!\n"); |
144 return kCannotFindProjectRootDir; | 143 return kCannotFindProjectRootDir; |
145 } | 144 } |
146 | 145 |
147 std::string OutputPath() { | 146 std::string OutputPath() { |
148 #if defined(WEBRTC_IOS) | 147 #if defined(WEBRTC_IOS) |
149 return IOSOutputPath(); | 148 return IOSOutputPath(); |
150 #else | 149 #else |
151 std::string path = ProjectRootPath(); | 150 std::string path = ProjectRootPath(); |
152 if (path == kCannotFindProjectRootDir) { | 151 if (path == kCannotFindProjectRootDir) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 if (fseek(f, 0, SEEK_END) == 0) { | 270 if (fseek(f, 0, SEEK_END) == 0) { |
272 size = ftell(f); | 271 size = ftell(f); |
273 } | 272 } |
274 fclose(f); | 273 fclose(f); |
275 } | 274 } |
276 return size; | 275 return size; |
277 } | 276 } |
278 | 277 |
279 } // namespace test | 278 } // namespace test |
280 } // namespace webrtc | 279 } // namespace webrtc |
OLD | NEW |