summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2020-05-26 08:42:03 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-05-26 08:42:03 +0000
commit2eb4ace0efd4512db99e54c04e563750cabb408f (patch)
treedc59e649772b5d1c507a6772370be4f702b0e660 /java/java.go
parent88ef9fb76e466947d03171aafd4ed748dce62c88 (diff)
parentd11e78e641dfbe235d9edbd11f4ed26189ffd74d (diff)
Merge changes from topic "disable_shared_library" into rvc-dev
* changes: Retry: "java_sdk_library: Control shared library use" Retry: "Improve tracking of exported sdk libraries"
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go33
1 files changed, 27 insertions, 6 deletions
diff --git a/java/java.go b/java/java.go
index da9bd3dfe..00b11f77a 100644
--- a/java/java.go
+++ b/java/java.go
@@ -355,7 +355,17 @@ func (me *CompilerDeviceProperties) EffectiveOptimizeEnabled() bool {
}
// Functionality common to Module and Import
+//
+// It is embedded in Module so its functionality can be used by methods in Module
+// but it is currently only initialized by Import and Library.
type embeddableInModuleAndImport struct {
+
+ // Functionality related to this being used as a component of a java_sdk_library.
+ EmbeddableSdkLibraryComponent
+}
+
+func (e *embeddableInModuleAndImport) initModuleAndImport(moduleBase *android.ModuleBase) {
+ e.initSdkLibraryComponent(moduleBase)
}
// Module/Import's DepIsInSameApex(...) delegates to this method.
@@ -496,11 +506,6 @@ type Dependency interface {
JacocoReportClassesFile() android.Path
}
-type SdkLibraryDependency interface {
- SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths
- SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths
-}
-
type xref interface {
XrefJavaFiles() android.Paths
}
@@ -930,6 +935,12 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
}
}
+ // If this is a component library (stubs, etc.) for a java_sdk_library then
+ // 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.exportedSdkLibs = append(j.exportedSdkLibs, j.OptionalImplicitSdkLibrary()...)
+
ctx.VisitDirectDeps(func(module android.Module) {
otherName := ctx.OtherModuleName(module)
tag := ctx.OtherModuleDependencyTag(module)
@@ -949,7 +960,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.exportedSdkLibs = append(j.exportedSdkLibs, otherName)
+ j.exportedSdkLibs = append(j.exportedSdkLibs, dep.OptionalImplicitSdkLibrary()...)
case staticLibTag:
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
}
@@ -1990,6 +2001,8 @@ func LibraryFactory() android.Module {
&module.Module.protoProperties,
&module.libraryProperties)
+ module.initModuleAndImport(&module.ModuleBase)
+
android.InitApexModule(module)
android.InitSdkAwareModule(module)
InitJavaModule(module, android.HostAndDeviceSupported)
@@ -2451,6 +2464,12 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
j.combinedClasspathFile = outputFile
+ // If this is a component library (impl, stubs, etc.) for a java_sdk_library then
+ // 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.exportedSdkLibs = append(j.exportedSdkLibs, j.OptionalImplicitSdkLibrary()...)
+
ctx.VisitDirectDeps(func(module android.Module) {
otherName := ctx.OtherModuleName(module)
tag := ctx.OtherModuleDependencyTag(module)
@@ -2567,6 +2586,8 @@ func ImportFactory() android.Module {
module.AddProperties(&module.properties)
+ module.initModuleAndImport(&module.ModuleBase)
+
android.InitPrebuiltModule(module, &module.properties.Jars)
android.InitApexModule(module)
android.InitSdkAwareModule(module)