aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2019-08-29 14:47:40 -0700
committerColin Cross <ccross@android.com>2019-11-21 14:47:59 -0800
commitdb14db3a06d2bfcbc0ab775cdf56630f56a5c957 (patch)
tree42c980591e099a7039f479ec679ec5bdaf05b68f /android
parent0ce5d05f76989c4cc699e0dd6cd1f906a9e0f16d (diff)
downloadbuild_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 'android')
-rw-r--r--android/rule_builder.go13
-rw-r--r--android/rule_builder_test.go6
2 files changed, 11 insertions, 8 deletions
diff --git a/android/rule_builder.go b/android/rule_builder.go
index 4a3b0223..b3fccea3 100644
--- a/android/rule_builder.go
+++ b/android/rule_builder.go
@@ -342,10 +342,6 @@ func (r *RuleBuilder) Build(pctx PackageContext, ctx BuilderContext, name string
sboxOutputs[i] = "__SBOX_OUT_DIR__/" + Rel(ctx, r.sboxOutDir.String(), output.String())
}
- if depFile != nil {
- sboxOutputs = append(sboxOutputs, "__SBOX_OUT_DIR__/"+Rel(ctx, r.sboxOutDir.String(), depFile.String()))
- }
-
commandString = proptools.ShellEscape(commandString)
if !strings.HasPrefix(commandString, `'`) {
commandString = `'` + commandString + `'`
@@ -355,8 +351,13 @@ func (r *RuleBuilder) Build(pctx PackageContext, ctx BuilderContext, name string
sboxCmd.Tool(ctx.Config().HostToolPath(ctx, "sbox")).
Flag("-c").Text(commandString).
Flag("--sandbox-path").Text(shared.TempDirForOutDir(PathForOutput(ctx).String())).
- Flag("--output-root").Text(r.sboxOutDir.String()).
- Flags(sboxOutputs)
+ Flag("--output-root").Text(r.sboxOutDir.String())
+
+ if depFile != nil {
+ sboxCmd.Flag("--depfile-out").Text(depFile.String())
+ }
+
+ sboxCmd.Flags(sboxOutputs)
commandString = string(sboxCmd.buf)
tools = append(tools, sboxCmd.tools...)
diff --git a/android/rule_builder_test.go b/android/rule_builder_test.go
index df0f2564..d122a429 100644
--- a/android/rule_builder_test.go
+++ b/android/rule_builder_test.go
@@ -454,6 +454,7 @@ func TestRuleBuilder_Build(t *testing.T) {
FailIfErrored(t, errs)
check := func(t *testing.T, params TestingBuildParams, wantCommand, wantOutput, wantDepfile string, wantRestat bool, extraCmdDeps []string) {
+ t.Helper()
if params.RuleParams.Command != wantCommand {
t.Errorf("\nwant RuleParams.Command = %q\n got %q", wantCommand, params.RuleParams.Command)
}
@@ -497,13 +498,14 @@ func TestRuleBuilder_Build(t *testing.T) {
t.Run("sbox", func(t *testing.T) {
outDir := filepath.Join(buildDir, ".intermediates", "foo_sbox")
outFile := filepath.Join(outDir, "foo_sbox")
+ depFile := filepath.Join(outDir, "foo_sbox.d")
sbox := filepath.Join(buildDir, "host", config.PrebuiltOS(), "bin/sbox")
sandboxPath := shared.TempDirForOutDir(buildDir)
- cmd := sbox + ` -c 'cp bar __SBOX_OUT_DIR__/foo_sbox' --sandbox-path ` + sandboxPath + " --output-root " + outDir + " __SBOX_OUT_DIR__/foo_sbox __SBOX_OUT_DIR__/foo_sbox.d"
+ cmd := sbox + ` -c 'cp bar __SBOX_OUT_DIR__/foo_sbox' --sandbox-path ` + sandboxPath + " --output-root " + outDir + " --depfile-out " + depFile + " __SBOX_OUT_DIR__/foo_sbox"
check(t, ctx.ModuleForTests("foo_sbox", "").Rule("rule"),
- cmd, outFile, outFile+".d", false, []string{sbox})
+ cmd, outFile, depFile, false, []string{sbox})
})
t.Run("singleton", func(t *testing.T) {
outFile := filepath.Join(buildDir, "baz")