summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go
index 969b0637e..8179df8c0 100644
--- a/java/java.go
+++ b/java/java.go
@@ -281,6 +281,9 @@ type Module struct {
// list of extra progurad flag files
extraProguardFlagFiles android.Paths
+
+ // list of SDK lib names that this java moudule is exporting
+ exportedSdkLibs []string
}
func (j *Module) Srcs() android.Paths {
@@ -293,6 +296,7 @@ type Dependency interface {
HeaderJars() android.Paths
ImplementationJars() android.Paths
AidlIncludeDirs() android.Paths
+ ExportedSdkLibs() []string
}
type SdkLibraryDependency interface {
@@ -714,10 +718,14 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
deps.bootClasspath = append(deps.bootClasspath, dep.HeaderJars()...)
case libTag:
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
+ // sdk lib names from dependencies are re-exported
+ j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
case staticLibTag:
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
deps.staticJars = append(deps.staticJars, dep.ImplementationJars()...)
deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars()...)
+ // sdk lib names from dependencies are re-exported
+ j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
case frameworkResTag:
if ctx.ModuleName() == "framework" {
// framework.jar has a one-off dependency on the R.java and Manifest.java files
@@ -748,6 +756,8 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
switch tag {
case libTag:
deps.classpath = append(deps.classpath, dep.HeaderJars(getLinkType(j, ctx.ModuleName()))...)
+ // names of sdk libs that are directly depended are exported
+ j.exportedSdkLibs = append(j.exportedSdkLibs, otherName)
default:
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
}
@@ -785,6 +795,8 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
}
})
+ j.exportedSdkLibs = android.FirstUniqueStrings(j.exportedSdkLibs)
+
return deps
}
@@ -1197,6 +1209,10 @@ func (j *Module) AidlIncludeDirs() android.Paths {
return j.exportAidlIncludeDirs
}
+func (j *Module) ExportedSdkLibs() []string {
+ return j.exportedSdkLibs
+}
+
var _ logtagsProducer = (*Module)(nil)
func (j *Module) logtags() android.Paths {
@@ -1398,6 +1414,9 @@ type ImportProperties struct {
Sdk_version *string
Installable *bool
+
+ // List of shared java libs that this module has dependencies to
+ Libs []string
}
type Import struct {
@@ -1408,6 +1427,7 @@ type Import struct {
classpathFiles android.Paths
combinedClasspathFile android.Path
+ exportedSdkLibs []string
}
func (j *Import) Prebuilt() *android.Prebuilt {
@@ -1423,6 +1443,7 @@ func (j *Import) Name() string {
}
func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
+ ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
}
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -1431,6 +1452,28 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
outputFile := android.PathForModuleOut(ctx, "classes.jar")
TransformJarsToJar(ctx, outputFile, "for prebuilts", j.classpathFiles, android.OptionalPath{}, false, nil)
j.combinedClasspathFile = outputFile
+
+ ctx.VisitDirectDeps(func(module android.Module) {
+ otherName := ctx.OtherModuleName(module)
+ tag := ctx.OtherModuleDependencyTag(module)
+
+ switch dep := module.(type) {
+ case Dependency:
+ switch tag {
+ case libTag, staticLibTag:
+ // sdk lib names from dependencies are re-exported
+ j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
+ }
+ case SdkLibraryDependency:
+ switch tag {
+ case libTag:
+ // names of sdk libs that are directly depended are exported
+ j.exportedSdkLibs = append(j.exportedSdkLibs, otherName)
+ }
+ }
+ })
+
+ j.exportedSdkLibs = android.FirstUniqueStrings(j.exportedSdkLibs)
}
var _ Dependency = (*Import)(nil)
@@ -1447,6 +1490,10 @@ func (j *Import) AidlIncludeDirs() android.Paths {
return nil
}
+func (j *Import) ExportedSdkLibs() []string {
+ return j.exportedSdkLibs
+}
+
var _ android.PrebuiltInterface = (*Import)(nil)
func ImportFactory() android.Module {