Merge "Refactor function to reduce nestedness level. No functional changes."
This commit is contained in:
60
java/app.go
60
java/app.go
@@ -1245,37 +1245,43 @@ func replaceInList(list []string, oldstr, newstr string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a map of module names of shared library dependencies to the paths
|
// Returns a map of module names of shared library dependencies to the paths to their dex jars on
|
||||||
// to their dex jars on host and on device.
|
// host and on device.
|
||||||
func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext) dexpreopt.ClassLoaderContextMap {
|
func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext) dexpreopt.ClassLoaderContextMap {
|
||||||
clcMap := make(dexpreopt.ClassLoaderContextMap)
|
clcMap := make(dexpreopt.ClassLoaderContextMap)
|
||||||
// Skip when UnbundledBuild() is true, but UnbundledBuildImage() is false.
|
|
||||||
// Added UnbundledBuildImage() condition to generate dexpreopt.config even though unbundled image is built.
|
// Skip when UnbundledBuild() is true, but UnbundledBuildImage() is false. With
|
||||||
if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() {
|
// UnbundledBuildImage() it is necessary to generate dexpreopt.config for post-dexpreopting.
|
||||||
ctx.VisitDirectDeps(func(m android.Module) {
|
if ctx.Config().UnbundledBuild() && !ctx.Config().UnbundledBuildImage() {
|
||||||
if tag, ok := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag); ok {
|
return clcMap
|
||||||
dep := ctx.OtherModuleName(m)
|
|
||||||
if lib, ok := m.(UsesLibraryDependency); ok {
|
|
||||||
libName := android.RemoveOptionalPrebuiltPrefix(dep)
|
|
||||||
if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil {
|
|
||||||
libName = android.RemoveOptionalPrebuiltPrefix(*ulib.ProvidesUsesLib())
|
|
||||||
// Replace module name with library name in `uses_libs`/`optional_uses_libs`
|
|
||||||
// in order to pass verify_uses_libraries check (which compares these
|
|
||||||
// properties against library names written in the manifest).
|
|
||||||
replaceInList(u.usesLibraryProperties.Uses_libs, dep, libName)
|
|
||||||
replaceInList(u.usesLibraryProperties.Optional_uses_libs, dep, libName)
|
|
||||||
}
|
|
||||||
clcMap.AddContext(ctx, tag.sdkVersion, libName,
|
|
||||||
lib.DexJarBuildPath(), lib.DexJarInstallPath(), lib.ClassLoaderContexts())
|
|
||||||
} else if ctx.Config().AllowMissingDependencies() {
|
|
||||||
ctx.AddMissingDependencies([]string{dep})
|
|
||||||
} else {
|
|
||||||
ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be a java library", dep)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.VisitDirectDeps(func(m android.Module) {
|
||||||
|
tag, isUsesLibTag := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag)
|
||||||
|
if !isUsesLibTag {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
dep := ctx.OtherModuleName(m)
|
||||||
|
|
||||||
|
if lib, ok := m.(UsesLibraryDependency); ok {
|
||||||
|
libName := android.RemoveOptionalPrebuiltPrefix(dep)
|
||||||
|
if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil {
|
||||||
|
libName = android.RemoveOptionalPrebuiltPrefix(*ulib.ProvidesUsesLib())
|
||||||
|
// Replace module name with library name in `uses_libs`/`optional_uses_libs` in
|
||||||
|
// order to pass verify_uses_libraries check (which compares these properties
|
||||||
|
// against library names written in the manifest).
|
||||||
|
replaceInList(u.usesLibraryProperties.Uses_libs, dep, libName)
|
||||||
|
replaceInList(u.usesLibraryProperties.Optional_uses_libs, dep, libName)
|
||||||
|
}
|
||||||
|
clcMap.AddContext(ctx, tag.sdkVersion, libName,
|
||||||
|
lib.DexJarBuildPath(), lib.DexJarInstallPath(), lib.ClassLoaderContexts())
|
||||||
|
} else if ctx.Config().AllowMissingDependencies() {
|
||||||
|
ctx.AddMissingDependencies([]string{dep})
|
||||||
|
} else {
|
||||||
|
ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be a java library", dep)
|
||||||
|
}
|
||||||
|
})
|
||||||
return clcMap
|
return clcMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user