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 // Check for our file that verifies the root dir. |
kjellander_webrtc
2016/09/15 06:28:32
We don't check for a file anymore, do we? I sugges
kjellander_webrtc
2016/09/15 06:28:33
I think a comment phrased something like this is s
ehmaldonado_webrtc
2016/09/15 08:23:15
Done.
| |
132 size_t path_delimiter_index = path.find_last_of(kPathDelimiter); | 130 size_t path_delimiter_index = path.find_last_of(kPathDelimiter); |
133 while (path_delimiter_index != std::string::npos) { | 131 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. | 132 // Move up one directory in the directory tree. |
139 path = path.substr(0, path_delimiter_index); | 133 path = path.substr(0, path_delimiter_index); |
140 path_delimiter_index = path.find_last_of(kPathDelimiter); | 134 path_delimiter_index = path.find_last_of(kPathDelimiter); |
135 // Check for our file that verifies the root dir. | |
kjellander_webrtc
2016/09/15 06:28:33
Remove this comment, it's just confusing.
ehmaldonado_webrtc
2016/09/15 08:23:15
Done.
| |
136 size_t path_delimiter_index = path.find_last_of(kPathDelimiter); | |
kjellander_webrtc
2016/09/15 06:28:33
Does this even compile? It seems you're declaring
ehmaldonado_webrtc
2016/09/15 08:23:15
Yes, it compiles, and it works. I think maybe it w
| |
137 if (path_delimiter_index != std::string::npos) { | |
138 // Move up one directory in the directory tree. | |
kjellander_webrtc
2016/09/15 06:28:32
Change to:
// Move up another directory level in t
ehmaldonado_webrtc
2016/09/15 08:23:15
Done.
| |
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 if (FileExists(resource_file)) { | 252 if (FileExists(resource_file)) { |
254 return resource_file; | 253 return resource_file; |
255 } | 254 } |
256 // Try without platform. | 255 // Try without platform. |
257 resource_file = resources_path + name + "_" + architecture + "." + extension; | 256 resource_file = resources_path + name + "_" + architecture + "." + extension; |
258 if (FileExists(resource_file)) { | 257 if (FileExists(resource_file)) { |
259 return resource_file; | 258 return resource_file; |
260 } | 259 } |
261 | 260 |
262 // Fall back on name without architecture or platform. | 261 // Fall back on name without architecture or platform. |
262 resource_file = resources_path + name + "." + extension; | |
263 FileExists(resource_file); | |
263 return resources_path + name + "." + extension; | 264 return resources_path + name + "." + extension; |
kjellander_webrtc
2016/09/15 06:28:33
return resource_file;
ehmaldonado_webrtc
2016/09/15 08:23:15
I'm leaving this unchanged. Those two lines were f
kjellander_webrtc
2016/09/15 10:04:49
Acknowledged.
| |
264 #endif // defined (WEBRTC_IOS) | 265 #endif // defined (WEBRTC_IOS) |
265 } | 266 } |
266 | 267 |
267 size_t GetFileSize(std::string filename) { | 268 size_t GetFileSize(std::string filename) { |
268 FILE* f = fopen(filename.c_str(), "rb"); | 269 FILE* f = fopen(filename.c_str(), "rb"); |
269 size_t size = 0; | 270 size_t size = 0; |
270 if (f != NULL) { | 271 if (f != NULL) { |
271 if (fseek(f, 0, SEEK_END) == 0) { | 272 if (fseek(f, 0, SEEK_END) == 0) { |
272 size = ftell(f); | 273 size = ftell(f); |
273 } | 274 } |
274 fclose(f); | 275 fclose(f); |
275 } | 276 } |
276 return size; | 277 return size; |
277 } | 278 } |
278 | 279 |
279 } // namespace test | 280 } // namespace test |
280 } // namespace webrtc | 281 } // namespace webrtc |
OLD | NEW |