diff options
author | David Brazdil <dbrazdil@google.com> | 2018-06-27 10:27:45 +0100 |
---|---|---|
committer | David Brazdil <dbrazdil@google.com> | 2018-07-09 16:04:41 +0000 |
commit | 17ef5635fa1b81a0aa41f6ad094afc740444db36 (patch) | |
tree | 7adc3fde61735bd8aff4d71e7364325513319726 | |
parent | 17bef8f03494c7c364498c62de3ac1d30712d2e6 (diff) | |
download | build_soong-17ef5635fa1b81a0aa41f6ad094afc740444db36.tar.gz build_soong-17ef5635fa1b81a0aa41f6ad094afc740444db36.tar.bz2 build_soong-17ef5635fa1b81a0aa41f6ad094afc740444db36.zip |
Add option to compile dex for a Java library
Currently Soong will only compile a Java library into dex if the
library has device support and is installable. For our use case of
inspecting the dex at build time this is not sufficient. Add a new
"compile_dex" device property which forces the creation of a dex
rule. In this case, the class jar remains the output file of the
module.
Bug: 79409988
Test: on related CL
Change-Id: Ia908a47148a03a0bdb0da4315cce6efc86c51865
-rw-r--r-- | java/java.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/java/java.go b/java/java.go index e87a990f..00d52634 100644 --- a/java/java.go +++ b/java/java.go @@ -192,6 +192,9 @@ type CompilerDeviceProperties struct { // If true, export a copy of the module as a -hostdex module for host testing. Hostdex *bool + // If set to true, compile dex regardless of installable. Defaults to false. + Compile_dex *bool + Dex_preopt struct { // If false, prevent dexpreopting and stripping the dex file from the final jar. Defaults to // true. @@ -1134,11 +1137,15 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path outputFile = j.instrument(ctx, flags, outputFile, jarName) } - if ctx.Device() && j.installable() { - outputFile = j.compileDex(ctx, flags, outputFile, jarName) + if ctx.Device() && j.createDexRule() { + var dexOutputFile android.Path + dexOutputFile = j.compileDex(ctx, flags, outputFile, jarName) if ctx.Failed() { return } + if j.installable() { + outputFile = dexOutputFile + } } ctx.CheckbuildFile(outputFile) j.outputFile = outputFile @@ -1213,6 +1220,10 @@ func (j *Module) installable() bool { return BoolDefault(j.properties.Installable, true) } +func (j *Module) createDexRule() bool { + return Bool(j.deviceProperties.Compile_dex) || j.installable() +} + var _ Dependency = (*Library)(nil) func (j *Module) HeaderJars() android.Paths { |