Merge "Don't run resource shrinking for eng builds" into main

This commit is contained in:
Rico Wind 2024-05-14 04:04:17 +00:00 committed by Gerrit Code Review
commit c3e6594a0d
2 changed files with 10 additions and 6 deletions

View file

@ -538,7 +538,7 @@ func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
}
// Use non final ids if we are doing optimized shrinking and are using R8.
nonFinalIds := Bool(a.dexProperties.Optimize.Optimized_shrink_resources) && a.dexer.effectiveOptimizeEnabled()
nonFinalIds := a.dexProperties.optimizedResourceShrinkingEnabled(ctx) && a.dexer.effectiveOptimizeEnabled()
a.aapt.buildActions(ctx,
aaptBuildActionOptions{
sdkContext: android.SdkContext(a),
@ -569,7 +569,7 @@ func (a *AndroidApp) proguardBuildActions(ctx android.ModuleContext) {
staticLibProguardFlagFiles = android.FirstUniquePaths(staticLibProguardFlagFiles)
a.Module.extraProguardFlagsFiles = append(a.Module.extraProguardFlagsFiles, staticLibProguardFlagFiles...)
if !Bool(a.dexProperties.Optimize.Optimized_shrink_resources) {
if !(a.dexProperties.optimizedResourceShrinkingEnabled(ctx)) {
// When using the optimized shrinking the R8 enqueuer will traverse the xml files that become
// live for code references and (transitively) mark these as live.
// In this case we explicitly don't wan't the aapt2 generated keep files (which would keep the now
@ -608,7 +608,7 @@ func (a *AndroidApp) dexBuildActions(ctx android.ModuleContext) (android.Path, a
var packageResources = a.exportPackage
if ctx.ModuleName() != "framework-res" {
if a.dexProperties.resourceShrinkingEnabled() {
if a.dexProperties.resourceShrinkingEnabled(ctx) {
protoFile := android.PathForModuleOut(ctx, packageResources.Base()+".proto.apk")
aapt2Convert(ctx, protoFile, packageResources, "proto")
a.dexer.resourcesInput = android.OptionalPathForPath(protoFile)
@ -631,7 +631,7 @@ func (a *AndroidApp) dexBuildActions(ctx android.ModuleContext) (android.Path, a
}
a.Module.compile(ctx, extraSrcJars, extraClasspathJars, extraCombinedJars)
if a.dexProperties.resourceShrinkingEnabled() {
if a.dexProperties.resourceShrinkingEnabled(ctx) {
binaryResources := android.PathForModuleOut(ctx, packageResources.Base()+".binary.out.apk")
aapt2Convert(ctx, binaryResources, a.dexer.resourcesOutput.Path(), "binary")
packageResources = binaryResources

View file

@ -111,8 +111,12 @@ func (d *dexer) effectiveOptimizeEnabled() bool {
return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault)
}
func (d *DexProperties) resourceShrinkingEnabled() bool {
return BoolDefault(d.Optimize.Optimized_shrink_resources, Bool(d.Optimize.Shrink_resources))
func (d *DexProperties) resourceShrinkingEnabled(ctx android.ModuleContext) bool {
return !ctx.Config().Eng() && BoolDefault(d.Optimize.Optimized_shrink_resources, Bool(d.Optimize.Shrink_resources))
}
func (d *DexProperties) optimizedResourceShrinkingEnabled(ctx android.ModuleContext) bool {
return d.resourceShrinkingEnabled(ctx) && Bool(d.Optimize.Optimized_shrink_resources)
}
var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8",