Add an order-only dependency on the build number file
Remote execution and other tools can be confused by references to
build_number.txt without a dependency. Add an order-only dependency,
which maintains the current behavior.
Test: BUILD_NUMBER=1 && m aapt && aapt version # shows 1
BUILD_NUMBER=2 && m aapt && aapt version # shows 1
rm out/soong/.intermediates/frameworks/base/tools/aapt/aapt/linux_glibc_x86_64/aapt
BUILD_NUMBER=2 && m aapt && aapt version # shows 2
Change-Id: Icfa98d6840b1dc2e273ba29c33011635d1cf93b1
diff --git a/cc/linker.go b/cc/linker.go
index af4cbf3..a7b621a 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -501,19 +501,21 @@
var injectVersionSymbol = pctx.AndroidStaticRule("injectVersionSymbol",
blueprint.RuleParams{
Command: "$symbolInjectCmd -i $in -o $out -s soong_build_number " +
- "-from 'SOONG BUILD NUMBER PLACEHOLDER' -v $buildNumberFromFile",
+ "-from 'SOONG BUILD NUMBER PLACEHOLDER' -v $$(cat $buildNumberFile)",
CommandDeps: []string{"$symbolInjectCmd"},
},
- "buildNumberFromFile")
+ "buildNumberFile")
func (linker *baseLinker) injectVersionSymbol(ctx ModuleContext, in android.Path, out android.WritablePath) {
+ buildNumberFile := ctx.Config().BuildNumberFile(ctx)
ctx.Build(pctx, android.BuildParams{
Rule: injectVersionSymbol,
Description: "inject version symbol",
Input: in,
Output: out,
+ OrderOnly: android.Paths{buildNumberFile},
Args: map[string]string{
- "buildNumberFromFile": proptools.NinjaEscape(ctx.Config().BuildNumberFromFile()),
+ "buildNumberFile": buildNumberFile.String(),
},
})
}