summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2023-08-23 16:11:26 -0700
committer Cole Faust <colefaust@google.com> 2023-08-24 09:47:35 -0700
commit39b614af176ee2e1d9752ed73b23ecf30473191f (patch)
treea2eebdde94a3cf5f09825d3488116c77543b1718
parent573eabaa62bf1aeb46b22f4879e859b551d2c088 (diff)
Add the system image test to the bazel sandwich
Also make -test.sh files executable, while we wait for a bazel update that will tell us which FileWrite actions should be executable. Bug: 297268692 Test: m bazel_sandwich Change-Id: I60498577ba12813bff8bbdbc1b997ea4addefd17
-rw-r--r--android/allowlists/allowlists.go4
-rw-r--r--android/bazel_handler.go9
-rw-r--r--android/defs.go12
3 files changed, 19 insertions, 6 deletions
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index fec2cdc98..75f2c3ff1 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -1645,5 +1645,9 @@ var (
Label: "//build/bazel/examples/partitions:system_image",
Host: false,
},
+ {
+ Label: "//build/bazel/examples/partitions:run_test",
+ Host: false,
+ },
}
)
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index fda8a2251..42ba9b44e 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -1382,7 +1382,14 @@ func (c *bazelSingleton) GenerateBuildActions(ctx SingletonContext) {
WriteFileRuleVerbatim(ctx, out, "")
case "FileWrite", "SourceSymlinkManifest":
out := PathForBazelOut(ctx, buildStatement.OutputPaths[0])
- WriteFileRuleVerbatim(ctx, out, buildStatement.FileContents)
+ // TODO(b/297366783) This is a hack to make files from skylib's diff_test executable.
+ // We need to update bazel to have aquery tell us whether a file is supposed to be
+ // executable or not.
+ if strings.HasSuffix(buildStatement.OutputPaths[0], "-test.sh") {
+ WriteExecutableFileRuleVerbatim(ctx, out, buildStatement.FileContents)
+ } else {
+ WriteFileRuleVerbatim(ctx, out, buildStatement.FileContents)
+ }
case "SymlinkTree":
// build-runfiles arguments are the manifest file and the target directory
// where it creates the symlink tree according to this manifest (and then
diff --git a/android/defs.go b/android/defs.go
index 18eed2dae..682111ea5 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -209,12 +209,14 @@ func WriteFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content
buildWriteFileRule(ctx, outputFile, content)
}
-func CatFileRule(ctx BuilderContext, paths Paths, outputFile WritablePath) {
+// WriteExecutableFileRuleVerbatim is the same as WriteFileRuleVerbatim, but runs chmod +x on the result
+func WriteExecutableFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content string) {
+ intermediate := PathForIntermediates(ctx, "write_executable_file_intermediates").Join(ctx, outputFile.String())
+ WriteFileRuleVerbatim(ctx, intermediate, content)
ctx.Build(pctx, BuildParams{
- Rule: Cat,
- Inputs: paths,
- Output: outputFile,
- Description: "combine files to " + outputFile.Base(),
+ Rule: CpExecutable,
+ Output: outputFile,
+ Input: intermediate,
})
}