don't touch `bp2build_workspace_marker` file if it exists
- the generating rule has `restat=true`, so its output need not have a newer timestamp to prevent it from rerunning on subsequent ninja invocations
- its dependents (so far only bootstrap.ninja's "build build.ninja") already have proper dependencies in the depfile, namely
1. Android.bp.list,
2. entries in Android.bp.list,
3. bazel.list and
4. entries in bazel.list
This change prevents symlink related changes from spuriously retriggering build.ninja
Change-Id: I93f1fea7054dfbfc7c13ece34d2d1f07a81bbe07
Test: manually verifying bazel analysis is triggered only under the right set of CUJs using build/bazel/ci/incremental_build.py
Bug: b/239044236
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index c1a66db..517b80f 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -519,6 +519,12 @@
}
}
+func touchIfDoesNotExist(path string) {
+ if _, err := os.Stat(path); os.IsNotExist(err) {
+ touch(path)
+ }
+}
+
// Find BUILD files in the srcDir which are not in the allowlist
// (android.Bp2BuildConversionAllowlist#ShouldKeepExistingBuildFileForDir)
// and return their paths so they can be left out of the Bazel workspace dir (i.e. ignored)
@@ -684,8 +690,9 @@
writeDepFile(bp2buildMarker, eventHandler, ninjaDeps)
- // Create an empty bp2build marker file.
- touch(shared.JoinPath(topDir, bp2buildMarker))
+ // Create an empty bp2build marker file, if it does not already exist.
+ // Note the relevant rule has `restat = true`
+ touchIfDoesNotExist(shared.JoinPath(topDir, bp2buildMarker))
})
// Only report metrics when in bp2build mode. The metrics aren't relevant