Have Soong try to enforce that genrules declare all their outputs.
This causes Soong to put the outputs of each genrule into a temporary
location and copy the declared outputs back to the output directory.
This gets the process closer to having an actual sandbox.
Bug: 35562758
Test: make
Change-Id: I8048fbf1a3899a86fb99d71b60669b6633b07b3e
diff --git a/ui/build/util.go b/ui/build/util.go
index 37ac6b9..2555e8a 100644
--- a/ui/build/util.go
+++ b/ui/build/util.go
@@ -50,6 +50,19 @@
}
}
+// ensureEmptyDirectoriesExist ensures that the given directories exist and are empty
+func ensureEmptyDirectoriesExist(ctx Context, dirs ...string) {
+ // remove all the directories
+ for _, dir := range dirs {
+ err := os.RemoveAll(dir)
+ if err != nil {
+ ctx.Fatalf("Error removing %s: %q\n", dir, err)
+ }
+ }
+ // recreate all the directories
+ ensureDirectoriesExist(ctx, dirs...)
+}
+
// ensureEmptyFileExists ensures that the containing directory exists, and the
// specified file exists. If it doesn't exist, it will write an empty file.
func ensureEmptyFileExists(ctx Context, file string) {