diff options
author | 2021-02-26 11:38:21 +0000 | |
---|---|---|
committer | 2021-03-01 17:31:23 +0000 | |
commit | eea486a58033a4d444363ec07ccf35645abaad0c (patch) | |
tree | 1f21a6b11421d969a8f68cd013e9b4e238a043e2 /java/app.go | |
parent | 861a896c965ddc11f7b913379e5c97d6dde37901 (diff) |
Respect `provides_uses_lib` for modules added via `[optional_]uses_libs`
Previously `provides_uses_lib` property affected only those
<uses-library> dependencies that are automatically deduced by Soong as
implicit Java SDK libraries reachable from the `libs` property. Other
<uses-library> dependencies that are explicitly added in `uses_libs` and
`optional_uses_libs` properties ignored `provides_uses_lib`.
As TestUsesLibraries shows (see the TODOs), Soong behaviour is still
incorrect in two ways (to be addressed in follow-up CLs):
- `uses_libs`/`optional_uses_libs` are passed to manifest_fixer
- verify_uses_libraries check is based on `uses_libs`/
`optional_uses_libs`, and not on the CLC as it should be
Bug: 132357300
Test: m nothing
Change-Id: I0ec7aab9dcd44554d1a79ddd382491c562266fa3
Diffstat (limited to 'java/app.go')
-rwxr-xr-x | java/app.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/java/app.go b/java/app.go index 8287533e0..e81b25d73 100755 --- a/java/app.go +++ b/java/app.go @@ -1217,6 +1217,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 { @@ -1227,7 +1236,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}) |