From 2f68f1903aece97cc98e43723bcb98382ca3aaf6 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Mon, 22 Jul 2024 19:25:50 +0000 Subject: [PATCH] Drop module sdk MakeUninstallable special case Platform variants of module sdk libraries were marked as uninstallable originally in https://r.android.com/1974259. This special case is no longer necesssary - android.MutateApexTransition will call MakeUninstallable on the platform variant on both the source and prebuilt soong modules when the following conditions are met - //apex_available:platform is not listed in apex_available (explicitly or via the default implicit) - the soong module is included in an apex that exists in the tree (listed in native_shared_libs) Since MakeUninstallable is set by apex specific mutators, the relevant unit test has been moved to the apex package. The Android.bp of the test has also been extended with an apex that includes the shared library. Test: m nothing --no-skip-soong-tests Test: no diff in out/soong/Android-$product.mk Test: added prebuilt_libdexfile to art's apex_contributions locally, no diff in out/soong/Android-$product.mk Bug: 220898484 Change-Id: I43a324882d486451bb921028853508d7ec3d76bf --- apex/apex_test.go | 118 ++++++++++++++++++++++++++++++++++++++++++++ cc/prebuilt.go | 11 ----- cc/prebuilt_test.go | 106 --------------------------------------- 3 files changed, 118 insertions(+), 117 deletions(-) diff --git a/apex/apex_test.go b/apex/apex_test.go index a2dbbfc35..f62ee680b 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -11738,3 +11738,121 @@ func TestUpdatableApexMinSdkVersionCurrent(t *testing.T) { } `) } + +func TestPrebuiltStubNoinstall(t *testing.T) { + testFunc := func(t *testing.T, expectLibfooOnSystemLib bool, fs android.MockFS) { + result := android.GroupFixturePreparers( + prepareForApexTest, + android.PrepareForTestWithAndroidMk, + android.PrepareForTestWithMakevars, + android.FixtureMergeMockFs(fs), + ).RunTest(t) + + ldRule := result.ModuleForTests("installedlib", "android_arm64_armv8-a_shared").Rule("ld") + android.AssertStringDoesContain(t, "", ldRule.Args["libFlags"], "android_arm64_armv8-a_shared/libfoo.so") + + installRules := result.InstallMakeRulesForTesting(t) + + var installedlibRule *android.InstallMakeRule + for i, rule := range installRules { + if rule.Target == "out/target/product/test_device/system/lib/installedlib.so" { + if installedlibRule != nil { + t.Errorf("Duplicate install rules for %s", rule.Target) + } + installedlibRule = &installRules[i] + } + } + if installedlibRule == nil { + t.Errorf("No install rule found for installedlib") + return + } + + if expectLibfooOnSystemLib { + android.AssertStringListContains(t, + "installedlib doesn't have install dependency on libfoo impl", + installedlibRule.OrderOnlyDeps, + "out/target/product/test_device/system/lib/libfoo.so") + } else { + android.AssertStringListDoesNotContain(t, + "installedlib has install dependency on libfoo stub", + installedlibRule.Deps, + "out/target/product/test_device/system/lib/libfoo.so") + android.AssertStringListDoesNotContain(t, + "installedlib has order-only install dependency on libfoo stub", + installedlibRule.OrderOnlyDeps, + "out/target/product/test_device/system/lib/libfoo.so") + } + } + + prebuiltLibfooBp := []byte(` + cc_prebuilt_library { + name: "libfoo", + prefer: true, + srcs: ["libfoo.so"], + stubs: { + versions: ["1"], + }, + apex_available: ["apexfoo"], + } + `) + + apexfooBp := []byte(` + apex { + name: "apexfoo", + key: "apexfoo.key", + native_shared_libs: ["libfoo"], + updatable: false, + compile_multilib: "both", + } + apex_key { + name: "apexfoo.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + `) + + installedlibBp := []byte(` + cc_library { + name: "installedlib", + shared_libs: ["libfoo"], + } + `) + + t.Run("prebuilt stub (without source): no install", func(t *testing.T) { + testFunc( + t, + /*expectLibfooOnSystemLib=*/ false, + android.MockFS{ + "prebuilts/module_sdk/art/current/Android.bp": prebuiltLibfooBp, + "apexfoo/Android.bp": apexfooBp, + "system/sepolicy/apex/apexfoo-file_contexts": nil, + "Android.bp": installedlibBp, + }, + ) + }) + + disabledSourceLibfooBp := []byte(` + cc_library { + name: "libfoo", + enabled: false, + stubs: { + versions: ["1"], + }, + apex_available: ["apexfoo"], + } + `) + + t.Run("prebuilt stub (with disabled source): no install", func(t *testing.T) { + testFunc( + t, + /*expectLibfooOnSystemLib=*/ false, + android.MockFS{ + "prebuilts/module_sdk/art/current/Android.bp": prebuiltLibfooBp, + "impl/Android.bp": disabledSourceLibfooBp, + "apexfoo/Android.bp": apexfooBp, + "system/sepolicy/apex/apexfoo-file_contexts": nil, + "Android.bp": installedlibBp, + }, + ) + }) +} diff --git a/cc/prebuilt.go b/cc/prebuilt.go index e9f790f73..e023a324c 100644 --- a/cc/prebuilt.go +++ b/cc/prebuilt.go @@ -205,17 +205,6 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext, TableOfContents: p.tocFile, }) - // TODO(b/220898484): Mainline module sdk prebuilts of stub libraries use a stub - // library as their source and must not be installed, but other prebuilts like - // libclang_rt.* libraries set `stubs` property because they are LLNDK libraries, - // but use an implementation library as their source and need to be installed. - // This discrepancy should be resolved without the prefix hack below. - isModuleSdkPrebuilts := android.HasAnyPrefix(ctx.ModuleDir(), []string{ - "prebuilts/runtime/mainline/", "prebuilts/module_sdk/"}) - if p.hasStubsVariants() && !p.buildStubs() && !ctx.Host() && isModuleSdkPrebuilts { - ctx.Module().MakeUninstallable() - } - return outputFile } } diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go index 71b7e4369..86e6af96a 100644 --- a/cc/prebuilt_test.go +++ b/cc/prebuilt_test.go @@ -385,112 +385,6 @@ func TestPrebuiltLibrarySanitized(t *testing.T) { assertString(t, static2.OutputFile().Path().Base(), "libf.hwasan.a") } -func TestPrebuiltStubNoinstall(t *testing.T) { - testFunc := func(t *testing.T, expectLibfooOnSystemLib bool, fs android.MockFS) { - result := android.GroupFixturePreparers( - prepareForPrebuiltTest, - android.PrepareForTestWithMakevars, - android.FixtureMergeMockFs(fs), - ).RunTest(t) - - ldRule := result.ModuleForTests("installedlib", "android_arm64_armv8-a_shared").Rule("ld") - android.AssertStringDoesContain(t, "", ldRule.Args["libFlags"], "android_arm64_armv8-a_shared/libfoo.so") - - installRules := result.InstallMakeRulesForTesting(t) - var installedlibRule *android.InstallMakeRule - for i, rule := range installRules { - if rule.Target == "out/target/product/test_device/system/lib/installedlib.so" { - if installedlibRule != nil { - t.Errorf("Duplicate install rules for %s", rule.Target) - } - installedlibRule = &installRules[i] - } - } - if installedlibRule == nil { - t.Errorf("No install rule found for installedlib") - return - } - - if expectLibfooOnSystemLib { - android.AssertStringListContains(t, - "installedlib doesn't have install dependency on libfoo impl", - installedlibRule.OrderOnlyDeps, - "out/target/product/test_device/system/lib/libfoo.so") - } else { - android.AssertStringListDoesNotContain(t, - "installedlib has install dependency on libfoo stub", - installedlibRule.Deps, - "out/target/product/test_device/system/lib/libfoo.so") - android.AssertStringListDoesNotContain(t, - "installedlib has order-only install dependency on libfoo stub", - installedlibRule.OrderOnlyDeps, - "out/target/product/test_device/system/lib/libfoo.so") - } - } - - prebuiltLibfooBp := []byte(` - cc_prebuilt_library { - name: "libfoo", - prefer: true, - srcs: ["libfoo.so"], - stubs: { - versions: ["1"], - }, - } - `) - - installedlibBp := []byte(` - cc_library { - name: "installedlib", - shared_libs: ["libfoo"], - } - `) - - t.Run("prebuilt stub (without source): no install", func(t *testing.T) { - testFunc( - t, - /*expectLibfooOnSystemLib=*/ false, - android.MockFS{ - "prebuilts/module_sdk/art/current/Android.bp": prebuiltLibfooBp, - "Android.bp": installedlibBp, - }, - ) - }) - - disabledSourceLibfooBp := []byte(` - cc_library { - name: "libfoo", - enabled: false, - stubs: { - versions: ["1"], - }, - } - `) - - t.Run("prebuilt stub (with disabled source): no install", func(t *testing.T) { - testFunc( - t, - /*expectLibfooOnSystemLib=*/ false, - android.MockFS{ - "prebuilts/module_sdk/art/current/Android.bp": prebuiltLibfooBp, - "impl/Android.bp": disabledSourceLibfooBp, - "Android.bp": installedlibBp, - }, - ) - }) - - t.Run("prebuilt impl (with `stubs` property set): install", func(t *testing.T) { - testFunc( - t, - /*expectLibfooOnSystemLib=*/ true, - android.MockFS{ - "impl/Android.bp": prebuiltLibfooBp, - "Android.bp": installedlibBp, - }, - ) - }) -} - func TestPrebuiltBinaryNoSrcsNoError(t *testing.T) { const bp = ` cc_prebuilt_binary {