From 39b437b25f0c8cf9f32ab6adedd83336df48d1d8 Mon Sep 17 00:00:00 2001 From: Ulya Trafimovich Date: Wed, 23 Sep 2020 16:42:35 +0100 Subject: Add dependency on implementation 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 --- java/app_test.go | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'java/app_test.go') diff --git a/java/app_test.go b/java/app_test.go index 536797119..78b1467e2 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -2757,19 +2757,6 @@ func TestUsesLibraries(t *testing.T) { android_app { name: "app", srcs: ["a.java"], - libs: ["qux", "quuz"], - static_libs: ["static-runtime-helper"], - uses_libs: ["foo"], - sdk_version: "current", - optional_uses_libs: [ - "bar", - "baz", - ], - } - - android_app { - name: "app_with_stub_deps", - srcs: ["a.java"], libs: ["qux", "quuz.stubs"], static_libs: ["static-runtime-helper"], uses_libs: ["foo"], @@ -2800,7 +2787,6 @@ func TestUsesLibraries(t *testing.T) { run(t, ctx, config) app := ctx.ModuleForTests("app", "android_common") - appWithStubDeps := ctx.ModuleForTests("app_with_stub_deps", "android_common") prebuilt := ctx.ModuleForTests("prebuilt", "android_common") // Test that implicit dependencies on java_sdk_library instances are passed to the manifest. @@ -2831,7 +2817,7 @@ func TestUsesLibraries(t *testing.T) { t.Errorf("wanted %q in %q", w, cmd) } - // Test that all present libraries are preopted, including implicit SDK dependencies + // Test that all present libraries are preopted, including implicit SDK dependencies, possibly stubs cmd = app.Rule("dexpreopt").RuleParams.Command w := `--target-classpath-for-sdk any` + ` /system/framework/foo.jar` + @@ -2843,11 +2829,6 @@ func TestUsesLibraries(t *testing.T) { t.Errorf("wanted %q in %q", w, cmd) } - // TODO(skvadrik) fix dexpreopt for stub libraries for which the implementation is present - if appWithStubDeps.MaybeRule("dexpreopt").RuleParams.Command != "" { - t.Errorf("dexpreopt should be disabled for apps with dependencies on stub libraries") - } - cmd = prebuilt.Rule("dexpreopt").RuleParams.Command if w := `--target-classpath-for-sdk any /system/framework/foo.jar:/system/framework/bar.jar`; !strings.Contains(cmd, w) { t.Errorf("wanted %q in %q", w, cmd) -- cgit v1.2.3-59-g8ed1b