summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go381
1 files changed, 278 insertions, 103 deletions
diff --git a/java/java.go b/java/java.go
index b2bd2b0a4..e6ed931fe 100644
--- a/java/java.go
+++ b/java/java.go
@@ -41,7 +41,6 @@ func init() {
android.RegisterModuleType("java_binary_host", BinaryHostFactory)
android.RegisterModuleType("java_import", ImportFactory)
android.RegisterModuleType("java_import_host", ImportFactoryHost)
- android.RegisterModuleType("android_app", AndroidAppFactory)
android.RegisterSingletonType("logtags", LogtagsSingleton)
}
@@ -51,9 +50,6 @@ func init() {
// Renderscript
// Post-jar passes:
// Proguard
-// Jacoco
-// Jarjar
-// Dex
// Rmtypedefs
// DroidDoc
// Findbugs
@@ -127,6 +123,31 @@ type CompilerProperties struct {
// List of javac flags that should only be used when passing -source 1.9
Javacflags []string
}
+
+ Jacoco struct {
+ // List of classes to include for instrumentation with jacoco to collect coverage
+ // information at runtime when building with coverage enabled. If unset defaults to all
+ // classes.
+ // Supports '*' as the last character of an entry in the list as a wildcard match.
+ // If preceded by '.' it matches all classes in the package and subpackages, otherwise
+ // it matches classes in the package that have the class name as a prefix.
+ Include_filter []string
+
+ // List of classes to exclude from instrumentation with jacoco to collect coverage
+ // information at runtime when building with coverage enabled. Overrides classes selected
+ // by the include_filter property.
+ // Supports '*' as the last character of an entry in the list as a wildcard match.
+ // If preceded by '.' it matches all classes in the package and subpackages, otherwise
+ // it matches classes in the package that have the class name as a prefix.
+ Exclude_filter []string
+ }
+
+ Proto struct {
+ // List of extra options that will be passed to the proto generator.
+ Output_params []string
+ }
+
+ Instrument bool `blueprint:"mutated"`
}
type CompilerDeviceProperties struct {
@@ -151,9 +172,24 @@ type CompilerDeviceProperties struct {
// If true, export a copy of the module as a -hostdex module for host testing.
Hostdex *bool
- // If false, prevent dexpreopting and stripping the dex file from the final jar. Defaults to
- // true.
- Dex_preopt *bool
+ Dex_preopt struct {
+ // If false, prevent dexpreopting and stripping the dex file from the final jar. Defaults to
+ // true.
+ Enabled *bool
+
+ // If true, generate an app image (.art file) for this module.
+ App_image *bool
+
+ // If true, use a checked-in profile to guide optimization. Defaults to false unless
+ // a matching profile is set or a profile is found in PRODUCT_DEX_PREOPT_PROFILE_DIR
+ // that matches the name of this module, in which case it is defaulted to true.
+ Profile_guided *bool
+
+ // If set, provides the path to profile relative to the Android.bp file. If not set,
+ // defaults to searching for a file that matches the name of this module in the default
+ // profile location set by PRODUCT_DEX_PREOPT_PROFILE_DIR, or empty if not found.
+ Profile *string
+ }
// When targeting 1.9, override the modules to use with --system
System_modules *string
@@ -177,6 +213,9 @@ type Module struct {
// output file containing classes.dex
dexJarFile android.Path
+ // output file containing uninstrumented classes that will be instrumented by jacoco
+ jacocoReportClassesFile android.Path
+
// output file suitable for installing or running
outputFile android.Path
@@ -184,14 +223,20 @@ type Module struct {
logtagsSrcs android.Paths
- // jars containing source files that should be included in the javac command line,
- // for example R.java generated by aapt for android apps
- ExtraSrcJars android.Paths
-
// installed file for binary dependency
installFile android.Path
+
+ // list of .java files and srcjars that was passed to javac
+ compiledJavaSrcs android.Paths
+ compiledSrcJars android.Paths
+}
+
+func (j *Module) Srcs() android.Paths {
+ return android.Paths{j.implementationJarFile}
}
+var _ android.SourceFileProducer = (*Module)(nil)
+
type Dependency interface {
HeaderJars() android.Paths
ImplementationJars() android.Paths
@@ -232,7 +277,7 @@ func sdkStringToNumber(ctx android.BaseContext, v string) int {
case "", "current", "system_current", "test_current":
return 10000
default:
- if i, err := strconv.Atoi(v); err != nil {
+ if i, err := strconv.Atoi(android.GetNumericSdkVersion(v)); err != nil {
ctx.PropertyErrorf("sdk_version", "invalid sdk version")
return -1
} else {
@@ -255,7 +300,13 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
jarPath := android.ExistentPathForSource(ctx, "sdkdir", jar)
aidlPath := android.ExistentPathForSource(ctx, "sdkdir", aidl)
- if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.AConfig().AllowMissingDependencies() {
+ if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() {
+ if strings.Contains(v, "system_") {
+ return sdkDep{
+ invalidVersion: true,
+ module: "vsdk_v" + strings.Replace(v, "system_", "", 1),
+ }
+ }
return sdkDep{
invalidVersion: true,
module: "sdk_v" + v,
@@ -287,7 +338,7 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
// }
//}
- if ctx.AConfig().UnbundledBuild() && v != "" {
+ if ctx.Config().UnbundledBuild() && v != "" {
return toFile(v)
}
@@ -315,14 +366,14 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
sdkDep := decodeSdkDep(ctx, String(j.deviceProperties.Sdk_version))
if sdkDep.useDefaultLibs {
ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...)
- if ctx.AConfig().TargetOpenJDK9() {
+ if ctx.Config().TargetOpenJDK9() {
ctx.AddDependency(ctx.Module(), systemModulesTag, config.DefaultSystemModules)
}
if !proptools.Bool(j.properties.No_framework_libs) {
ctx.AddDependency(ctx.Module(), libTag, config.DefaultLibraries...)
}
} else if sdkDep.useModule {
- if ctx.AConfig().TargetOpenJDK9() {
+ if ctx.Config().TargetOpenJDK9() {
ctx.AddDependency(ctx.Module(), systemModulesTag, sdkDep.systemModules)
}
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module)
@@ -330,9 +381,12 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
} else if j.deviceProperties.System_modules == nil {
ctx.PropertyErrorf("no_standard_libs",
"system_modules is required to be set when no_standard_libs is true, did you mean no_framework_libs?")
- } else if *j.deviceProperties.System_modules != "none" && ctx.AConfig().TargetOpenJDK9() {
+ } else if *j.deviceProperties.System_modules != "none" && ctx.Config().TargetOpenJDK9() {
ctx.AddDependency(ctx.Module(), systemModulesTag, *j.deviceProperties.System_modules)
}
+ if ctx.ModuleName() == "framework" {
+ ctx.AddDependency(ctx.Module(), frameworkResTag, "framework-res")
+ }
}
ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
@@ -341,6 +395,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
android.ExtractSourcesDeps(ctx, j.properties.Srcs)
android.ExtractSourcesDeps(ctx, j.properties.Java_resources)
+ android.ExtractSourceDeps(ctx, j.properties.Manifest)
if j.hasSrcExt(".proto") {
protoDeps(ctx, &j.protoProperties)
@@ -418,6 +473,15 @@ type deps struct {
kotlinStdlib android.Paths
}
+func checkProducesJars(ctx android.ModuleContext, dep android.SourceFileProducer) {
+ for _, f := range dep.Srcs() {
+ if f.Ext() != ".jar" {
+ ctx.ModuleErrorf("genrule %q must generate files ending with .jar to be used as a libs or static_libs dependency",
+ ctx.OtherModuleName(dep.(blueprint.Module)))
+ }
+ }
+}
+
func (j *Module) collectDeps(ctx android.ModuleContext) deps {
var deps deps
@@ -434,8 +498,46 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
otherName := ctx.OtherModuleName(module)
tag := ctx.OtherModuleDependencyTag(module)
- dep, _ := module.(Dependency)
- if dep == nil {
+ switch dep := module.(type) {
+ case Dependency:
+ switch tag {
+ case bootClasspathTag:
+ deps.bootClasspath = append(deps.bootClasspath, dep.HeaderJars()...)
+ case libTag:
+ deps.classpath = append(deps.classpath, dep.HeaderJars()...)
+ case staticLibTag:
+ deps.classpath = append(deps.classpath, dep.HeaderJars()...)
+ deps.staticJars = append(deps.staticJars, dep.ImplementationJars()...)
+ deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars()...)
+ case frameworkResTag:
+ if ctx.ModuleName() == "framework" {
+ // framework.jar has a one-off dependency on the R.java and Manifest.java files
+ // generated by framework-res.apk
+ deps.srcJars = append(deps.srcJars, dep.(*AndroidApp).aaptSrcJar)
+ }
+ case kotlinStdlibTag:
+ deps.kotlinStdlib = dep.HeaderJars()
+ default:
+ panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
+ }
+
+ deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
+ case android.SourceFileProducer:
+ switch tag {
+ case libTag:
+ checkProducesJars(ctx, dep)
+ deps.classpath = append(deps.classpath, dep.Srcs()...)
+ case staticLibTag:
+ checkProducesJars(ctx, dep)
+ deps.classpath = append(deps.classpath, dep.Srcs()...)
+ deps.staticJars = append(deps.staticJars, dep.Srcs()...)
+ deps.staticHeaderJars = append(deps.staticHeaderJars, dep.Srcs()...)
+ case android.DefaultsDepTag, android.SourceDepTag:
+ // Nothing to do
+ default:
+ ctx.ModuleErrorf("dependency on genrule %q may only be in srcs, libs, or static_libs", otherName)
+ }
+ default:
switch tag {
case android.DefaultsDepTag, android.SourceDepTag:
// Nothing to do
@@ -451,31 +553,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
default:
ctx.ModuleErrorf("depends on non-java module %q", otherName)
}
- return
}
-
- switch tag {
- case bootClasspathTag:
- deps.bootClasspath = append(deps.bootClasspath, dep.HeaderJars()...)
- case libTag:
- deps.classpath = append(deps.classpath, dep.HeaderJars()...)
- case staticLibTag:
- deps.classpath = append(deps.classpath, dep.HeaderJars()...)
- deps.staticJars = append(deps.staticJars, dep.ImplementationJars()...)
- deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars()...)
- case frameworkResTag:
- if ctx.ModuleName() == "framework" {
- // framework.jar has a one-off dependency on the R.java and Manifest.java files
- // generated by framework-res.apk
- // TODO(ccross): aapt java files should go in a src jar
- }
- case kotlinStdlibTag:
- deps.kotlinStdlib = dep.HeaderJars()
- default:
- panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
- }
-
- deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
})
return deps
@@ -487,10 +565,10 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
// javac flags.
javacFlags := j.properties.Javacflags
- if ctx.AConfig().TargetOpenJDK9() {
+ if ctx.Config().TargetOpenJDK9() {
javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...)
}
- if ctx.AConfig().MinimizeJavaDebugInfo() {
+ if ctx.Config().MinimizeJavaDebugInfo() {
// Override the -g flag passed globally to remove local variable debug info to reduce
// disk and memory usage.
javacFlags = append(javacFlags, "-g:source,lines")
@@ -507,7 +585,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
flags.javaVersion = *j.properties.Java_version
} else if ctx.Device() && sdk <= 23 {
flags.javaVersion = "1.7"
- } else if ctx.Device() && sdk <= 26 || !ctx.AConfig().TargetOpenJDK9() {
+ } else if ctx.Device() && sdk <= 26 || !ctx.Config().TargetOpenJDK9() {
flags.javaVersion = "1.8"
} else if ctx.Device() && String(j.deviceProperties.Sdk_version) != "" && sdk == 10000 {
// TODO(ccross): once we generate stubs we should be able to use 1.9 for sdk_version: "current"
@@ -535,26 +613,26 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
return flags
}
-func (j *Module) compile(ctx android.ModuleContext) {
+func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path) {
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs)
deps := j.collectDeps(ctx)
flags := j.collectBuilderFlags(ctx, deps)
- if ctx.AConfig().TargetOpenJDK9() {
+ if ctx.Config().TargetOpenJDK9() {
j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...)
}
srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
if hasSrcExt(srcFiles.Strings(), ".proto") {
- flags = protoFlags(ctx, &j.protoProperties, flags)
+ flags = protoFlags(ctx, &j.properties, &j.protoProperties, flags)
}
srcFiles = j.genSources(ctx, srcFiles, flags)
srcJars := srcFiles.FilterByExt(".srcjar")
srcJars = append(srcJars, deps.srcJars...)
- srcJars = append(srcJars, j.ExtraSrcJars...)
+ srcJars = append(srcJars, extraSrcJars...)
var jars android.Paths
@@ -596,8 +674,13 @@ func (j *Module) compile(ctx android.ModuleContext) {
}
}
+ // Store the list of .java files that was passed to javac
+ j.compiledJavaSrcs = uniqueSrcFiles
+ j.compiledSrcJars = srcJars
+ fullD8 := ctx.Config().UseD8Desugar()
+
enable_sharding := false
- if ctx.Device() && !ctx.AConfig().IsEnvFalse("TURBINE_ENABLED") {
+ if ctx.Device() && !ctx.Config().IsEnvFalse("TURBINE_ENABLED") {
if j.properties.Javac_shard_size != nil && *(j.properties.Javac_shard_size) > 0 {
enable_sharding = true
if len(j.properties.Annotation_processors) != 0 ||
@@ -618,7 +701,7 @@ func (j *Module) compile(ctx android.ModuleContext) {
}
if len(uniqueSrcFiles) > 0 || len(srcJars) > 0 {
var extraJarDeps android.Paths
- if ctx.AConfig().IsEnvTrue("RUN_ERROR_PRONE") {
+ if ctx.Config().IsEnvTrue("RUN_ERROR_PRONE") {
// If error-prone is enabled, add an additional rule to compile the java files into
// a separate set of classes (so that they don't overwrite the normal ones and require
// a rebuild when error-prone is turned off).
@@ -687,7 +770,10 @@ func (j *Module) compile(ctx android.ModuleContext) {
// static classpath jars have the resources in them, so the resource jars aren't necessary here
jars = append(jars, deps.staticJars...)
- manifest := android.OptionalPathForModuleSrc(ctx, j.properties.Manifest)
+ var manifest android.OptionalPath
+ if j.properties.Manifest != nil {
+ manifest = android.OptionalPathForPath(ctx.ExpandSource(*j.properties.Manifest, "manifest"))
+ }
// Combine the classes built from sources, any manifests, and any static libraries into
// classes.jar. If there is only one input jar this step will be skipped.
@@ -717,8 +803,26 @@ func (j *Module) compile(ctx android.ModuleContext) {
j.headerJarFile = j.implementationJarFile
}
+ if !fullD8 && ctx.Device() && j.installable() {
+ outputFile = j.desugar(ctx, flags, outputFile, jarName)
+ }
+
+ if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
+ if inList(ctx.ModuleName(), config.InstrumentFrameworkModules) {
+ j.properties.Instrument = true
+ }
+ }
+
+ if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") && j.properties.Instrument {
+ outputFile = j.instrument(ctx, flags, outputFile, jarName)
+ }
+
if ctx.Device() && j.installable() {
- outputFile = j.compileDex(ctx, flags, outputFile, jarName)
+ if fullD8 {
+ outputFile = j.compileDexFullD8(ctx, flags, outputFile, jarName)
+ } else {
+ outputFile = j.compileDex(ctx, flags, outputFile, jarName)
+ }
if ctx.Failed() {
return
}
@@ -766,25 +870,52 @@ func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars
return headerJar
}
+func (j *Module) desugar(ctx android.ModuleContext, flags javaBuilderFlags,
+ classesJar android.Path, jarName string) android.Path {
+
+ desugarFlags := []string{
+ "--min_sdk_version " + j.minSdkVersionNumber(ctx),
+ "--desugar_try_with_resources_if_needed=false",
+ "--allow_empty_bootclasspath",
+ }
+
+ if inList("--core-library", j.deviceProperties.Dxflags) {
+ desugarFlags = append(desugarFlags, "--core_library")
+ }
+
+ flags.desugarFlags = strings.Join(desugarFlags, " ")
+
+ desugarJar := android.PathForModuleOut(ctx, "desugar", jarName)
+ TransformDesugar(ctx, desugarJar, classesJar, flags)
+
+ return desugarJar
+}
+
+func (j *Module) instrument(ctx android.ModuleContext, flags javaBuilderFlags,
+ classesJar android.Path, jarName string) android.Path {
+
+ specs := j.jacocoModuleToZipCommand(ctx)
+
+ jacocoReportClassesFile := android.PathForModuleOut(ctx, "jacoco", "jacoco-report-classes.jar")
+ instrumentedJar := android.PathForModuleOut(ctx, "jacoco", jarName)
+
+ jacocoInstrumentJar(ctx, instrumentedJar, jacocoReportClassesFile, classesJar, specs)
+
+ j.jacocoReportClassesFile = jacocoReportClassesFile
+
+ return instrumentedJar
+}
+
func (j *Module) compileDex(ctx android.ModuleContext, flags javaBuilderFlags,
classesJar android.Path, jarName string) android.Path {
dxFlags := j.deviceProperties.Dxflags
- if false /* emma enabled */ {
- // If you instrument class files that have local variable debug information in
- // them emma does not correctly maintain the local variable table.
- // This will cause an error when you try to convert the class files for Android.
- // The workaround here is to build different dex file here based on emma switch
- // then later copy into classes.dex. When emma is on, dx is run with --no-locals
- // option to remove local variable information
- dxFlags = append(dxFlags, "--no-locals")
- }
- if ctx.AConfig().Getenv("NO_OPTIMIZE_DX") != "" {
+ if ctx.Config().Getenv("NO_OPTIMIZE_DX") != "" {
dxFlags = append(dxFlags, "--no-optimize")
}
- if ctx.AConfig().Getenv("GENERATE_DEX_DEBUG") != "" {
+ if ctx.Config().Getenv("GENERATE_DEX_DEBUG") != "" {
dxFlags = append(dxFlags,
"--debug",
"--verbose",
@@ -792,47 +923,74 @@ func (j *Module) compileDex(ctx android.ModuleContext, flags javaBuilderFlags,
"--dump-width=1000")
}
- var minSdkVersion string
- switch String(j.deviceProperties.Sdk_version) {
- case "", "current", "test_current", "system_current":
- minSdkVersion = strconv.Itoa(ctx.AConfig().DefaultAppTargetSdkInt())
- default:
- minSdkVersion = String(j.deviceProperties.Sdk_version)
- }
-
- dxFlags = append(dxFlags, "--min-sdk-version="+minSdkVersion)
+ dxFlags = append(dxFlags, "--min-sdk-version="+j.minSdkVersionNumber(ctx))
flags.dxFlags = strings.Join(dxFlags, " ")
- desugarFlags := []string{
- "--min_sdk_version " + minSdkVersion,
- "--desugar_try_with_resources_if_needed=false",
- "--allow_empty_bootclasspath",
- }
+ // Compile classes.jar into classes.dex and then javalib.jar
+ javalibJar := android.PathForModuleOut(ctx, "dex", jarName)
+ TransformClassesJarToDexJar(ctx, javalibJar, classesJar, flags)
- if inList("--core-library", dxFlags) {
- desugarFlags = append(desugarFlags, "--core_library")
+ j.dexJarFile = javalibJar
+ return javalibJar
+}
+
+func (j *Module) compileDexFullD8(ctx android.ModuleContext, flags javaBuilderFlags,
+ classesJar android.Path, jarName string) android.Path {
+
+ // Translate all the DX flags to D8 ones until all the build files have been migrated
+ // to D8 flags. See: b/69377755
+ var dxFlags []string
+ for _, x := range j.deviceProperties.Dxflags {
+ if x == "--core-library" {
+ continue
+ }
+ if x == "--dex" {
+ continue
+ }
+ if x == "--multi-dex" {
+ continue
+ }
+ if x == "--no-locals" {
+ dxFlags = append(dxFlags, "--release")
+ continue
+ }
+ dxFlags = append(dxFlags, x)
}
- flags.desugarFlags = strings.Join(desugarFlags, " ")
+ if ctx.AConfig().Getenv("NO_OPTIMIZE_DX") != "" {
+ dxFlags = append(dxFlags, "--debug")
+ }
- desugarJar := android.PathForModuleOut(ctx, "desugar", jarName)
- TransformDesugar(ctx, desugarJar, classesJar, flags)
- if ctx.Failed() {
- return nil
+ if ctx.AConfig().Getenv("GENERATE_DEX_DEBUG") != "" {
+ dxFlags = append(dxFlags,
+ "--debug",
+ "--verbose")
}
+ dxFlags = append(dxFlags, "--min-api "+j.minSdkVersionNumber(ctx))
+
+ flags.dxFlags = strings.Join(dxFlags, " ")
+
// Compile classes.jar into classes.dex and then javalib.jar
javalibJar := android.PathForModuleOut(ctx, "dex", jarName)
- TransformClassesJarToDexJar(ctx, javalibJar, desugarJar, flags)
- if ctx.Failed() {
- return nil
- }
+ TransformClassesJarToDexJar(ctx, javalibJar, classesJar, flags)
j.dexJarFile = javalibJar
return javalibJar
}
+// Returns a sdk version as a string that is guaranteed to be a parseable as a number. For
+// modules targeting an unreleased SDK (meaning it does not yet have a number) it returns "10000".
+func (j *Module) minSdkVersionNumber(ctx android.ModuleContext) string {
+ switch String(j.deviceProperties.Sdk_version) {
+ case "", "current", "test_current", "system_current":
+ return strconv.Itoa(ctx.Config().DefaultAppTargetSdkInt())
+ default:
+ return android.GetNumericSdkVersion(String(j.deviceProperties.Sdk_version))
+ }
+}
+
func (j *Module) installable() bool {
return j.properties.Installable == nil || *j.properties.Installable
}
@@ -921,7 +1079,9 @@ type Binary struct {
binaryProperties binaryProperties
- wrapperFile android.SourcePath
+ isWrapperVariant bool
+
+ wrapperFile android.Path
binaryFile android.OutputPath
}
@@ -930,21 +1090,34 @@ func (j *Binary) HostToolPath() android.OptionalPath {
}
func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- j.Library.GenerateAndroidBuildActions(ctx)
-
- // Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by
- // another build rule before the jar has been installed.
- if String(j.binaryProperties.Wrapper) != "" {
- j.wrapperFile = android.PathForModuleSrc(ctx, String(j.binaryProperties.Wrapper)).SourcePath
+ if ctx.Arch().ArchType == android.Common {
+ // Compile the jar
+ j.Library.GenerateAndroidBuildActions(ctx)
} else {
- j.wrapperFile = android.PathForSource(ctx, "build/soong/scripts/jar-wrapper.sh")
+ // Handle the binary wrapper
+ j.isWrapperVariant = true
+
+ if j.binaryProperties.Wrapper != nil {
+ j.wrapperFile = ctx.ExpandSource(*j.binaryProperties.Wrapper, "wrapper")
+ } else {
+ j.wrapperFile = android.PathForSource(ctx, "build/soong/scripts/jar-wrapper.sh")
+ }
+
+ // Depend on the installed jar so that the wrapper doesn't get executed by
+ // another build rule before the jar has been installed.
+ jarFile := ctx.PrimaryModule().(*Binary).installFile
+
+ j.binaryFile = ctx.InstallExecutable(android.PathForModuleInstall(ctx, "bin"),
+ ctx.ModuleName(), j.wrapperFile, jarFile)
}
- j.binaryFile = ctx.InstallExecutable(android.PathForModuleInstall(ctx, "bin"),
- ctx.ModuleName(), j.wrapperFile, j.installFile)
}
func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) {
- j.deps(ctx)
+ if ctx.Arch().ArchType == android.Common {
+ j.deps(ctx)
+ } else {
+ android.ExtractSourceDeps(ctx, j.binaryProperties.Wrapper)
+ }
}
func BinaryFactory() android.Module {
@@ -956,7 +1129,8 @@ func BinaryFactory() android.Module {
&module.Module.protoProperties,
&module.binaryProperties)
- InitJavaModule(module, android.HostAndDeviceSupported)
+ android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommonFirst)
+ android.InitDefaultableModule(module)
return module
}
@@ -969,7 +1143,8 @@ func BinaryHostFactory() android.Module {
&module.Module.protoProperties,
&module.binaryProperties)
- InitJavaModule(module, android.HostSupported)
+ android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommonFirst)
+ android.InitDefaultableModule(module)
return module
}