Merge "Collect paths to transitive SDK Java library dependencies." am: 9ce2221791 am: 9b67bbd11c

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1402668

Change-Id: Ib15bc0cb3fd0d53506eb36f895f04dfc8665df24
This commit is contained in:
Ulyana Trafimovich
2020-08-20 11:11:01 +00:00
committed by Automerger Merge Worker
9 changed files with 117 additions and 55 deletions

View File

@@ -29,6 +29,7 @@ import (
"github.com/google/blueprint/proptools"
"android/soong/android"
"android/soong/dexpreopt"
"android/soong/java/config"
"android/soong/tradefed"
)
@@ -415,8 +416,8 @@ type Module struct {
// manifest file to use instead of properties.Manifest
overrideManifest android.OptionalPath
// list of SDK lib names that this java module is exporting
exportedSdkLibs []string
// map of SDK libs exported by this java module to their build and install paths
exportedSdkLibs dexpreopt.LibraryPaths
// list of plugins that this java module is exporting
exportedPluginJars android.Paths
@@ -492,14 +493,19 @@ type ApexDependency interface {
ImplementationAndResourcesJars() android.Paths
}
type Dependency interface {
ApexDependency
ImplementationJars() android.Paths
ResourceJars() android.Paths
// Provides build path and install path to DEX jars.
type UsesLibraryDependency interface {
DexJarBuildPath() android.Path
DexJarInstallPath() android.Path
}
type Dependency interface {
ApexDependency
UsesLibraryDependency
ImplementationJars() android.Paths
ResourceJars() android.Paths
AidlIncludeDirs() android.Paths
ExportedSdkLibs() []string
ExportedSdkLibs() dexpreopt.LibraryPaths
ExportedPlugins() (android.Paths, []string)
SrcJarArgs() ([]string, android.Paths)
BaseModuleName() string
@@ -970,12 +976,6 @@ 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)
@@ -995,7 +995,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, dep.OptionalImplicitSdkLibrary()...)
j.exportedSdkLibs.AddLibraryPath(ctx, dep.OptionalImplicitSdkLibrary(), dep.DexJarBuildPath(), dep.DexJarInstallPath())
case staticLibTag:
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
}
@@ -1006,7 +1006,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
case libTag, instrumentationForTag:
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
// sdk lib names from dependencies are re-exported
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
j.exportedSdkLibs.AddLibraryPaths(dep.ExportedSdkLibs())
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
pluginJars, pluginClasses := dep.ExportedPlugins()
addPlugins(&deps, pluginJars, pluginClasses...)
@@ -1018,7 +1018,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars()...)
deps.staticResourceJars = append(deps.staticResourceJars, dep.ResourceJars()...)
// sdk lib names from dependencies are re-exported
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
j.exportedSdkLibs.AddLibraryPaths(dep.ExportedSdkLibs())
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
pluginJars, pluginClasses := dep.ExportedPlugins()
addPlugins(&deps, pluginJars, pluginClasses...)
@@ -1081,8 +1081,6 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
}
})
j.exportedSdkLibs = android.FirstUniqueStrings(j.exportedSdkLibs)
return deps
}
@@ -1823,8 +1821,7 @@ func (j *Module) AidlIncludeDirs() android.Paths {
return j.exportAidlIncludeDirs
}
func (j *Module) ExportedSdkLibs() []string {
// exportedSdkLibs is type []string
func (j *Module) ExportedSdkLibs() dexpreopt.LibraryPaths {
return j.exportedSdkLibs
}
@@ -1957,6 +1954,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
}
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
j.exportedSdkLibs = make(dexpreopt.LibraryPaths)
j.compile(ctx, nil)
// Collect the module directory for IDE info in java/jdeps.go.
@@ -1972,6 +1970,12 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.Stem()+".jar", j.outputFile, extraInstallDeps...)
}
// 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.AddLibraryPath(ctx, j.OptionalImplicitSdkLibrary(), j.DexJarBuildPath(), j.DexJarInstallPath())
j.distFiles = j.GenerateTaggedDistFiles(ctx)
}
@@ -2522,7 +2526,7 @@ type Import struct {
properties ImportProperties
combinedClasspathFile android.Path
exportedSdkLibs []string
exportedSdkLibs dexpreopt.LibraryPaths
exportAidlIncludeDirs android.Paths
}
@@ -2575,12 +2579,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
TransformJetifier(ctx, outputFile, inputFile)
}
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()...)
j.exportedSdkLibs = make(dexpreopt.LibraryPaths)
ctx.VisitDirectDeps(func(module android.Module) {
otherName := ctx.OtherModuleName(module)
@@ -2591,23 +2590,29 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
switch tag {
case libTag, staticLibTag:
// sdk lib names from dependencies are re-exported
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
j.exportedSdkLibs.AddLibraryPaths(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.AddLibraryPath(ctx, &otherName, dep.DexJarBuildPath(), dep.DexJarInstallPath())
}
}
})
j.exportedSdkLibs = android.FirstUniqueStrings(j.exportedSdkLibs)
var installFile android.Path
if Bool(j.properties.Installable) {
ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
jarName, 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.AddLibraryPath(ctx, j.OptionalImplicitSdkLibrary(), outputFile, installFile)
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Aidl.Export_include_dirs)
}
@@ -2650,7 +2655,7 @@ func (j *Import) AidlIncludeDirs() android.Paths {
return j.exportAidlIncludeDirs
}
func (j *Import) ExportedSdkLibs() []string {
func (j *Import) ExportedSdkLibs() dexpreopt.LibraryPaths {
return j.exportedSdkLibs
}