Only override prebuilts property if the override_apex.prebuilts is

explicitly specified (not nil).

This allows the base apex's prebuilts to be surfaced to the override
apex target.

Discovered when com.google.android.adbd's prebuilts didn't contain its
init.rc module.

Bug: 222588072
Test: CI
Change-Id: I925e98d53f7d9208652c629799ab568521ba7dfe
This commit is contained in:
Jingwen Chen
2022-06-08 16:00:39 +00:00
parent fdc0540751
commit df165c9e85
2 changed files with 130 additions and 2 deletions

View File

@@ -2523,8 +2523,10 @@ func (o *OverrideApex) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
}
// Prebuilts
prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, overridableProperties.Prebuilts)
attrs.Prebuilts = bazel.MakeLabelListAttribute(prebuiltsLabelList)
if overridableProperties.Prebuilts != nil {
prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, overridableProperties.Prebuilts)
attrs.Prebuilts = bazel.MakeLabelListAttribute(prebuiltsLabelList)
}
// Compressible
if overridableProperties.Compressible != nil {

View File

@@ -18,6 +18,7 @@ import (
"android/soong/android"
"android/soong/apex"
"android/soong/cc"
"android/soong/etc"
"android/soong/java"
"android/soong/sh"
@@ -57,6 +58,7 @@ func registerOverrideApexModuleTypes(ctx android.RegistrationContext) {
ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("apex", apex.BundleFactory)
ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory)
}
func TestApexBundleSimple(t *testing.T) {
@@ -818,3 +820,127 @@ override_apex {
}),
}})
}
func TestApexBundleSimple_NoPrebuiltsOverride(t *testing.T) {
runOverrideApexTestCase(t, bp2buildTestCase{
description: "override_apex - no override",
moduleTypeUnderTest: "override_apex",
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
bazel_module: { bp2build_available: false },
}`,
},
blueprint: `
prebuilt_etc {
name: "prebuilt_file",
bazel_module: { bp2build_available: false },
}
apex {
name: "com.android.apogee",
bazel_module: { bp2build_available: false },
prebuilts: ["prebuilt_file"]
}
override_apex {
name: "com.google.android.apogee",
base: ":com.android.apogee",
}
`,
expectedBazelTargets: []string{
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
"manifest": `"apex_manifest.json"`,
"prebuilts": `[":prebuilt_file"]`,
}),
}})
}
func TestApexBundleSimple_PrebuiltsOverride(t *testing.T) {
runOverrideApexTestCase(t, bp2buildTestCase{
description: "override_apex - ooverride",
moduleTypeUnderTest: "override_apex",
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
bazel_module: { bp2build_available: false },
}`,
},
blueprint: `
prebuilt_etc {
name: "prebuilt_file",
bazel_module: { bp2build_available: false },
}
prebuilt_etc {
name: "prebuilt_file2",
bazel_module: { bp2build_available: false },
}
apex {
name: "com.android.apogee",
bazel_module: { bp2build_available: false },
prebuilts: ["prebuilt_file"]
}
override_apex {
name: "com.google.android.apogee",
base: ":com.android.apogee",
prebuilts: ["prebuilt_file2"]
}
`,
expectedBazelTargets: []string{
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
"manifest": `"apex_manifest.json"`,
"prebuilts": `[":prebuilt_file2"]`,
}),
}})
}
func TestApexBundleSimple_PrebuiltsOverrideEmptyList(t *testing.T) {
runOverrideApexTestCase(t, bp2buildTestCase{
description: "override_apex - override with empty list",
moduleTypeUnderTest: "override_apex",
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
bazel_module: { bp2build_available: false },
}`,
},
blueprint: `
prebuilt_etc {
name: "prebuilt_file",
bazel_module: { bp2build_available: false },
}
apex {
name: "com.android.apogee",
bazel_module: { bp2build_available: false },
prebuilts: ["prebuilt_file"]
}
override_apex {
name: "com.google.android.apogee",
base: ":com.android.apogee",
prebuilts: [],
}
`,
expectedBazelTargets: []string{
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
"manifest": `"apex_manifest.json"`,
"prebuilts": `[]`,
}),
}})
}