Merge changes Ib9a08167,I925e98d5
* changes: Use prebuilt_etc for prebuilt modules in bp2build test, instead of pretending with a cc_library. Only override prebuilts property if the override_apex.prebuilts is explicitly specified (not nil).
This commit is contained in:
commit
1f0b70e7c0
2 changed files with 145 additions and 16 deletions
|
@ -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 {
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"android/soong/android"
|
||||
"android/soong/apex"
|
||||
"android/soong/cc"
|
||||
"android/soong/etc"
|
||||
"android/soong/java"
|
||||
"android/soong/sh"
|
||||
|
||||
|
@ -39,6 +40,7 @@ func registerApexModuleTypes(ctx android.RegistrationContext) {
|
|||
ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory)
|
||||
ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory)
|
||||
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
||||
ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory)
|
||||
}
|
||||
|
||||
func runOverrideApexTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
|
@ -57,6 +59,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) {
|
||||
|
@ -89,13 +92,13 @@ cc_library {
|
|||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "pretend_prebuilt_1",
|
||||
prebuilt_etc {
|
||||
name: "prebuilt_1",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "pretend_prebuilt_2",
|
||||
prebuilt_etc {
|
||||
name: "prebuilt_2",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
|
@ -130,8 +133,8 @@ apex {
|
|||
"sh_binary_2",
|
||||
],
|
||||
prebuilts: [
|
||||
"pretend_prebuilt_1",
|
||||
"pretend_prebuilt_2",
|
||||
"prebuilt_1",
|
||||
"prebuilt_2",
|
||||
],
|
||||
package_name: "com.android.apogee.test.package",
|
||||
}
|
||||
|
@ -165,8 +168,8 @@ apex {
|
|||
"//conditions:default": [],
|
||||
})`,
|
||||
"prebuilts": `[
|
||||
":pretend_prebuilt_1",
|
||||
":pretend_prebuilt_2",
|
||||
":prebuilt_1",
|
||||
":prebuilt_2",
|
||||
]`,
|
||||
"updatable": "False",
|
||||
"compressible": "False",
|
||||
|
@ -549,13 +552,13 @@ cc_library {
|
|||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "pretend_prebuilt_1",
|
||||
prebuilt_etc {
|
||||
name: "prebuilt_1",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "pretend_prebuilt_2",
|
||||
prebuilt_etc {
|
||||
name: "prebuilt_2",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
|
@ -590,8 +593,8 @@ apex {
|
|||
"sh_binary_2",
|
||||
],
|
||||
prebuilts: [
|
||||
"pretend_prebuilt_1",
|
||||
"pretend_prebuilt_2",
|
||||
"prebuilt_1",
|
||||
"prebuilt_2",
|
||||
],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
@ -818,3 +821,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": `[]`,
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue