aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/sbox/sbox.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/sbox/sbox.go')
-rw-r--r--cmd/sbox/sbox.go26
1 files changed, 23 insertions, 3 deletions
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
}