Collect paths to transitive SDK Java library dependencies.
Previously only the names were collected, and later used in the manifest_fixer to add missing <uses-library> entries to the manifest. Now we also need to collect build-time and on-device paths, to be used in class loader context for dexpreopt. This commit only collects paths, but does not pass them to dexpreopt yet. Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: I34b229ee68f16ba215ba03770feadb4d890ec2bf
This commit is contained in:
@@ -17,6 +17,7 @@ package dexpreopt
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
@@ -100,6 +101,8 @@ type GlobalSoongConfig struct {
|
|||||||
ConstructContext android.Path
|
ConstructContext android.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const UnknownInstallLibraryPath = "error"
|
||||||
|
|
||||||
// LibraryPath contains paths to the library DEX jar on host and on device.
|
// LibraryPath contains paths to the library DEX jar on host and on device.
|
||||||
type LibraryPath struct {
|
type LibraryPath struct {
|
||||||
Host android.Path
|
Host android.Path
|
||||||
@@ -109,6 +112,46 @@ type LibraryPath struct {
|
|||||||
// LibraryPaths is a map from library name to on-host and on-device paths to its DEX jar.
|
// LibraryPaths is a map from library name to on-host and on-device paths to its DEX jar.
|
||||||
type LibraryPaths map[string]*LibraryPath
|
type LibraryPaths map[string]*LibraryPath
|
||||||
|
|
||||||
|
// Add a new path to the map of library paths, unless a path for this library already exists.
|
||||||
|
func (libPaths LibraryPaths) AddLibraryPath(ctx android.PathContext, lib *string, hostPath, installPath android.Path) {
|
||||||
|
if lib == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, present := libPaths[*lib]; !present {
|
||||||
|
var devicePath string
|
||||||
|
if installPath != nil {
|
||||||
|
devicePath = android.InstallPathToOnDevicePath(ctx, installPath.(android.InstallPath))
|
||||||
|
} else {
|
||||||
|
// For some stub libraries the only known thing is the name of their implementation
|
||||||
|
// library, but the library itself is unavailable (missing or part of a prebuilt). In
|
||||||
|
// such cases we still need to add the library to <uses-library> tags in the manifest,
|
||||||
|
// but we cannot use if for dexpreopt.
|
||||||
|
devicePath = UnknownInstallLibraryPath
|
||||||
|
}
|
||||||
|
libPaths[*lib] = &LibraryPath{hostPath, devicePath}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add library paths from the second map to the first map (do not override existing entries).
|
||||||
|
func (libPaths LibraryPaths) AddLibraryPaths(otherPaths LibraryPaths) {
|
||||||
|
for lib, path := range otherPaths {
|
||||||
|
if _, present := libPaths[lib]; !present {
|
||||||
|
libPaths[lib] = path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return sorted names of the libraries in the map.
|
||||||
|
func (libPaths LibraryPaths) Names() []string {
|
||||||
|
keys := make([]string, 0, len(libPaths))
|
||||||
|
for k := range libPaths {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
return keys
|
||||||
|
}
|
||||||
|
|
||||||
type ModuleConfig struct {
|
type ModuleConfig struct {
|
||||||
Name string
|
Name string
|
||||||
DexLocation string // dex location on device
|
DexLocation string // dex location on device
|
||||||
|
19
java/aar.go
19
java/aar.go
@@ -20,6 +20,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"android/soong/dexpreopt"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
@@ -99,7 +100,7 @@ type aapt struct {
|
|||||||
useEmbeddedNativeLibs bool
|
useEmbeddedNativeLibs bool
|
||||||
useEmbeddedDex bool
|
useEmbeddedDex bool
|
||||||
usesNonSdkApis bool
|
usesNonSdkApis bool
|
||||||
sdkLibraries []string
|
sdkLibraries dexpreopt.LibraryPaths
|
||||||
hasNoCode bool
|
hasNoCode bool
|
||||||
LoggingParent string
|
LoggingParent string
|
||||||
resourceFiles android.Paths
|
resourceFiles android.Paths
|
||||||
@@ -231,6 +232,8 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, ex
|
|||||||
transitiveStaticLibs, transitiveStaticLibManifests, staticRRODirs, assetPackages, libDeps, libFlags, sdkLibraries :=
|
transitiveStaticLibs, transitiveStaticLibManifests, staticRRODirs, assetPackages, libDeps, libFlags, sdkLibraries :=
|
||||||
aaptLibs(ctx, sdkContext)
|
aaptLibs(ctx, sdkContext)
|
||||||
|
|
||||||
|
a.sdkLibraries = sdkLibraries
|
||||||
|
|
||||||
// App manifest file
|
// App manifest file
|
||||||
manifestFile := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml")
|
manifestFile := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml")
|
||||||
manifestSrcPath := android.PathForModuleSrc(ctx, manifestFile)
|
manifestSrcPath := android.PathForModuleSrc(ctx, manifestFile)
|
||||||
@@ -357,7 +360,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, ex
|
|||||||
|
|
||||||
// aaptLibs collects libraries from dependencies and sdk_version and converts them into paths
|
// aaptLibs collects libraries from dependencies and sdk_version and converts them into paths
|
||||||
func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext) (transitiveStaticLibs, transitiveStaticLibManifests android.Paths,
|
func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext) (transitiveStaticLibs, transitiveStaticLibManifests android.Paths,
|
||||||
staticRRODirs []rroDir, assets, deps android.Paths, flags []string, sdkLibraries []string) {
|
staticRRODirs []rroDir, assets, deps android.Paths, flags []string, sdkLibraries dexpreopt.LibraryPaths) {
|
||||||
|
|
||||||
var sharedLibs android.Paths
|
var sharedLibs android.Paths
|
||||||
|
|
||||||
@@ -366,6 +369,8 @@ func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext) (transitiveStati
|
|||||||
sharedLibs = append(sharedLibs, sdkDep.jars...)
|
sharedLibs = append(sharedLibs, sdkDep.jars...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sdkLibraries = make(dexpreopt.LibraryPaths)
|
||||||
|
|
||||||
ctx.VisitDirectDeps(func(module android.Module) {
|
ctx.VisitDirectDeps(func(module android.Module) {
|
||||||
var exportPackage android.Path
|
var exportPackage android.Path
|
||||||
aarDep, _ := module.(AndroidLibraryDependency)
|
aarDep, _ := module.(AndroidLibraryDependency)
|
||||||
@@ -385,7 +390,8 @@ func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext) (transitiveStati
|
|||||||
// (including the java_sdk_library) itself then append any implicit sdk library
|
// (including the java_sdk_library) itself then append any implicit sdk library
|
||||||
// names to the list of sdk libraries to be added to the manifest.
|
// names to the list of sdk libraries to be added to the manifest.
|
||||||
if component, ok := module.(SdkLibraryComponentDependency); ok {
|
if component, ok := module.(SdkLibraryComponentDependency); ok {
|
||||||
sdkLibraries = append(sdkLibraries, component.OptionalImplicitSdkLibrary()...)
|
sdkLibraries.AddLibraryPath(ctx, component.OptionalImplicitSdkLibrary(),
|
||||||
|
component.DexJarBuildPath(), component.DexJarInstallPath())
|
||||||
}
|
}
|
||||||
|
|
||||||
case frameworkResTag:
|
case frameworkResTag:
|
||||||
@@ -397,7 +403,7 @@ func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext) (transitiveStati
|
|||||||
transitiveStaticLibs = append(transitiveStaticLibs, aarDep.ExportedStaticPackages()...)
|
transitiveStaticLibs = append(transitiveStaticLibs, aarDep.ExportedStaticPackages()...)
|
||||||
transitiveStaticLibs = append(transitiveStaticLibs, exportPackage)
|
transitiveStaticLibs = append(transitiveStaticLibs, exportPackage)
|
||||||
transitiveStaticLibManifests = append(transitiveStaticLibManifests, aarDep.ExportedManifests()...)
|
transitiveStaticLibManifests = append(transitiveStaticLibManifests, aarDep.ExportedManifests()...)
|
||||||
sdkLibraries = append(sdkLibraries, aarDep.ExportedSdkLibs()...)
|
sdkLibraries.AddLibraryPaths(aarDep.ExportedSdkLibs())
|
||||||
if aarDep.ExportedAssets().Valid() {
|
if aarDep.ExportedAssets().Valid() {
|
||||||
assets = append(assets, aarDep.ExportedAssets().Path())
|
assets = append(assets, aarDep.ExportedAssets().Path())
|
||||||
}
|
}
|
||||||
@@ -428,7 +434,6 @@ func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext) (transitiveStati
|
|||||||
|
|
||||||
transitiveStaticLibs = android.FirstUniquePaths(transitiveStaticLibs)
|
transitiveStaticLibs = android.FirstUniquePaths(transitiveStaticLibs)
|
||||||
transitiveStaticLibManifests = android.FirstUniquePaths(transitiveStaticLibManifests)
|
transitiveStaticLibManifests = android.FirstUniquePaths(transitiveStaticLibManifests)
|
||||||
sdkLibraries = android.FirstUniqueStrings(sdkLibraries)
|
|
||||||
|
|
||||||
return transitiveStaticLibs, transitiveStaticLibManifests, staticRRODirs, assets, deps, flags, sdkLibraries
|
return transitiveStaticLibs, transitiveStaticLibManifests, staticRRODirs, assets, deps, flags, sdkLibraries
|
||||||
}
|
}
|
||||||
@@ -465,8 +470,8 @@ func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
|
|
||||||
func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
a.aapt.isLibrary = true
|
a.aapt.isLibrary = true
|
||||||
a.aapt.sdkLibraries = a.exportedSdkLibs
|
|
||||||
a.aapt.buildActions(ctx, sdkContext(a))
|
a.aapt.buildActions(ctx, sdkContext(a))
|
||||||
|
a.exportedSdkLibs = a.aapt.sdkLibraries
|
||||||
|
|
||||||
ctx.CheckbuildFile(a.proguardOptionsFile)
|
ctx.CheckbuildFile(a.proguardOptionsFile)
|
||||||
ctx.CheckbuildFile(a.exportPackage)
|
ctx.CheckbuildFile(a.exportPackage)
|
||||||
@@ -749,7 +754,7 @@ func (a *AARImport) AidlIncludeDirs() android.Paths {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AARImport) ExportedSdkLibs() []string {
|
func (a *AARImport) ExportedSdkLibs() dexpreopt.LibraryPaths {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"android/soong/dexpreopt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var manifestFixerRule = pctx.AndroidStaticRule("manifestFixer",
|
var manifestFixerRule = pctx.AndroidStaticRule("manifestFixer",
|
||||||
@@ -52,7 +53,7 @@ var optionalUsesLibs = []string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Uses manifest_fixer.py to inject minSdkVersion, etc. into an AndroidManifest.xml
|
// Uses manifest_fixer.py to inject minSdkVersion, etc. into an AndroidManifest.xml
|
||||||
func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext sdkContext, sdkLibraries []string,
|
func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext sdkContext, sdkLibraries dexpreopt.LibraryPaths,
|
||||||
isLibrary, useEmbeddedNativeLibs, usesNonSdkApis, useEmbeddedDex, hasNoCode bool, loggingParent string) android.Path {
|
isLibrary, useEmbeddedNativeLibs, usesNonSdkApis, useEmbeddedDex, hasNoCode bool, loggingParent string) android.Path {
|
||||||
|
|
||||||
var args []string
|
var args []string
|
||||||
@@ -79,7 +80,7 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext
|
|||||||
args = append(args, "--use-embedded-dex")
|
args = append(args, "--use-embedded-dex")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, usesLib := range sdkLibraries {
|
for usesLib, _ := range sdkLibraries {
|
||||||
if inList(usesLib, optionalUsesLibs) {
|
if inList(usesLib, optionalUsesLibs) {
|
||||||
args = append(args, "--optional-uses-library", usesLib)
|
args = append(args, "--optional-uses-library", usesLib)
|
||||||
} else {
|
} else {
|
||||||
|
@@ -121,7 +121,7 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
|
|||||||
entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
|
entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...)
|
entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs.Names()...)
|
||||||
|
|
||||||
if len(library.additionalCheckedModules) != 0 {
|
if len(library.additionalCheckedModules) != 0 {
|
||||||
entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
|
entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
|
||||||
|
@@ -598,6 +598,7 @@ func (a *AndroidApp) dexBuildActions(ctx android.ModuleContext) android.Path {
|
|||||||
a.dexpreopter.optionalUsesLibs = a.usesLibrary.presentOptionalUsesLibs(ctx)
|
a.dexpreopter.optionalUsesLibs = a.usesLibrary.presentOptionalUsesLibs(ctx)
|
||||||
a.dexpreopter.libraryPaths = a.usesLibrary.usesLibraryPaths(ctx)
|
a.dexpreopter.libraryPaths = a.usesLibrary.usesLibraryPaths(ctx)
|
||||||
a.dexpreopter.manifestFile = a.mergedManifestFile
|
a.dexpreopter.manifestFile = a.mergedManifestFile
|
||||||
|
a.exportedSdkLibs = make(dexpreopt.LibraryPaths)
|
||||||
|
|
||||||
if ctx.ModuleName() != "framework-res" {
|
if ctx.ModuleName() != "framework-res" {
|
||||||
a.Module.compile(ctx, a.aaptSrcJar)
|
a.Module.compile(ctx, a.aaptSrcJar)
|
||||||
|
@@ -19,6 +19,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"android/soong/dexpreopt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeviceHostConverter struct {
|
type DeviceHostConverter struct {
|
||||||
@@ -162,7 +163,7 @@ func (d *DeviceHostConverter) AidlIncludeDirs() android.Paths {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DeviceHostConverter) ExportedSdkLibs() []string {
|
func (d *DeviceHostConverter) ExportedSdkLibs() dexpreopt.LibraryPaths {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
69
java/java.go
69
java/java.go
@@ -29,6 +29,7 @@ import (
|
|||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"android/soong/dexpreopt"
|
||||||
"android/soong/java/config"
|
"android/soong/java/config"
|
||||||
"android/soong/tradefed"
|
"android/soong/tradefed"
|
||||||
)
|
)
|
||||||
@@ -411,8 +412,8 @@ type Module struct {
|
|||||||
// manifest file to use instead of properties.Manifest
|
// manifest file to use instead of properties.Manifest
|
||||||
overrideManifest android.OptionalPath
|
overrideManifest android.OptionalPath
|
||||||
|
|
||||||
// list of SDK lib names that this java module is exporting
|
// map of SDK libs exported by this java module to their build and install paths
|
||||||
exportedSdkLibs []string
|
exportedSdkLibs dexpreopt.LibraryPaths
|
||||||
|
|
||||||
// list of plugins that this java module is exporting
|
// list of plugins that this java module is exporting
|
||||||
exportedPluginJars android.Paths
|
exportedPluginJars android.Paths
|
||||||
@@ -488,14 +489,19 @@ type ApexDependency interface {
|
|||||||
ImplementationAndResourcesJars() android.Paths
|
ImplementationAndResourcesJars() android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
type Dependency interface {
|
// Provides build path and install path to DEX jars.
|
||||||
ApexDependency
|
type UsesLibraryDependency interface {
|
||||||
ImplementationJars() android.Paths
|
|
||||||
ResourceJars() android.Paths
|
|
||||||
DexJarBuildPath() android.Path
|
DexJarBuildPath() android.Path
|
||||||
DexJarInstallPath() android.Path
|
DexJarInstallPath() android.Path
|
||||||
|
}
|
||||||
|
|
||||||
|
type Dependency interface {
|
||||||
|
ApexDependency
|
||||||
|
UsesLibraryDependency
|
||||||
|
ImplementationJars() android.Paths
|
||||||
|
ResourceJars() android.Paths
|
||||||
AidlIncludeDirs() android.Paths
|
AidlIncludeDirs() android.Paths
|
||||||
ExportedSdkLibs() []string
|
ExportedSdkLibs() dexpreopt.LibraryPaths
|
||||||
ExportedPlugins() (android.Paths, []string)
|
ExportedPlugins() (android.Paths, []string)
|
||||||
SrcJarArgs() ([]string, android.Paths)
|
SrcJarArgs() ([]string, android.Paths)
|
||||||
BaseModuleName() string
|
BaseModuleName() string
|
||||||
@@ -973,12 +979,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) {
|
ctx.VisitDirectDeps(func(module android.Module) {
|
||||||
otherName := ctx.OtherModuleName(module)
|
otherName := ctx.OtherModuleName(module)
|
||||||
tag := ctx.OtherModuleDependencyTag(module)
|
tag := ctx.OtherModuleDependencyTag(module)
|
||||||
@@ -998,7 +998,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
case libTag:
|
case libTag:
|
||||||
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
|
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
|
||||||
// names of sdk libs that are directly depended are exported
|
// 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:
|
case staticLibTag:
|
||||||
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
|
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
|
||||||
}
|
}
|
||||||
@@ -1009,7 +1009,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
case libTag, instrumentationForTag:
|
case libTag, instrumentationForTag:
|
||||||
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
||||||
// sdk lib names from dependencies are re-exported
|
// 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()...)
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
||||||
pluginJars, pluginClasses := dep.ExportedPlugins()
|
pluginJars, pluginClasses := dep.ExportedPlugins()
|
||||||
addPlugins(&deps, pluginJars, pluginClasses...)
|
addPlugins(&deps, pluginJars, pluginClasses...)
|
||||||
@@ -1021,7 +1021,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars()...)
|
deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars()...)
|
||||||
deps.staticResourceJars = append(deps.staticResourceJars, dep.ResourceJars()...)
|
deps.staticResourceJars = append(deps.staticResourceJars, dep.ResourceJars()...)
|
||||||
// sdk lib names from dependencies are re-exported
|
// 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()...)
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
||||||
pluginJars, pluginClasses := dep.ExportedPlugins()
|
pluginJars, pluginClasses := dep.ExportedPlugins()
|
||||||
addPlugins(&deps, pluginJars, pluginClasses...)
|
addPlugins(&deps, pluginJars, pluginClasses...)
|
||||||
@@ -1096,8 +1096,6 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
j.exportedSdkLibs = android.FirstUniqueStrings(j.exportedSdkLibs)
|
|
||||||
|
|
||||||
return deps
|
return deps
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1838,8 +1836,7 @@ func (j *Module) AidlIncludeDirs() android.Paths {
|
|||||||
return j.exportAidlIncludeDirs
|
return j.exportAidlIncludeDirs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) ExportedSdkLibs() []string {
|
func (j *Module) ExportedSdkLibs() dexpreopt.LibraryPaths {
|
||||||
// exportedSdkLibs is type []string
|
|
||||||
return j.exportedSdkLibs
|
return j.exportedSdkLibs
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1972,6 +1969,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
|
j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
|
||||||
}
|
}
|
||||||
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
|
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
|
||||||
|
j.exportedSdkLibs = make(dexpreopt.LibraryPaths)
|
||||||
j.compile(ctx, nil)
|
j.compile(ctx, nil)
|
||||||
|
|
||||||
// Collect the module directory for IDE info in java/jdeps.go.
|
// Collect the module directory for IDE info in java/jdeps.go.
|
||||||
@@ -1987,6 +1985,12 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
j.Stem()+".jar", j.outputFile, extraInstallDeps...)
|
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)
|
j.distFiles = j.GenerateTaggedDistFiles(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2537,7 +2541,7 @@ type Import struct {
|
|||||||
properties ImportProperties
|
properties ImportProperties
|
||||||
|
|
||||||
combinedClasspathFile android.Path
|
combinedClasspathFile android.Path
|
||||||
exportedSdkLibs []string
|
exportedSdkLibs dexpreopt.LibraryPaths
|
||||||
exportAidlIncludeDirs android.Paths
|
exportAidlIncludeDirs android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2590,12 +2594,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
TransformJetifier(ctx, outputFile, inputFile)
|
TransformJetifier(ctx, outputFile, inputFile)
|
||||||
}
|
}
|
||||||
j.combinedClasspathFile = outputFile
|
j.combinedClasspathFile = outputFile
|
||||||
|
j.exportedSdkLibs = make(dexpreopt.LibraryPaths)
|
||||||
// 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) {
|
ctx.VisitDirectDeps(func(module android.Module) {
|
||||||
otherName := ctx.OtherModuleName(module)
|
otherName := ctx.OtherModuleName(module)
|
||||||
@@ -2606,23 +2605,29 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
switch tag {
|
switch tag {
|
||||||
case libTag, staticLibTag:
|
case libTag, staticLibTag:
|
||||||
// sdk lib names from dependencies are re-exported
|
// sdk lib names from dependencies are re-exported
|
||||||
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
|
j.exportedSdkLibs.AddLibraryPaths(dep.ExportedSdkLibs())
|
||||||
}
|
}
|
||||||
case SdkLibraryDependency:
|
case SdkLibraryDependency:
|
||||||
switch tag {
|
switch tag {
|
||||||
case libTag:
|
case libTag:
|
||||||
// names of sdk libs that are directly depended are exported
|
// 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) {
|
if Bool(j.properties.Installable) {
|
||||||
ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
|
installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
|
||||||
jarName, outputFile)
|
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)
|
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Aidl.Export_include_dirs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2665,7 +2670,7 @@ func (j *Import) AidlIncludeDirs() android.Paths {
|
|||||||
return j.exportAidlIncludeDirs
|
return j.exportAidlIncludeDirs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Import) ExportedSdkLibs() []string {
|
func (j *Import) ExportedSdkLibs() dexpreopt.LibraryPaths {
|
||||||
return j.exportedSdkLibs
|
return j.exportedSdkLibs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,7 +20,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -1496,8 +1495,7 @@ func TestJavaSdkLibrary(t *testing.T) {
|
|||||||
// test if baz has exported SDK lib names foo and bar to qux
|
// test if baz has exported SDK lib names foo and bar to qux
|
||||||
qux := ctx.ModuleForTests("qux", "android_common")
|
qux := ctx.ModuleForTests("qux", "android_common")
|
||||||
if quxLib, ok := qux.Module().(*Library); ok {
|
if quxLib, ok := qux.Module().(*Library); ok {
|
||||||
sdkLibs := quxLib.ExportedSdkLibs()
|
sdkLibs := quxLib.ExportedSdkLibs().Names()
|
||||||
sort.Strings(sdkLibs)
|
|
||||||
if w := []string{"bar", "foo", "fred", "quuz"}; !reflect.DeepEqual(w, sdkLibs) {
|
if w := []string{"bar", "foo", "fred", "quuz"}; !reflect.DeepEqual(w, sdkLibs) {
|
||||||
t.Errorf("qux should export %q but exports %q", w, sdkLibs)
|
t.Errorf("qux should export %q but exports %q", w, sdkLibs)
|
||||||
}
|
}
|
||||||
|
@@ -849,22 +849,20 @@ func (e *EmbeddableSdkLibraryComponent) initSdkLibraryComponent(moduleBase *andr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// to satisfy SdkLibraryComponentDependency
|
// to satisfy SdkLibraryComponentDependency
|
||||||
func (e *EmbeddableSdkLibraryComponent) OptionalImplicitSdkLibrary() []string {
|
func (e *EmbeddableSdkLibraryComponent) OptionalImplicitSdkLibrary() *string {
|
||||||
if e.sdkLibraryComponentProperties.SdkLibraryToImplicitlyTrack != nil {
|
return e.sdkLibraryComponentProperties.SdkLibraryToImplicitlyTrack
|
||||||
return []string{*e.sdkLibraryComponentProperties.SdkLibraryToImplicitlyTrack}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implemented by modules that are (or possibly could be) a component of a java_sdk_library
|
// Implemented by modules that are (or possibly could be) a component of a java_sdk_library
|
||||||
// (including the java_sdk_library) itself.
|
// (including the java_sdk_library) itself.
|
||||||
type SdkLibraryComponentDependency interface {
|
type SdkLibraryComponentDependency interface {
|
||||||
|
UsesLibraryDependency
|
||||||
|
|
||||||
// The optional name of the sdk library that should be implicitly added to the
|
// The optional name of the sdk library that should be implicitly added to the
|
||||||
// AndroidManifest of an app that contains code which references the sdk library.
|
// AndroidManifest of an app that contains code which references the sdk library.
|
||||||
//
|
//
|
||||||
// Returns an array containing 0 or 1 items rather than a *string to make it easier
|
// Returns the name of the optional implicit SDK library or nil, if there isn't one.
|
||||||
// to append this to the list of exported sdk libraries.
|
OptionalImplicitSdkLibrary() *string
|
||||||
OptionalImplicitSdkLibrary() []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that all the module types that are components of java_sdk_library/_import
|
// Make sure that all the module types that are components of java_sdk_library/_import
|
||||||
@@ -878,6 +876,7 @@ var _ SdkLibraryComponentDependency = (*SdkLibraryImport)(nil)
|
|||||||
// Provides access to sdk_version related header and implentation jars.
|
// Provides access to sdk_version related header and implentation jars.
|
||||||
type SdkLibraryDependency interface {
|
type SdkLibraryDependency interface {
|
||||||
SdkLibraryComponentDependency
|
SdkLibraryComponentDependency
|
||||||
|
UsesLibraryDependency
|
||||||
|
|
||||||
// Get the header jars appropriate for the supplied sdk_version.
|
// Get the header jars appropriate for the supplied sdk_version.
|
||||||
//
|
//
|
||||||
@@ -1972,7 +1971,7 @@ func (module *SdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleCont
|
|||||||
return module.sdkJars(ctx, sdkVersion, false)
|
return module.sdkJars(ctx, sdkVersion, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// to satisfy apex.javaDependency interface
|
// to satisfy SdkLibraryDependency interface
|
||||||
func (module *SdkLibraryImport) DexJarBuildPath() android.Path {
|
func (module *SdkLibraryImport) DexJarBuildPath() android.Path {
|
||||||
if module.implLibraryModule == nil {
|
if module.implLibraryModule == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -1981,6 +1980,15 @@ func (module *SdkLibraryImport) DexJarBuildPath() android.Path {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// to satisfy SdkLibraryDependency interface
|
||||||
|
func (module *SdkLibraryImport) DexJarInstallPath() android.Path {
|
||||||
|
if module.implLibraryModule == nil {
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
return module.implLibraryModule.DexJarInstallPath()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// to satisfy apex.javaDependency interface
|
// to satisfy apex.javaDependency interface
|
||||||
func (module *SdkLibraryImport) JacocoReportClassesFile() android.Path {
|
func (module *SdkLibraryImport) JacocoReportClassesFile() android.Path {
|
||||||
if module.implLibraryModule == nil {
|
if module.implLibraryModule == nil {
|
||||||
|
Reference in New Issue
Block a user