diff options
| author | Luca Stefani <luca.stefani.ge1@gmail.com> | 2020-03-07 13:13:34 +0100 |
|---|---|---|
| committer | Luca Stefani <luca.stefani.ge1@gmail.com> | 2020-03-07 13:13:34 +0100 |
| commit | 4dac9eee3f43e0fa62015d6f7a318ec05f63bc63 (patch) | |
| tree | 8b9352758716535ce05ca458aebed4bb57037e59 /cmd/sbox | |
| parent | a8b49b207d563ef1f563176978394c06e909ee93 (diff) | |
| parent | e65de78c9ad4109022266b51edfc5546afd0ef95 (diff) | |
| download | build_soong-4dac9eee3f43e0fa62015d6f7a318ec05f63bc63.tar.gz build_soong-4dac9eee3f43e0fa62015d6f7a318ec05f63bc63.tar.bz2 build_soong-4dac9eee3f43e0fa62015d6f7a318ec05f63bc63.zip | |
Merge tag 'android-10.0.0_r31' into lineage-17.1-android-10.0.0_r31
Android 10.0.0 release 31
* tag 'android-10.0.0_r31':
Revert submission 9940985-qpr1-dev merge
Revert submission 9919844-manual r1 merge
DO NOT MERGE: Add tradefed_java_library_host
DO NOT MERGE: Add tradefed_java_library_host
DO NOT MERGE: Add tradefed_java_library_host
Switch to clang-r353983c1.
Switch to clang-r353983d
Shard gensrcs modules into multiple commands
Move sharding functions for reuse
Rewrite depfile from sbox to stay reproducible
Support RuleBuilder.Sbox to wrap commands in sbox
Update droidstubs build target
Change-Id: Iff6698461ec43d1c74e70e3a693ebd028fe7b8b7
Diffstat (limited to 'cmd/sbox')
| -rw-r--r-- | cmd/sbox/Android.bp | 1 | ||||
| -rw-r--r-- | cmd/sbox/sbox.go | 28 |
2 files changed, 25 insertions, 4 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 47e60b19..151e8bbf 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 ( @@ -59,7 +62,7 @@ func usageViolation(violation string) { } fmt.Fprintf(os.Stderr, - "Usage: sbox -c <commandToRun> --sandbox-path <sandboxPath> --output-root <outputRoot> --overwrite [--depfile-out depFile] <outputFile> [<outputFile>...]\n"+ + "Usage: sbox -c <commandToRun> --sandbox-path <sandboxPath> --output-root <outputRoot> [--depfile-out depFile] <outputFile> [<outputFile>...]\n"+ "\n"+ "Deletes <outputRoot>,"+ "runs <commandToRun>,"+ @@ -155,9 +158,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) } @@ -290,6 +290,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 } |
