summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
authorUlya Trafimovich <skvadrik@google.com>2020-09-23 16:42:35 +0100
committerUlya Trafimovich <skvadrik@google.com>2020-10-06 14:04:49 +0100
commit39b437b25f0c8cf9f32ab6adedd83336df48d1d8 (patch)
tree4df225923733afa47ea903c4735898159b3f2d8d /java/java.go
parent1a1b885319d79b4372f61b5174acbcee3a3191ea (diff)
Add dependency on implementation <uses-library> for modules that depend on component libraries.
If a dexpreopted Java module depends on a component library (such as stubs), it must be dexpreopted against the implementation library, because that is what it will use at run time. Therefore dexpreopt needs to know about the implementation library. One of the subtests of TestUsesLibraries is removed. This is because the subtest was previosuly split in two variants with the only difference that the first variant had dependency on a stubs library, and the second one had dependency on the implementation. The latter caused dexpreopt to be disabled because Soong couldn't find the implementation (it had only the name, but no access to the module). Now that there is a dependency on the implementation, the problem goes away and the two subtest variants can be merged into one. Add a method for getting the name of the implementation library for the optional SDK library. Currently it is the same as the SDK library name, but it may change in future. Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: I584df4b6db874c7ae3c478231fc51572a46929b1
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/java/java.go b/java/java.go
index d67e9e098..44fbd7a08 100644
--- a/java/java.go
+++ b/java/java.go
@@ -735,9 +735,21 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
return ret
}
- ctx.AddVariationDependencies(nil, libTag, rewriteSyspropLibs(j.properties.Libs, "libs")...)
+ libDeps := ctx.AddVariationDependencies(nil, libTag, rewriteSyspropLibs(j.properties.Libs, "libs")...)
ctx.AddVariationDependencies(nil, staticLibTag, rewriteSyspropLibs(j.properties.Static_libs, "static_libs")...)
+ // For library dependencies that are component libraries (like stubs), add the implementation
+ // as a dependency (dexpreopt needs to be against the implementation library, not stubs).
+ for _, dep := range libDeps {
+ if dep != nil {
+ if component, ok := dep.(SdkLibraryComponentDependency); ok {
+ if lib := component.OptionalSdkLibraryImplementation(); lib != nil {
+ ctx.AddVariationDependencies(nil, usesLibTag, *lib)
+ }
+ }
+ }
+ }
+
ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), pluginTag, j.properties.Plugins...)
ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), exportedPluginTag, j.properties.Exported_plugins...)