Do not rename prebuilt apexes for product packaging

https://r.android.com/2901309 added support for handling installation
rules for multiple prebuilts. One of the implementation details there
was to change LOCAL_MODULE name to the source apex name in the generated
.mk files.

This causes issues in partner builds where the google singed apex
com.google.android.foo gets renamed to com.android.foo in
out/soong/Android-$PRODUCT.mk. If the partner builds does not include
the aosp apex in its PRODUCT_PACAKGES, then the google signed apex gets
elided from packaging.

This CL undoes that change. After this CL, the name of the module as it
appears in Android.bp will match the LOCAL_MODULE name emitted for
product packaging.

Test: in build/soong, go test ./apex
Bug: 355682304
(cherry picked from https://android-review.googlesource.com/q/commit:a8e2d6173d0d83ead3e481124311ab59deced404)
Merged-In: Icadbb75609174cff5326f52baf7d53e901f9f1c0
Change-Id: Icadbb75609174cff5326f52baf7d53e901f9f1c0
This commit is contained in:
Spandan Das 2024-07-26 19:24:27 +00:00 committed by Android Build Coastguard Worker
parent af2b96ca93
commit d53fcc06ce
2 changed files with 2 additions and 15 deletions

View file

@ -5244,7 +5244,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
myApex := ctx.ModuleForTests("myapex", "android_common_myapex").Module()
overrideNames := []string{
"myapex",
"",
"myjavalib.myapex",
"libfoo.myapex",
"libbar.myapex",
@ -11286,13 +11286,6 @@ func TestBootDexJarsMultipleApexPrebuilts(t *testing.T) {
// Test that product packaging installs the selected mainline module (either source or a specific prebuilt)
// RELEASE_APEX_CONTIRBUTIONS_* build flags will be used to select the correct prebuilt for a specific release config
func TestInstallationRulesForMultipleApexPrebuilts(t *testing.T) {
// check that the LOCAL_MODULE in the generated mk file matches the name used in PRODUCT_PACKAGES
// Since the name used in PRODUCT_PACKAGES does not contain prebuilt_ prefix, LOCAL_MODULE should not contain any prefix either
checkLocalModuleName := func(t *testing.T, ctx *android.TestContext, soongApexModuleName string, expectedLocalModuleName string) {
// Variations are created based on apex_name
entries := android.AndroidMkEntriesForTest(t, ctx, ctx.ModuleForTests(soongApexModuleName, "android_common_com.android.foo").Module())
android.AssertStringEquals(t, "LOCAL_MODULE of the prebuilt apex must match the name listed in PRODUCT_PACKAGES", expectedLocalModuleName, entries[0].EntryMap["LOCAL_MODULE"][0])
}
// for a mainline module family, check that only the flagged soong module is visible to make
checkHideFromMake := func(t *testing.T, ctx *android.TestContext, visibleModuleName string, hiddenModuleNames []string) {
variation := func(moduleName string) string {
@ -11347,7 +11340,7 @@ func TestInstallationRulesForMultipleApexPrebuilts(t *testing.T) {
prebuilt_apex {
name: "com.google.android.foo.v2",
apex_name: "com.android.foo",
source_apex_name: "com.google.android.foo", // source_apex_name becomes LOCAL_MODULE in the generated mk file
source_apex_name: "com.google.android.foo",
src: "com.android.foo-arm.apex",
prefer: true, // prefer is set to true on both the prebuilts to induce an error if flagging is not present
}
@ -11433,11 +11426,6 @@ func TestInstallationRulesForMultipleApexPrebuilts(t *testing.T) {
}
ctx := testApex(t, bp, preparer)
// Check that the LOCAL_MODULE of the two prebuilts is com.android.foo
// This ensures that product packaging can pick them for installation if it has been flagged by apex_contributions
checkLocalModuleName(t, ctx, "prebuilt_com.google.android.foo", "com.google.android.foo")
checkLocalModuleName(t, ctx, "prebuilt_com.google.android.foo.v2", "com.google.android.foo")
// Check that
// 1. The contents of the selected apex_contributions are visible to make
// 2. The rest of the apexes in the mainline module family (source or other prebuilt) is hidden from make

View file

@ -246,7 +246,6 @@ func (p *prebuiltCommon) AndroidMkEntries() []android.AndroidMkEntries {
OutputFile: android.OptionalPathForPath(p.outputApex),
Include: "$(BUILD_PREBUILT)",
Host_required: p.hostRequired,
OverrideName: p.BaseModuleName(),
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.SetString("LOCAL_MODULE_PATH", p.installDir.String())