diff options
| author | Dan Willemsen <dwillemsen@google.com> | 2019-08-29 14:47:40 -0700 |
|---|---|---|
| committer | Colin Cross <ccross@android.com> | 2019-11-21 14:47:59 -0800 |
| commit | db14db3a06d2bfcbc0ab775cdf56630f56a5c957 (patch) | |
| tree | 42c980591e099a7039f479ec679ec5bdaf05b68f /cmd/sbox | |
| parent | 0ce5d05f76989c4cc699e0dd6cd1f906a9e0f16d (diff) | |
| download | build_soong-db14db3a06d2bfcbc0ab775cdf56630f56a5c957.tar.gz build_soong-db14db3a06d2bfcbc0ab775cdf56630f56a5c957.tar.bz2 build_soong-db14db3a06d2bfcbc0ab775cdf56630f56a5c957.zip | |
Rewrite depfile from sbox to stay reproducible
sbox will generate a random directory for the output root, and most
tools will encode that directory name in the output target of the
depfile.
So embed the library from dep_fixer into sbox so that it can rewrite the
output filename to a static (reproducible) value. Ninja doesn't care
what that value is, so it's just "outputfile".
Also fix up rule_builder to actually tell sbox about the depfile.
Bug: 144948629
Test: mmma system/iorap; check the contents of:
out/soong/.intermediates/system/iorap/libiorap-binder/android_arm_armv7-a-neon_core_static/gen/aidl/system/iorap/binder/com/google/android/startop/iorap/IIorap.cpp.d
Change-Id: I3640a2e8b0c034f143a35e398a8418a6d621b265
Merged-In: I3640a2e8b0c034f143a35e398a8418a6d621b265
(cherry picked from commit c89b6f19810d368d7d5c128407c3eaaa5e3b2e81)
Diffstat (limited to 'cmd/sbox')
| -rw-r--r-- | cmd/sbox/Android.bp | 1 | ||||
| -rw-r--r-- | cmd/sbox/sbox.go | 26 |
2 files changed, 24 insertions, 3 deletions
diff --git a/cmd/sbox/Android.bp b/cmd/sbox/Android.bp index fe4c7bbc..a706810d 100644 --- a/cmd/sbox/Android.bp +++ b/cmd/sbox/Android.bp @@ -14,6 +14,7 @@ blueprint_go_binary { name: "sbox", + deps: ["soong-makedeps"], srcs: [ "sbox.go", ], diff --git a/cmd/sbox/sbox.go b/cmd/sbox/sbox.go index 4ac92953..7057b33f 100644 --- a/cmd/sbox/sbox.go +++ b/cmd/sbox/sbox.go @@ -15,6 +15,7 @@ package main import ( + "bytes" "errors" "flag" "fmt" @@ -25,6 +26,8 @@ import ( "path/filepath" "strings" "time" + + "android/soong/makedeps" ) var ( @@ -152,9 +155,6 @@ func run() error { return err } allOutputs = append(allOutputs, sandboxedDepfile) - if !strings.Contains(rawCommand, "__SBOX_DEPFILE__") { - return fmt.Errorf("the --depfile-out argument only makes sense if the command contains the text __SBOX_DEPFILE__") - } rawCommand = strings.Replace(rawCommand, "__SBOX_DEPFILE__", filepath.Join(tempDir, sandboxedDepfile), -1) } @@ -281,6 +281,26 @@ func run() error { } } + // Rewrite the depfile so that it doesn't include the (randomized) sandbox directory + if depfileOut != "" { + in, err := ioutil.ReadFile(depfileOut) + if err != nil { + return err + } + + deps, err := makedeps.Parse(depfileOut, bytes.NewBuffer(in)) + if err != nil { + return err + } + + deps.Output = "outputfile" + + err = ioutil.WriteFile(depfileOut, deps.Print(), 0666) + if err != nil { + return err + } + } + // TODO(jeffrygaston) if a process creates more output files than it declares, should there be a warning? return nil } |
