Merge "Respect provides_uses_lib for modules added via [optional_]uses_libs" am: ae5cdfffa3 am: a9860b8a8f

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib5b3fe2b21b9b2186196e0b38a43cdf561f36a56
This commit is contained in:
Ulyana Trafimovich
2021-03-02 23:24:52 +00:00
committed by Automerger Merge Worker
2 changed files with 22 additions and 6 deletions

View File

@@ -1212,6 +1212,15 @@ func (u *usesLibrary) presentOptionalUsesLibs(ctx android.BaseModuleContext) []s
return optionalUsesLibs
}
// Helper function to replace string in a list.
func replaceInList(list []string, oldstr, newstr string) {
for i, str := range list {
if str == oldstr {
list[i] = newstr
}
}
}
// Returns a map of module names of shared library dependencies to the paths
// to their dex jars on host and on device.
func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext) dexpreopt.ClassLoaderContextMap {
@@ -1222,7 +1231,16 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext
if tag, ok := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag); ok {
dep := ctx.OtherModuleName(m)
if lib, ok := m.(UsesLibraryDependency); ok {
clcMap.AddContext(ctx, tag.sdkVersion, dep,
libName := dep
if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil {
libName = *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})