From c31929962bc79b52cf3415dd2aa185c53396768c Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Tue, 16 Nov 2021 17:01:11 -0500 Subject: [PATCH] Quote aquery commands. Bazel run shell actions begin `bin/bash -c `, without escaping, the command can be treated as an argument to `bin/bash`. Test: build/bazel/mixed_droid.sh Change-Id: I423cb393da2e6ac97448ec77b2596f12670dfd31 --- android/bazel.go | 3 +++ bazel/aquery.go | 2 +- bazel/aquery_test.go | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/android/bazel.go b/android/bazel.go index 4f613df7e..bf214a541 100644 --- a/android/bazel.go +++ b/android/bazel.go @@ -334,6 +334,9 @@ var ( mixedBuildsDisabledList = []string{ "libbrotli", // http://b/198585397, ld.lld: error: bionic/libc/arch-arm64/generic/bionic/memmove.S:95:(.text+0x10): relocation R_AARCH64_CONDBR19 out of range: -1404176 is not in [-1048576, 1048575]; references __memcpy "minijail_constants_json", // http://b/200899432, bazel-built cc_genrule does not work in mixed build when it is a dependency of another soong module. + + "cap_names.h", // TODO(b/204913827) runfiles need to be handled in mixed builds + "libcap", // TODO(b/204913827) runfiles need to be handled in mixed builds } // Used for quicker lookups diff --git a/bazel/aquery.go b/bazel/aquery.go index 4475b5e59..fd8cf677d 100644 --- a/bazel/aquery.go +++ b/bazel/aquery.go @@ -271,7 +271,7 @@ func AqueryBuildStatements(aqueryJsonProto []byte) ([]BuildStatement, error) { } buildStatement := BuildStatement{ - Command: strings.Join(proptools.ShellEscapeList(actionEntry.Arguments), " "), + Command: strings.Join(proptools.ShellEscapeListIncludingSpaces(actionEntry.Arguments), " "), Depfile: depfile, OutputPaths: outputPaths, InputPaths: inputPaths, diff --git a/bazel/aquery_test.go b/bazel/aquery_test.go index ca58606d7..68e50c21a 100644 --- a/bazel/aquery_test.go +++ b/bazel/aquery_test.go @@ -709,7 +709,7 @@ func TestTransitiveInputDepsets(t *testing.T) { } expectedBuildStatements := []BuildStatement{ BuildStatement{ - Command: "/bin/bash -c touch bazel-out/sourceroot/k8-fastbuild/bin/testpkg/test_out", + Command: "/bin/bash -c 'touch bazel-out/sourceroot/k8-fastbuild/bin/testpkg/test_out'", OutputPaths: []string{"bazel-out/sourceroot/k8-fastbuild/bin/testpkg/test_out"}, InputPaths: inputPaths, Mnemonic: "Action", @@ -1378,7 +1378,7 @@ func assertError(t *testing.T, err error, expected string) { func assertBuildStatements(t *testing.T, expected []BuildStatement, actual []BuildStatement) { t.Helper() if len(expected) != len(actual) { - t.Errorf("expected %d build statements, but got %d,\n expected: %v,\n actual: %v", + t.Errorf("expected %d build statements, but got %d,\n expected: %#v,\n actual: %#v", len(expected), len(actual), expected, actual) return } @@ -1389,7 +1389,7 @@ ACTUAL_LOOP: continue ACTUAL_LOOP } } - t.Errorf("unexpected build statement %v.\n expected: %v", + t.Errorf("unexpected build statement %#v.\n expected: %#v", actualStatement, expected) return }