Merge "Call rm -rf in mixed build build statement preamble."

This commit is contained in:
Jingwen Chen 2022-11-07 23:03:43 +00:00 committed by Gerrit Code Review
commit 1214001184
2 changed files with 5 additions and 4 deletions

View file

@ -1083,7 +1083,7 @@ func createCommand(cmd *RuleBuilderCommand, buildStatement bazel.BuildStatement,
// Remove old outputs, as some actions might not rerun if the outputs are detected.
if len(buildStatement.OutputPaths) > 0 {
cmd.Text("rm -f")
cmd.Text("rm -rf") // -r because outputs can be Bazel dir/tree artifacts.
for _, outputPath := range buildStatement.OutputPaths {
cmd.Text(fmt.Sprintf("'%s'", outputPath))
}

View file

@ -9,8 +9,9 @@ import (
"testing"
"android/soong/bazel/cquery"
"google.golang.org/protobuf/proto"
analysis_v2_proto "prebuilts/bazel/common/proto/analysis_v2"
"google.golang.org/protobuf/proto"
)
var testConfig = TestConfig("out", nil, "", nil)
@ -86,7 +87,7 @@ func TestInvokeBazelPopulatesBuildStatements(t *testing.T) {
{ "id": 1, "label": "one" },
{ "id": 2, "label": "two" }]
}`,
"cd 'test/exec_root' && rm -f 'one' && touch foo",
"cd 'test/exec_root' && rm -rf 'one' && touch foo",
}, {`
{
"artifacts": [
@ -105,7 +106,7 @@ func TestInvokeBazelPopulatesBuildStatements(t *testing.T) {
{ "id": 20, "label": "one.d", "parent_id": 30 },
{ "id": 30, "label": "parent" }]
}`,
`cd 'test/exec_root' && rm -f 'parent/one' && bogus command && sed -i'' -E 's@(^|\s|")bazel-out/@\1test/bazel_out/@g' 'parent/one.d'`,
`cd 'test/exec_root' && rm -rf 'parent/one' && bogus command && sed -i'' -E 's@(^|\s|")bazel-out/@\1test/bazel_out/@g' 'parent/one.d'`,
},
}