summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2021-02-08 10:14:04 -0800
committer Colin Cross <ccross@android.com> 2021-02-08 10:14:04 -0800
commitd97cf63cdf31cd7b78cdabedab2f159be836bfea (patch)
treead9c78f63071045398dbcd7358fd36c7fb9f873d
parent033bfa6e2903bbf858d7b666c5e52db69ba68bb4 (diff)
Turn missing jarjar output files into errors
Jarjar doesn't exit with a nonzero return code when there is a syntax error in a rules file and doesn't write the output file. Without a nonzero return code ninja prints a warning but continues, which leads to stale results on incremental builds where the output file already exists, or delayed errors on clean builds whre the output file didn't exist. Delete the output file before running jarjar, and then check if it exists after running jarjar. Fixes: 119516143 Test: m out/target/common/obj/APPS/TeleService_intermediates/classes.jar Change-Id: I7e9f7ff34de565a986ab0dc6e375f606c91c3846
-rw-r--r--java/builder.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/java/builder.go b/java/builder.go
index 995160d0e..22a891ae1 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -193,12 +193,19 @@ var (
jarjar = pctx.AndroidStaticRule("jarjar",
blueprint.RuleParams{
- Command: "${config.JavaCmd} ${config.JavaVmFlags}" +
+ Command: "" +
+ // Jarjar doesn't exit with an error when the rules file contains a syntax error,
+ // leading to stale or missing files later in the build. Remove the output file
+ // before running jarjar.
+ "rm -f ${out} && " +
+ "${config.JavaCmd} ${config.JavaVmFlags}" +
// b/146418363 Enable Android specific jarjar transformer to drop compat annotations
// for newly repackaged classes. Dropping @UnsupportedAppUsage on repackaged classes
// avoids adding new hiddenapis after jarjar'ing.
" -DremoveAndroidCompatAnnotations=true" +
- " -jar ${config.JarjarCmd} process $rulesFile $in $out",
+ " -jar ${config.JarjarCmd} process $rulesFile $in $out && " +
+ // Turn a missing output file into a ninja error
+ `[ -e ${out} ] || (echo "Missing output file"; exit 1)`,
CommandDeps: []string{"${config.JavaCmd}", "${config.JarjarCmd}", "$rulesFile"},
},
"rulesFile")