diff options
author | Jeff Gaston <jeffrygaston@google.com> | 2017-03-29 17:29:06 -0700 |
---|---|---|
committer | Jeff Gaston <jeffrygaston@google.com> | 2017-06-09 17:57:18 +0000 |
commit | efc1b412f199bbbe2474d4c5396dc4b39a6beff7 (patch) | |
tree | c324ef0de2b4a59c76b5c78637852f567be0038b /ui | |
parent | 6b78fa8c012d3e84684d458f3271e91f0312423f (diff) | |
download | build_soong-efc1b412f199bbbe2474d4c5396dc4b39a6beff7.tar.gz build_soong-efc1b412f199bbbe2474d4c5396dc4b39a6beff7.tar.bz2 build_soong-efc1b412f199bbbe2474d4c5396dc4b39a6beff7.zip |
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
Diffstat (limited to 'ui')
-rw-r--r-- | ui/build/Android.bp | 1 | ||||
-rw-r--r-- | ui/build/build.go | 2 | ||||
-rw-r--r-- | ui/build/config.go | 8 | ||||
-rw-r--r-- | ui/build/util.go | 13 |
4 files changed, 23 insertions, 1 deletions
diff --git a/ui/build/Android.bp b/ui/build/Android.bp index 25520da0..489c06dc 100644 --- a/ui/build/Android.bp +++ b/ui/build/Android.bp @@ -18,6 +18,7 @@ bootstrap_go_package { deps: [ "soong-ui-logger", "soong-ui-tracer", + "soong-shared", ], srcs: [ "build.go", diff --git a/ui/build/build.go b/ui/build/build.go index 83dbcb61..1400c48e 100644 --- a/ui/build/build.go +++ b/ui/build/build.go @@ -125,6 +125,8 @@ func Build(ctx Context, config Config, what int) { checkCaseSensitivity(ctx, config) + ensureEmptyDirectoriesExist(ctx, config.TempDir()) + if what&BuildProductConfig != 0 { // Run make for product config runMakeProductConfig(ctx, config) diff --git a/ui/build/config.go b/ui/build/config.go index 7e8091b9..16826f24 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -21,6 +21,8 @@ import ( "runtime" "strconv" "strings" + + "android/soong/shared" ) type Config struct{ *configImpl } @@ -250,6 +252,10 @@ func (c *configImpl) SoongOutDir() string { return filepath.Join(c.OutDir(), "soong") } +func (c *configImpl) TempDir() string { + return shared.TempDirForOutDir(c.SoongOutDir()) +} + func (c *configImpl) KatiSuffix() string { if c.katiSuffix != "" { return c.katiSuffix @@ -306,7 +312,7 @@ func (c *configImpl) UseGoma() bool { } // RemoteParallel controls how many remote jobs (i.e., commands which contain -// gomacc) are run in parallel. Note the paralleism of all other jobs is +// gomacc) are run in parallel. Note the parallelism of all other jobs is // still limited by Parallel() func (c *configImpl) RemoteParallel() int { if v, ok := c.environ.Get("NINJA_REMOTE_NUM_JOBS"); ok { diff --git a/ui/build/util.go b/ui/build/util.go index 37ac6b9a..2555e8a4 100644 --- a/ui/build/util.go +++ b/ui/build/util.go @@ -50,6 +50,19 @@ func ensureDirectoriesExist(ctx Context, dirs ...string) { } } +// 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) { |