diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2017-03-14 11:10:04 +0000 |
---|---|---|
committer | Yun Peng <pcloudy@google.com> | 2017-03-14 19:46:48 +0000 |
commit | c8cd6bd2728e93c052ea217b5a93707a8a876f40 (patch) | |
tree | 9668d35b515b6ec29a71cb0191a27573e5b28146 /src/main | |
parent | 3786a19b731bc2ac57966f0f2971d026c71a88f3 (diff) |
Bazel client, Windows: make server mode work
Fix blaze_util_windows::ConvertAbsolutePaths,
which happens to have been the culprit why the
MSYS-less Bazel would always kill the running
server.
Fixes https://github.com/bazelbuild/bazel/issues/2672
See https://github.com/bazelbuild/bazel/issues/2107
--
Change-Id: I873a78c737a6d6906ac7db9bcd0e7186e17bd7ca
Reviewed-on: https://cr.bazel.build/9355
PiperOrigin-RevId: 150052180
MOS_MIGRATED_REVID=150052180
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/cpp/blaze_util_windows.cc | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/main/cpp/blaze_util_windows.cc b/src/main/cpp/blaze_util_windows.cc index 4e72092f4b..5e68544317 100644 --- a/src/main/cpp/blaze_util_windows.cc +++ b/src/main/cpp/blaze_util_windows.cc @@ -964,26 +964,18 @@ bool ReadDirectorySymlink(const string &posix_name, string* result) { } } -// TODO(laszlocsomor): use IsAbsolute from file_windows.cc -static bool IsAbsoluteWindowsPath(const string& p) { - if (p.size() < 3) { - return false; - } - - if (p.substr(1, 2) == ":/") { - return true; +bool CompareAbsolutePaths(const string& a, const string& b) { + // `a` and `b` may not be Windows-style and may not be normalized, so convert + // them both before comparing them. + wstring a_real, b_real; + if (!blaze_util::AsWindowsPathWithUncPrefix(a, &a_real)) { + pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR, + "CompareAbsolutePaths(a=%s, b=%s)", a.c_str(), b.c_str()); } - - if (p.substr(1, 2) == ":\\") { - return true; + if (!blaze_util::AsWindowsPathWithUncPrefix(b, &b_real)) { + pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR, + "CompareAbsolutePaths(a=%s, b=%s)", a.c_str(), b.c_str()); } - - return false; -} - -bool CompareAbsolutePaths(const string& a, const string& b) { - string a_real = IsAbsoluteWindowsPath(a) ? ConvertPathToPosix(a) : a; - string b_real = IsAbsoluteWindowsPath(b) ? ConvertPathToPosix(b) : b; return a_real == b_real; } @@ -1001,9 +993,9 @@ bool KillServerProcess(int pid) { return false; } - bool result = TerminateProcess(process, /*uExitCode*/0); + BOOL result = TerminateProcess(process, /*uExitCode*/ 0); if (!result) { - fprintf(stderr, "Cannot terminate server process with PID %d\n", pid); + blaze_util::PrintError("Cannot terminate server process with PID %d", pid); } CloseHandle(process); |