diff options
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 76 |
1 files changed, 52 insertions, 24 deletions
diff --git a/java/java.go b/java/java.go index 808c3896d..9000f7478 100644 --- a/java/java.go +++ b/java/java.go @@ -201,7 +201,10 @@ type CompilerProperties struct { // List of modules to use as annotation processors Plugins []string - // List of modules to export to libraries that directly depend on this library as annotation processors + // List of modules to export to libraries that directly depend on this library as annotation + // processors. Note that if the plugins set generates_api: true this will disable the turbine + // optimization on modules that depend on this module, which will reduce parallelism and cause + // more recompilation. Exported_plugins []string // The number of Java source entries each Javac instance can process @@ -428,6 +431,9 @@ type Module struct { // list of plugins that this java module is exporting exportedPluginClasses []string + // if true, the exported plugins generate API and require disabling turbine. + exportedDisableTurbine bool + // list of source files, collected from srcFiles with unique java and all kt files, // will be used by android.IDEInfo struct expandIDEInfoCompiledSrcs []string @@ -450,8 +456,6 @@ type Module struct { // list of the xref extraction files kytheFiles android.Paths - distFiles android.TaggedDistFiles - // Collect the module directory for IDE info in java/jdeps.go. modulePaths []string @@ -480,6 +484,8 @@ func (j *Module) OutputFiles(tag string) (android.Paths, error) { switch tag { case "": return append(android.Paths{j.outputFile}, j.extraOutputFiles...), nil + case android.DefaultDistTag: + return android.Paths{j.outputFile}, nil case ".jar": return android.Paths{j.implementationAndResourcesJar}, nil case ".proguard_map": @@ -513,7 +519,7 @@ type Dependency interface { ResourceJars() android.Paths AidlIncludeDirs() android.Paths ClassLoaderContexts() dexpreopt.ClassLoaderContextMap - ExportedPlugins() (android.Paths, []string) + ExportedPlugins() (android.Paths, []string, bool) SrcJarArgs() ([]string, android.Paths) BaseModuleName() string JacocoReportClassesFile() android.Path @@ -550,6 +556,14 @@ type dependencyTag struct { name string } +// installDependencyTag is a dependency tag that is annotated to cause the installed files of the +// dependency to be installed when the parent module is installed. +type installDependencyTag struct { + blueprint.BaseDependencyTag + android.InstallAlwaysNeededDependencyTag + name string +} + type usesLibraryDependencyTag struct { dependencyTag sdkVersion int // SDK version in which the library appared as a standalone library. @@ -584,6 +598,8 @@ var ( instrumentationForTag = dependencyTag{name: "instrumentation_for"} extraLintCheckTag = dependencyTag{name: "extra-lint-check"} jniLibTag = dependencyTag{name: "jnilib"} + jniInstallTag = installDependencyTag{name: "jni install"} + binaryInstallTag = installDependencyTag{name: "binary install"} usesLibTag = makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion) usesLibCompat28Tag = makeUsesLibraryDependencyTag(28) usesLibCompat29Tag = makeUsesLibraryDependencyTag(29) @@ -1066,7 +1082,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { case libTag: deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...) // names of sdk libs that are directly depended are exported - j.classLoaderContexts.MaybeAddContext(ctx, dep.OptionalImplicitSdkLibrary(), true, + j.classLoaderContexts.MaybeAddContext(ctx, dep.OptionalImplicitSdkLibrary(), dep.DexJarBuildPath(), dep.DexJarInstallPath()) case staticLibTag: ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName) @@ -1080,8 +1096,9 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { // sdk lib names from dependencies are re-exported j.classLoaderContexts.AddContextMap(dep.ClassLoaderContexts(), otherName) deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...) - pluginJars, pluginClasses := dep.ExportedPlugins() + pluginJars, pluginClasses, disableTurbine := dep.ExportedPlugins() addPlugins(&deps, pluginJars, pluginClasses...) + deps.disableTurbine = deps.disableTurbine || disableTurbine case java9LibTag: deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars()...) case staticLibTag: @@ -1092,8 +1109,12 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { // sdk lib names from dependencies are re-exported j.classLoaderContexts.AddContextMap(dep.ClassLoaderContexts(), otherName) deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...) - pluginJars, pluginClasses := dep.ExportedPlugins() + pluginJars, pluginClasses, disableTurbine := dep.ExportedPlugins() addPlugins(&deps, pluginJars, pluginClasses...) + // Turbine doesn't run annotation processors, so any module that uses an + // annotation processor that generates API is incompatible with the turbine + // optimization. + deps.disableTurbine = deps.disableTurbine || disableTurbine case pluginTag: if plugin, ok := dep.(*Plugin); ok { if plugin.pluginProperties.Processor_class != nil { @@ -1101,6 +1122,9 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { } else { addPlugins(&deps, plugin.ImplementationAndResourcesJars()) } + // Turbine doesn't run annotation processors, so any module that uses an + // annotation processor that generates API is incompatible with the turbine + // optimization. deps.disableTurbine = deps.disableTurbine || Bool(plugin.pluginProperties.Generates_api) } else { ctx.PropertyErrorf("plugins", "%q is not a java_plugin module", otherName) @@ -1113,13 +1137,14 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { } case exportedPluginTag: if plugin, ok := dep.(*Plugin); ok { - if plugin.pluginProperties.Generates_api != nil && *plugin.pluginProperties.Generates_api { - ctx.PropertyErrorf("exported_plugins", "Cannot export plugins with generates_api = true, found %v", otherName) - } j.exportedPluginJars = append(j.exportedPluginJars, plugin.ImplementationAndResourcesJars()...) if plugin.pluginProperties.Processor_class != nil { j.exportedPluginClasses = append(j.exportedPluginClasses, *plugin.pluginProperties.Processor_class) } + // Turbine doesn't run annotation processors, so any module that uses an + // annotation processor that generates API is incompatible with the turbine + // optimization. + j.exportedDisableTurbine = Bool(plugin.pluginProperties.Generates_api) } else { ctx.PropertyErrorf("exported_plugins", "%q is not a java_plugin module", otherName) } @@ -1953,8 +1978,11 @@ func (j *Module) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap { return j.classLoaderContexts } -func (j *Module) ExportedPlugins() (android.Paths, []string) { - return j.exportedPluginJars, j.exportedPluginClasses +// ExportedPlugins returns the list of jars needed to run the exported plugins, the list of +// classes for the plugins, and a boolean for whether turbine needs to be disabled due to plugins +// that generate APIs. +func (j *Module) ExportedPlugins() (android.Paths, []string, bool) { + return j.exportedPluginJars, j.exportedPluginClasses, j.exportedDisableTurbine } func (j *Module) SrcJarArgs() ([]string, android.Paths) { @@ -2108,15 +2136,13 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { // add the name of that java_sdk_library to the exported sdk libs to make sure // that, if necessary, a <uses-library> element for that java_sdk_library is // added to the Android manifest. - j.classLoaderContexts.MaybeAddContext(ctx, j.OptionalImplicitSdkLibrary(), true, + j.classLoaderContexts.MaybeAddContext(ctx, j.OptionalImplicitSdkLibrary(), j.DexJarBuildPath(), j.DexJarInstallPath()) // A non-SDK library may provide a <uses-library> (the name may be different from the module name). if lib := proptools.String(j.usesLibraryProperties.Provides_uses_lib); lib != "" { - j.classLoaderContexts.AddContext(ctx, lib, true, j.DexJarBuildPath(), j.DexJarInstallPath()) + j.classLoaderContexts.AddContext(ctx, lib, j.DexJarBuildPath(), j.DexJarInstallPath()) } - - j.distFiles = j.GenerateTaggedDistFiles(ctx) } func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) { @@ -2599,9 +2625,12 @@ func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) { if ctx.Arch().ArchType == android.Common { j.deps(ctx) } else { - // This dependency ensures the host installation rules will install the jni libraries - // when the wrapper is installed. - ctx.AddVariationDependencies(nil, jniLibTag, j.binaryProperties.Jni_libs...) + // These dependencies ensure the host installation rules will install the jar file and + // the jni libraries when the wrapper is installed. + ctx.AddVariationDependencies(nil, jniInstallTag, j.binaryProperties.Jni_libs...) + ctx.AddVariationDependencies( + []blueprint.Variation{{Mutator: "arch", Variation: android.CommonArch.String()}}, + binaryInstallTag, ctx.ModuleName()) } } @@ -2793,8 +2822,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { case libTag: flags.classpath = append(flags.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...) // names of sdk libs that are directly depended are exported - j.classLoaderContexts.AddContext(ctx, otherName, dep.IsSharedLibrary(), - dep.DexJarBuildPath(), dep.DexJarInstallPath()) + j.classLoaderContexts.AddContext(ctx, otherName, dep.DexJarBuildPath(), dep.DexJarInstallPath()) } } }) @@ -2809,7 +2837,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { // add the name of that java_sdk_library to the exported sdk libs to make sure // that, if necessary, a <uses-library> element for that java_sdk_library is // added to the Android manifest. - j.classLoaderContexts.MaybeAddContext(ctx, j.OptionalImplicitSdkLibrary(), true, + j.classLoaderContexts.MaybeAddContext(ctx, j.OptionalImplicitSdkLibrary(), outputFile, installFile) j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Aidl.Export_include_dirs) @@ -2896,8 +2924,8 @@ func (j *Import) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap { return j.classLoaderContexts } -func (j *Import) ExportedPlugins() (android.Paths, []string) { - return nil, nil +func (j *Import) ExportedPlugins() (android.Paths, []string, bool) { + return nil, nil, false } func (j *Import) SrcJarArgs() ([]string, android.Paths) { |
