Merge "Convert override_apex.package_name with bp2build."
This commit is contained in:
23
apex/apex.go
23
apex/apex.go
@@ -2530,6 +2530,22 @@ func (o *OverrideApex) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|||||||
if overridableProperties.Compressible != nil {
|
if overridableProperties.Compressible != nil {
|
||||||
attrs.Compressible = bazel.BoolAttribute{Value: overridableProperties.Compressible}
|
attrs.Compressible = bazel.BoolAttribute{Value: overridableProperties.Compressible}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Package name
|
||||||
|
//
|
||||||
|
// e.g. com.android.adbd's package name is com.android.adbd, but
|
||||||
|
// com.google.android.adbd overrides the package name to com.google.android.adbd
|
||||||
|
//
|
||||||
|
// TODO: this can be overridden from the product configuration, see
|
||||||
|
// getOverrideManifestPackageName and
|
||||||
|
// PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES.
|
||||||
|
//
|
||||||
|
// Instead of generating the BUILD files differently based on the product config
|
||||||
|
// at the point of conversion, this should be handled by the BUILD file loading
|
||||||
|
// from the soong_injection's product_vars, so product config is decoupled from bp2build.
|
||||||
|
if overridableProperties.Package_name != "" {
|
||||||
|
attrs.Package_name = &overridableProperties.Package_name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: o.Name()}, &attrs)
|
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: o.Name()}, &attrs)
|
||||||
@@ -3471,6 +3487,7 @@ type bazelApexBundleAttributes struct {
|
|||||||
Native_shared_libs_32 bazel.LabelListAttribute
|
Native_shared_libs_32 bazel.LabelListAttribute
|
||||||
Native_shared_libs_64 bazel.LabelListAttribute
|
Native_shared_libs_64 bazel.LabelListAttribute
|
||||||
Compressible bazel.BoolAttribute
|
Compressible bazel.BoolAttribute
|
||||||
|
Package_name *string
|
||||||
}
|
}
|
||||||
|
|
||||||
type convertedNativeSharedLibs struct {
|
type convertedNativeSharedLibs struct {
|
||||||
@@ -3565,6 +3582,11 @@ func convertWithBp2build(a *apexBundle, ctx android.TopDownMutatorContext) (baze
|
|||||||
compressibleAttribute.Value = a.overridableProperties.Compressible
|
compressibleAttribute.Value = a.overridableProperties.Compressible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var packageName *string
|
||||||
|
if a.overridableProperties.Package_name != "" {
|
||||||
|
packageName = &a.overridableProperties.Package_name
|
||||||
|
}
|
||||||
|
|
||||||
attrs := bazelApexBundleAttributes{
|
attrs := bazelApexBundleAttributes{
|
||||||
Manifest: manifestLabelAttribute,
|
Manifest: manifestLabelAttribute,
|
||||||
Android_manifest: androidManifestLabelAttribute,
|
Android_manifest: androidManifestLabelAttribute,
|
||||||
@@ -3579,6 +3601,7 @@ func convertWithBp2build(a *apexBundle, ctx android.TopDownMutatorContext) (baze
|
|||||||
Binaries: binariesLabelListAttribute,
|
Binaries: binariesLabelListAttribute,
|
||||||
Prebuilts: prebuiltsLabelListAttribute,
|
Prebuilts: prebuiltsLabelListAttribute,
|
||||||
Compressible: compressibleAttribute,
|
Compressible: compressibleAttribute,
|
||||||
|
Package_name: packageName,
|
||||||
}
|
}
|
||||||
|
|
||||||
props := bazel.BazelTargetModuleProperties{
|
props := bazel.BazelTargetModuleProperties{
|
||||||
|
@@ -133,6 +133,7 @@ apex {
|
|||||||
"pretend_prebuilt_1",
|
"pretend_prebuilt_1",
|
||||||
"pretend_prebuilt_2",
|
"pretend_prebuilt_2",
|
||||||
],
|
],
|
||||||
|
package_name: "com.android.apogee.test.package",
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
expectedBazelTargets: []string{
|
expectedBazelTargets: []string{
|
||||||
@@ -169,6 +170,7 @@ apex {
|
|||||||
]`,
|
]`,
|
||||||
"updatable": "False",
|
"updatable": "False",
|
||||||
"compressible": "False",
|
"compressible": "False",
|
||||||
|
"package_name": `"com.android.apogee.test.package"`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
@@ -782,3 +784,37 @@ override_apex {
|
|||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApexBundleSimple_packageNameOverride(t *testing.T) {
|
||||||
|
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||||
|
description: "override_apex - override package name",
|
||||||
|
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: `
|
||||||
|
apex {
|
||||||
|
name: "com.android.apogee",
|
||||||
|
bazel_module: { bp2build_available: false },
|
||||||
|
}
|
||||||
|
|
||||||
|
override_apex {
|
||||||
|
name: "com.google.android.apogee",
|
||||||
|
base: ":com.android.apogee",
|
||||||
|
package_name: "com.google.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"`,
|
||||||
|
"package_name": `"com.google.android.apogee"`,
|
||||||
|
}),
|
||||||
|
}})
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user