summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
author Sasha Smundak <asmundak@google.com> 2019-04-16 17:16:58 -0700
committer Colin Cross <ccross@android.com> 2019-04-22 10:46:51 -0700
commit4eaeab4442a9b760ed9f07ca5b40088cb602def9 (patch)
tree7df1d90e6bdeefbcf2fd7c7f919f4cd81e7b7bc8 /java/java.go
parent5c87791a78fc31620b165300c7976d8cf5674f9c (diff)
Fix handling optimize.enabled from java_defaults
Some module types (`android_test`, etc.) set `optimize.enabled` by default. If such module happens to have `defaults` attribute which clears `optimize.enabled`, the latter value is ignored. Fixes: 129858282 Test: unit tests in java_test.go, `atest CtsExtendedMockingTestCases` succeeds with aog/936802 reverted (that is, with cts/test/mocking converted to Android.bp) Change-Id: Ib8e3a0ab0bd489d70ed07f626082aeae31c45e7c Merged-In: Ib8e3a0ab0bd489d70ed07f626082aeae31c45e7c (cherry picked from commit 2057f82161dec05cb23535da713ec0fae44c38d1)
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/java/java.go b/java/java.go
index 793e40b5d..b0ad8c26d 100644
--- a/java/java.go
+++ b/java/java.go
@@ -228,6 +228,8 @@ type CompilerDeviceProperties struct {
// If false, disable all optimization. Defaults to true for android_app and android_test
// modules, false for java_library and java_test modules.
Enabled *bool
+ // True if the module containing this has it set by default.
+ EnabledByDefault bool `blueprint:"mutated"`
// If true, optimize for size by removing unused code. Defaults to true for apps,
// false for libraries and tests.
@@ -257,6 +259,10 @@ type CompilerDeviceProperties struct {
IsSDKLibrary bool `blueprint:"mutated"`
}
+func (me *CompilerDeviceProperties) EffectiveOptimizeEnabled() bool {
+ return BoolDefault(me.Optimize.Enabled, me.Optimize.EnabledByDefault)
+}
+
// Module contains the properties and members used by all java module types
type Module struct {
android.ModuleBase
@@ -460,7 +466,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
} else if sdkDep.useModule {
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...)
- if Bool(j.deviceProperties.Optimize.Enabled) {
+ if j.deviceProperties.EffectiveOptimizeEnabled() {
ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultBootclasspathLibraries...)
ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultLibraries...)
}