Merge "Improve optimize bp2build conditional." into main am: 8559872623 am: 6c49c4a1d5

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2762806

Change-Id: Ib480e7bf5525173b01ae47846cd721e5c992fd3c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-09-26 17:00:16 +00:00
committed by Automerger Merge Worker

View File

@@ -1689,16 +1689,12 @@ func convertWithBp2build(ctx android.Bp2buildMutatorContext, a *AndroidApp) (boo
// //
// TODO(b/192032291): Disable android_test_helper_app optimization by // TODO(b/192032291): Disable android_test_helper_app optimization by
// default after auditing downstream usage. // default after auditing downstream usage.
if a.dexProperties.Optimize.Enabled == nil { if a.dexProperties.Optimize.EnabledByDefault != a.dexer.effectiveOptimizeEnabled() {
// Property was not explicitly defined. // Property is explicitly defined by default from default, so emit the Bazel attribute.
a.dexProperties.Optimize.Enabled = &a.dexProperties.Optimize.EnabledByDefault appAttrs.Optimize = proptools.BoolPtr(a.dexer.effectiveOptimizeEnabled())
} }
if Bool(a.dexProperties.Optimize.Enabled) {
if !a.dexProperties.Optimize.EnabledByDefault {
// explicitly enable optimize for module types that disable it by default
appAttrs.Optimize = proptools.BoolPtr(true)
}
if a.dexer.effectiveOptimizeEnabled() {
handCraftedFlags := "" handCraftedFlags := ""
if Bool(a.dexProperties.Optimize.Ignore_warnings) { if Bool(a.dexProperties.Optimize.Ignore_warnings) {
handCraftedFlags += "-ignorewarning " handCraftedFlags += "-ignorewarning "
@@ -1728,9 +1724,6 @@ func convertWithBp2build(ctx android.Bp2buildMutatorContext, a *AndroidApp) (boo
}) })
appAttrs.Proguard_specs.Add(bazel.MakeLabelAttribute(":" + generatedFlagFileRuleName)) appAttrs.Proguard_specs.Add(bazel.MakeLabelAttribute(":" + generatedFlagFileRuleName))
} }
} else if a.dexProperties.Optimize.EnabledByDefault {
// explicitly disable optimize for module types that enable it by default
appAttrs.Optimize = proptools.BoolPtr(false)
} }
commonAttrs, bp2BuildInfo, supported := a.convertLibraryAttrsBp2Build(ctx) commonAttrs, bp2BuildInfo, supported := a.convertLibraryAttrsBp2Build(ctx)