Changed the way we find the ProjectRootPath.

This was blocking swarming for memcheck.

BUG=chromium:497757, webrtc:6727

Review-Url: https://codereview.webrtc.org/2511393002
Cr-Commit-Position: refs/heads/master@{#15153}
This commit is contained in:
ehmaldonado 2016-11-18 07:06:41 -08:00 committed by Commit bot
parent dedaf1ced7
commit 00f2ee04d7
2 changed files with 17 additions and 16 deletions

View File

@ -18,6 +18,8 @@
#include <windows.h>
#include <algorithm>
#include "Shlwapi.h"
#include "webrtc/system_wrappers/include/utf_util_win.h"
#define GET_CURRENT_DIR _getcwd
#else
@ -127,24 +129,23 @@ std::string ProjectRootPath() {
if (path == kFallbackPath) {
return kCannotFindProjectRootDir;
}
if (relative_dir_path_set && strcmp(relative_dir_path, ".") != 0) {
if (relative_dir_path_set) {
path = path + kPathDelimiter + relative_dir_path;
}
// Remove two directory levels from the path, i.e. a path like
// /absolute/path/src/out/Debug will become /absolute/path/src/
size_t path_delimiter_index = path.find_last_of(kPathDelimiter);
if (path_delimiter_index != std::string::npos) {
// Move up one directory in the directory tree.
path = path.substr(0, path_delimiter_index);
path_delimiter_index = path.find_last_of(kPathDelimiter);
if (path_delimiter_index != std::string::npos) {
// Move up another directory in the directory tree. We should now be at
// the project root.
return path.substr(0, path_delimiter_index) + kPathDelimiter;
}
path = path + kPathDelimiter + ".." + kPathDelimiter + "..";
char canonical_path[FILENAME_MAX];
#ifdef WIN32
bool succeeded = PathCanonicalizeA(canonical_path, path.c_str());
#else
bool succeeded = realpath(path.c_str(), canonical_path) != NULL;
#endif
if (succeeded) {
path = std::string(canonical_path) + kPathDelimiter;
return path;
} else {
fprintf(stderr, "Cannot find project root directory!\n");
return kCannotFindProjectRootDir;
}
fprintf(stderr, "Cannot find project root directory!\n");
return kCannotFindProjectRootDir;
#endif
}

View File

@ -81,7 +81,7 @@ TEST_F(FileUtilsTest, MAYBE_OutputPathFromUnchangedWorkingDir) {
// Tests with current working directory set to a directory higher up in the
// directory tree than the project root dir.
#if defined(WEBRTC_ANDROID)
#if defined(WEBRTC_ANDROID) || defined(WIN32)
#define MAYBE_OutputPathFromRootWorkingDir DISABLED_OutputPathFromRootWorkingDir
#else
#define MAYBE_OutputPathFromRootWorkingDir OutputPathFromRootWorkingDir