Fixes bugs so that we can build bazel with bazel twice without cleaning up on Windows
--
Change-Id: I0048202b431ca05b88f67153389ca40c1542b1d5
Reviewed-on: https://bazel-review.googlesource.com/#/c/3371
MOS_MIGRATED_REVID=119861292
diff --git a/src/BUILD b/src/BUILD
index 7ff67d4..98460b1 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -155,7 +155,10 @@
"package-zip" + suffix,
],
outs = ["bazel" + suffix],
- cmd = "cat $(location //src/main/cpp:client) $(location :package-zip" + suffix + ") > $@ && zip -qA $@",
+ # In msys, a file path without .exe suffix(say foo), refers to a file with .exe
+ # suffix(say foo.exe), if foo.exe exists and foo doesn't. So, on windows, we
+ # need to remove bazel.exe first, so that cat to bazel won't fail.
+ cmd = "rm -f $@; cat $(location //src/main/cpp:client) $(location :package-zip" + suffix + ") > $@ && zip -qA $@",
executable = 1,
output_to_bindir = 1,
visibility = [
diff --git a/src/main/tools/build-runfiles.cc b/src/main/tools/build-runfiles.cc
index 935568f..cbf096d 100644
--- a/src/main/tools/build-runfiles.cc
+++ b/src/main/tools/build-runfiles.cc
@@ -260,8 +260,13 @@
}
FileInfoMap::iterator expected_it = manifest_.find(entry_path);
+ // When windows_compatible is enabled, if the hard link already existing
+ // is still
+ // in the mainifest, no need to recreate it.
+ // Note: here we assume the content won't change, which might not be true
+ // in some rare cases.
if (expected_it == manifest_.end() ||
- expected_it->second != actual_info) {
+ (!windows_compatible_ && expected_it->second != actual_info)) {
DelTree(entry_path, actual_info.type);
} else {
manifest_.erase(expected_it);