summaryrefslogtreecommitdiff
path: root/java/dex.go
diff options
context:
space:
mode:
author Rico Wind <ricow@google.com> 2023-11-23 08:41:28 +0100
committer Rico Wind <ricow@google.com> 2023-11-28 13:47:02 +0000
commit20c2010030612da735e0416c03a3ca884f1ef6ac (patch)
treefc51250d346189a9c5581debb705ce89426f9b6e /java/dex.go
parentf24ed7e3a9f562ce2818f9927805be6558971355 (diff)
Reapply "Use R8 for resource shrinking"
This reverts commit a9fd59a7f28df05f9d75bda7d661241e4d1a3f6a. We are moving the resource shinking pipeline into r8 (gennerally, not just for platform) This disables the usage of the resource shrinker cli from cmd-line tools There are no changes in this cl compared to the original land, the fix was done in R8 (to use the same compression for res folder entries as in the original) Bug: 308710394 Bug: 309078004 Test: Existing, validated that resource table on SystemUI was byte<>byte equal, validated uncompression Ignore-AOSP-First: Merge does not apply cleanly Change-Id: Ib8a6fb128084e994325b975c46a036cb41494654
Diffstat (limited to 'java/dex.go')
-rw-r--r--java/dex.go39
1 files changed, 27 insertions, 12 deletions
diff --git a/java/dex.go b/java/dex.go
index aa017834d..ee28643e9 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -95,6 +95,8 @@ type dexer struct {
proguardDictionary android.OptionalPath
proguardConfiguration android.OptionalPath
proguardUsageZip android.OptionalPath
+ resourcesInput android.OptionalPath
+ resourcesOutput android.OptionalPath
providesTransitiveHeaderJars
}
@@ -161,7 +163,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8",
"$r8Template": &remoteexec.REParams{
Labels: map[string]string{"type": "compile", "compiler": "r8"},
Inputs: []string{"$implicits", "${config.R8Jar}"},
- OutputFiles: []string{"${outUsage}", "${outConfig}", "${outDict}"},
+ OutputFiles: []string{"${outUsage}", "${outConfig}", "${outDict}", "${resourcesOutput}"},
ExecStrategy: "${config.RER8ExecStrategy}",
ToolchainInputs: []string{"${config.JavaCmd}"},
Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"},
@@ -181,7 +183,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8",
Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"},
},
}, []string{"outDir", "outDict", "outConfig", "outUsage", "outUsageZip", "outUsageDir",
- "r8Flags", "zipFlags", "mergeZipsFlags"}, []string{"implicits"})
+ "r8Flags", "zipFlags", "mergeZipsFlags", "resourcesOutput"}, []string{"implicits"})
func (d *dexer) dexCommonFlags(ctx android.ModuleContext,
dexParams *compileDexParams) (flags []string, deps android.Paths) {
@@ -350,6 +352,12 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8Fl
r8Flags = append(r8Flags, "-ignorewarnings")
}
+ if d.resourcesInput.Valid() {
+ r8Flags = append(r8Flags, "--resource-input", d.resourcesInput.Path().String())
+ r8Deps = append(r8Deps, d.resourcesInput.Path())
+ r8Flags = append(r8Flags, "--resource-output", d.resourcesOutput.Path().String())
+ }
+
return r8Flags, r8Deps
}
@@ -391,6 +399,8 @@ func (d *dexer) compileDex(ctx android.ModuleContext, dexParams *compileDexParam
android.ModuleNameWithPossibleOverride(ctx), "unused.txt")
proguardUsageZip := android.PathForModuleOut(ctx, "proguard_usage.zip")
d.proguardUsageZip = android.OptionalPathForPath(proguardUsageZip)
+ resourcesOutput := android.PathForModuleOut(ctx, "package-res-shrunken.apk")
+ d.resourcesOutput = android.OptionalPathForPath(resourcesOutput)
r8Flags, r8Deps := d.r8Flags(ctx, dexParams.flags)
r8Deps = append(r8Deps, commonDeps...)
rule := r8
@@ -409,17 +419,22 @@ func (d *dexer) compileDex(ctx android.ModuleContext, dexParams *compileDexParam
rule = r8RE
args["implicits"] = strings.Join(r8Deps.Strings(), ",")
}
+ implicitOutputs := android.WritablePaths{
+ proguardDictionary,
+ proguardUsageZip,
+ proguardConfiguration}
+ if d.resourcesInput.Valid() {
+ implicitOutputs = append(implicitOutputs, resourcesOutput)
+ args["resourcesOutput"] = resourcesOutput.String()
+ }
ctx.Build(pctx, android.BuildParams{
- Rule: rule,
- Description: "r8",
- Output: javalibJar,
- ImplicitOutputs: android.WritablePaths{
- proguardDictionary,
- proguardUsageZip,
- proguardConfiguration},
- Input: dexParams.classesJar,
- Implicits: r8Deps,
- Args: args,
+ Rule: rule,
+ Description: "r8",
+ Output: javalibJar,
+ ImplicitOutputs: implicitOutputs,
+ Input: dexParams.classesJar,
+ Implicits: r8Deps,
+ Args: args,
})
} else {
d8Flags, d8Deps := d8Flags(dexParams.flags)