From e37a4de7733fb920c7522c8c2ba7d73434cf0f03 Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Thu, 23 Sep 2021 17:10:50 -0400 Subject: [PATCH] For mixed build bazel actions, remove old outputs This should fix incrementality issues in cases where actions don't wipe the old output. (Looking at you, llvm-ar) Test: mixed_libc.sh Change-Id: I4b6639e74c72921a5a703d73fd36f766f121c6ad --- android/bazel_handler.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/android/bazel_handler.go b/android/bazel_handler.go index 50b79fa15..22412553c 100644 --- a/android/bazel_handler.go +++ b/android/bazel_handler.go @@ -809,7 +809,16 @@ func (c *bazelSingleton) GenerateBuildActions(ctx SingletonContext) { cmd := rule.Command() // cd into Bazel's execution root, which is the action cwd. - cmd.Text(fmt.Sprintf("cd %s/execroot/__main__ && ", ctx.Config().BazelContext.OutputBase())) + cmd.Text(fmt.Sprintf("cd %s/execroot/__main__ &&", ctx.Config().BazelContext.OutputBase())) + + // Remove old outputs, as some actions might not rerun if the outputs are detected. + if len(buildStatement.OutputPaths) > 0 { + cmd.Text("rm -f") + for _, outputPath := range buildStatement.OutputPaths { + cmd.Text(PathForBazelOut(ctx, outputPath).String()) + } + cmd.Text("&&") + } for _, pair := range buildStatement.Env { // Set per-action env variables, if any.