summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author LaMont Jones <lamontjones@google.com> 2025-03-24 13:07:01 -0700
committer Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2025-03-25 19:23:46 -0700
commit1abd20d2e232f1a19921aecfb713f28572def8bd (patch)
tree67a51170976ac4df24f809828f70fc1c63d1c513
parentfc5e8dc9c38db6628ed1d9172161187da74b066f (diff)
Make d8-on-eng a stand-alone opt-in feature
Allow a module to override optimization on eng builds only. This adds `optimize.d8_on_eng` so that the module does not need to check the build variant itself, but can override the calculation of `optimize.enabled` for eng builds. Bug: b/374975543 Test: manual, TH (cherry picked from https://android-review.googlesource.com/q/commit:4ee862c4f17b04ee8a848f5ea8ac905be42e5209) Merged-In: I5284072e91063520cece0050eef0a7eefff54323 Change-Id: I5284072e91063520cece0050eef0a7eefff54323
-rw-r--r--java/dex.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/java/dex.go b/java/dex.go
index dd6467546..e3058e9bf 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -42,6 +42,10 @@ type DexProperties struct {
// True if the module containing this has it set by default.
EnabledByDefault bool `blueprint:"mutated"`
+ // If true, then `d8` will be used on eng builds instead of `r8`, even though
+ // optimize.enabled is true.
+ D8_on_eng *bool
+
// Whether to allow that library classes inherit from program classes.
// Defaults to false.
Ignore_library_extends_program *bool
@@ -162,7 +166,12 @@ type dexer struct {
}
func (d *dexer) effectiveOptimizeEnabled(ctx android.EarlyModuleContext) bool {
- return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault && !ctx.Config().Eng())
+ // For eng builds, if Optimize.D8_on_eng is true, then disable optimization.
+ if ctx.Config().Eng() && proptools.Bool(d.dexProperties.Optimize.D8_on_eng) {
+ return false
+ }
+ // Otherwise, use the legacy logic of a default value which can be explicitly overridden by the module.
+ return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault)
}
func (d *DexProperties) resourceShrinkingEnabled(ctx android.ModuleContext) bool {