summaryrefslogtreecommitdiff
path: root/java/builder.go
diff options
context:
space:
mode:
author Luca Stefani <luca.stefani.ge1@gmail.com> 2024-12-17 14:19:09 +0100
committer Luca Stefani <luca.stefani.ge1@gmail.com> 2025-01-03 12:15:40 +0100
commit172c56d662f5aaa832cd4fbe33cd4e1083adf44c (patch)
tree420b69fabae93605930626331292b1f5f397e0d8 /java/builder.go
parent9f6cee1eb5af46e8e75db15668755e59cb153624 (diff)
Extract proguard rules found in imported JAR archives
In Android Studio R8 is able to use bundled proguard rules found both in AAR archives (under /proguard.txt) and JAR archives (under /META-INF/proguard/*) Soong currently only handles the _easier_ AAR format and ignores the possibility to have rules in JAR archives. To support those rules we use the newly introduced ExtractR8Rules cli tool in R8 to extract all the embedded rules in the imported JAR for later propagation. Bug: 377144587 Test: m, including okhttp-4.12.0.jar now doesn't create R8 warnings. Change-Id: I10f9bbf76bc8daec1ec470fb493e399d1beffc8a
Diffstat (limited to 'java/builder.go')
-rw-r--r--java/builder.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/java/builder.go b/java/builder.go
index 88058e09a..72f4e145c 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -226,6 +226,12 @@ var (
},
"jarArgs")
+ extractR8Rules = pctx.AndroidStaticRule("extractR8Rules",
+ blueprint.RuleParams{
+ Command: `${config.ExtractR8RulesCmd} --rules-output $out --include-origin-comments $in`,
+ CommandDeps: []string{"${config.ExtractR8RulesCmd}"},
+ })
+
jarjar = pctx.AndroidStaticRule("jarjar",
blueprint.RuleParams{
Command: "" +
@@ -739,6 +745,16 @@ func TransformJarsToJar(ctx android.ModuleContext, outputFile android.WritablePa
})
}
+func TransformJarToR8Rules(ctx android.ModuleContext, outputFile android.WritablePath,
+ jar android.Path) {
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: extractR8Rules,
+ Output: outputFile,
+ Input: jar,
+ })
+}
+
func convertImplementationJarToHeaderJar(ctx android.ModuleContext, implementationJarFile android.Path,
headerJarFile android.WritablePath) {
ctx.Build(pctx, android.BuildParams{