From 6b21c7d2abb207b325fd4117d032a94b34ee2599 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 11 Feb 2020 09:16:01 +0900 Subject: [PATCH] Automatically set compile_dex:true and hostdex:true for APEX variants ... unless they are turned off explicitly. Bug: 147221965 Test: m Change-Id: I6b91d6409d9cf06ad09467c53d5d51a9c693256e --- apex/apex_test.go | 8 +------- java/java.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apex/apex_test.go b/apex/apex_test.go index 508bde600..9152fddd9 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -453,7 +453,6 @@ func TestBasicApex(t *testing.T) { srcs: ["foo/bar/MyClass.java"], sdk_version: "none", system_modules: "none", - compile_dex: true, static_libs: ["myotherjar"], libs: ["mysharedjar"], // TODO: remove //apex_available:platform @@ -468,7 +467,6 @@ func TestBasicApex(t *testing.T) { srcs: ["foo/bar/MyClass.java"], sdk_version: "none", system_modules: "none", - compile_dex: true, // TODO: remove //apex_available:platform apex_available: [ "//apex_available:platform", @@ -481,7 +479,6 @@ func TestBasicApex(t *testing.T) { srcs: ["foo/bar/MyClass.java"], sdk_version: "none", system_modules: "none", - compile_dex: true, } `) @@ -594,7 +591,6 @@ func TestDefaults(t *testing.T) { srcs: ["foo/bar/MyClass.java"], sdk_version: "none", system_modules: "none", - compile_dex: true, apex_available: [ "myapex" ], } @@ -2987,7 +2983,6 @@ func TestErrorsIfDepsAreNotEnabled(t *testing.T) { srcs: ["foo/bar/MyClass.java"], sdk_version: "none", system_modules: "none", - compile_dex: true, enabled: false, } `) @@ -3518,7 +3513,6 @@ func TestCompatConfig(t *testing.T) { srcs: ["foo/bar/MyClass.java"], sdk_version: "none", system_modules: "none", - compile_dex: true, apex_available: [ "myapex" ], } `) @@ -3547,6 +3541,7 @@ func TestRejectNonInstallableJavaLibrary(t *testing.T) { srcs: ["foo/bar/MyClass.java"], sdk_version: "none", system_modules: "none", + compile_dex: false, } `) } @@ -3633,7 +3628,6 @@ func TestSymlinksFromApexToSystem(t *testing.T) { sdk_version: "none", system_modules: "none", libs: ["myotherjar"], - compile_dex: true, apex_available: [ "myapex", "//apex_available:platform", diff --git a/java/java.go b/java/java.go index dd44d06aa..279d67424 100644 --- a/java/java.go +++ b/java/java.go @@ -1475,6 +1475,16 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { j.implementationAndResourcesJar = implementationAndResourcesJar + // Enable dex compilation for the APEX variants, unless it is disabled explicitly + if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !j.IsForPlatform() { + if j.deviceProperties.Compile_dex == nil { + j.deviceProperties.Compile_dex = proptools.BoolPtr(true) + } + if j.deviceProperties.Hostdex == nil { + j.deviceProperties.Hostdex = proptools.BoolPtr(true) + } + } + if ctx.Device() && j.hasCode(ctx) && (Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) { // Dex compilation