From 1679192d7d1a71633823d92bd7480e2f553e556b Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 6 Sep 2024 00:49:31 +0000 Subject: [PATCH 1/2] Skip `contents` validation of source bootclasspath fragments ... if prebuilts are selected. This is a special case of b/361771739 where a apex starts contributing a jar to the BCP. `disableSourceApexVariant` uses `PrebuiltSelectionInfoProvider` and this gets populated via the following dep chain ``` source --> prebuilt --> all_apex_contributions ``` This runs into issues if a prebuilt bootclasspath_fragment does not exist. This CL creates a dependency edge between the source module and all_apex_contributions singleton module so that `PrebuiltSelectionInfoProvider` is available for `disableSourceApexVariant` Bug: 361771739 Test: lunch cf_x86_64-next-userdebug Test: m nothing with ag/28851886 Change-Id: I92d88199a27579d3c9879d40fd354653370efcce --- apex/bootclasspath_fragment_test.go | 4 ++++ java/bootclasspath_fragment.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go index 25131eec6..fd2f3c5d1 100644 --- a/apex/bootclasspath_fragment_test.go +++ b/apex/bootclasspath_fragment_test.go @@ -833,6 +833,7 @@ func TestBootclasspathFragment_HiddenAPIList(t *testing.T) { `) java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{ + "all_apex_contributions", "art-bootclasspath-fragment", "bar", "dex2oatd", @@ -1003,6 +1004,7 @@ func TestBootclasspathFragment_AndroidNonUpdatable_FromSource(t *testing.T) { `) java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{ + "all_apex_contributions", "android-non-updatable.stubs", "android-non-updatable.stubs.module_lib", "android-non-updatable.stubs.system", @@ -1174,6 +1176,7 @@ func TestBootclasspathFragment_AndroidNonUpdatable_FromText(t *testing.T) { `) java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{ + "all_apex_contributions", "android-non-updatable.stubs", "android-non-updatable.stubs.system", "android-non-updatable.stubs.test", @@ -1326,6 +1329,7 @@ func TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks(t *test `) java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{ + "all_apex_contributions", "art-bootclasspath-fragment", "bar", "dex2oatd", diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index bef3b58c8..fe4cc7685 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -463,6 +463,12 @@ func (b *BootclasspathFragmentModule) DepsMutator(ctx android.BottomUpMutatorCon // Add a dependency onto the dex2oat tool which is needed for creating the boot image. The // path is retrieved from the dependency by GetGlobalSoongConfig(ctx). dexpreopt.RegisterToolDeps(ctx) + + // Add a dependency to `all_apex_contributions` to determine if prebuilts are active. + // If prebuilts are active, `contents` validation on the source bootclasspath fragment should be disabled. + if _, isPrebuiltModule := ctx.Module().(*PrebuiltBootclasspathFragmentModule); !isPrebuiltModule { + ctx.AddDependency(b, android.AcDepTag, "all_apex_contributions") + } } func (b *BootclasspathFragmentModule) BootclasspathDepsMutator(ctx android.BottomUpMutatorContext) { From 003452ff9c3b0dfe57be563d647c9a8dd76e0569 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 6 Sep 2024 00:56:25 +0000 Subject: [PATCH 2/2] Disable source apex variant using apex_available_name There are two versions of aosp extservices - one for Tplus and one for Sminus. When prebuilts are active, the `contents` validation of both variants of extservices bootclasspath fragments should be disabled to account for BCP jar skew. This CL adds ApexAvailableName to ApexInfo to achive that. If an api_domain matching the ApexAvailableName has been selected in `all_apex_contributions`, the source apex variants will be disabled. Bug: 361771739 Test: lunch cf_x86_64_phone-next-userdebug Test: m nothing with ag/28851886 Change-Id: I505a7ad8295c258e2eeef7f183669f7a75a1c88e --- android/apex.go | 3 +++ apex/apex.go | 1 + java/dexpreopt.go | 11 ++++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/android/apex.go b/android/apex.go index 79ee0a8f8..22cdb2a61 100644 --- a/android/apex.go +++ b/android/apex.go @@ -87,6 +87,9 @@ type ApexInfo struct { // Returns the name of the overridden apex (com.android.foo) BaseApexName string + + // Returns the value of `apex_available_name` + ApexAvailableName string } // AllApexInfo holds the ApexInfo of all apexes that include this module. diff --git a/apex/apex.go b/apex/apex.go index d5776b5de..4dd605544 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1073,6 +1073,7 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) { ApexContents: []*android.ApexContents{apexContents}, TestApexes: testApexes, BaseApexName: mctx.ModuleName(), + ApexAvailableName: proptools.String(a.properties.Apex_available_name), } mctx.WalkDeps(func(child, parent android.Module) bool { if !continueApexDepsWalk(child, parent) { diff --git a/java/dexpreopt.go b/java/dexpreopt.go index f949b123a..b55ef7310 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -209,13 +209,18 @@ func disableSourceApexVariant(ctx android.BaseModuleContext) bool { psi = prebuiltSelectionInfo } }) + // Find the apex variant for this module - var apexVariantsWithoutTestApexes []string + apexVariantsWithoutTestApexes := []string{} if apexInfo.BaseApexName != "" { // This is a transitive dependency of an override_apex - apexVariantsWithoutTestApexes = []string{apexInfo.BaseApexName} + apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, apexInfo.BaseApexName) } else { - _, apexVariantsWithoutTestApexes, _ = android.ListSetDifference(apexInfo.InApexVariants, apexInfo.TestApexes) + _, variants, _ := android.ListSetDifference(apexInfo.InApexVariants, apexInfo.TestApexes) + apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, variants...) + } + if apexInfo.ApexAvailableName != "" { + apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, apexInfo.ApexAvailableName) } disableSource := false // find the selected apexes