From fd88414b4c5e9eb09167ef3e201e01e59108d466 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Fri, 7 Oct 2022 11:40:01 -0700 Subject: [PATCH] Fix incrementality bug with merged BUILD files The merged build files should be added as ninja dependencies, so we rerun when they're changed. Fixes: 246552590 Test: m bp2build, m bp2build again and observe it didn't rerun. Then add a comment in external/protobuf/BUILD.bazel, run m bp2build again, and observe it reruns Change-Id: I26ed035cc0a894500a192f9aa3371fb46519689b --- bp2build/symlink_forest.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bp2build/symlink_forest.go b/bp2build/symlink_forest.go index 023ec9687..7c39a118b 100644 --- a/bp2build/symlink_forest.go +++ b/bp2build/symlink_forest.go @@ -285,6 +285,17 @@ func plantSymlinkForestRecursive(cfg android.Config, topdir string, forestDir st // Neither is a directory. Merge them. srcBuildFile := shared.JoinPath(topdir, srcChild) generatedBuildFile := shared.JoinPath(topdir, buildFilesChild) + // Add the src and generated build files as dependencies so that bp2build + // is rerun when they change. Currently, this is only really necessary + // for srcBuildFile, because if we regenerate the generated build files + // we will always rerun the symlink forest generation as well. If that + // is later split up into separate, fully dependency-tracing steps, then + // we'll need srcBuildFile as well. Adding srcBuildFile here today + // technically makes it a dependency of bp2build_workspace_marker, which + // also implicitly outputs that file, but since bp2build_workspace_marker + // will always have a newer timestamp than the generatedBuildFile it + // shouldn't be a problem. + *acc = append(*acc, srcBuildFile, generatedBuildFile) err = mergeBuildFiles(shared.JoinPath(topdir, forestChild), srcBuildFile, generatedBuildFile, cfg.IsEnvTrue("BP2BUILD_VERBOSE")) if err != nil { fmt.Fprintf(os.Stderr, "Error merging %s and %s: %s",