Fix an override_module bug.
proptools.PrependProperties doesn't replace a pointer when both the src and the dst have one. This prevented override_module from overriding simple value pointer properties when the base module has existing values. It turns out this was why the name property needed to be overwritten manually. Bug: 122957760 Test: app_test.go Change-Id: I3302287c31a560422548c22fade95261ddbe606a
This commit is contained in:
parent
ac7f27eab0
commit
a641ee9cc7
2 changed files with 9 additions and 10 deletions
|
@ -134,10 +134,15 @@ func (b *OverridableModuleBase) setOverridesProperty(overridesProperty *[]string
|
|||
|
||||
// Overrides a base module with the given OverrideModule.
|
||||
func (b *OverridableModuleBase) override(ctx BaseModuleContext, o OverrideModule) {
|
||||
// Adds the base module to the overrides property, if exists, of the overriding module. See the
|
||||
// comment on OverridableModuleBase.overridesProperty for details.
|
||||
if b.overridesProperty != nil {
|
||||
*b.overridesProperty = append(*b.overridesProperty, b.Name())
|
||||
}
|
||||
for _, p := range b.overridableProperties {
|
||||
for _, op := range o.getOverridingProperties() {
|
||||
if proptools.TypeEqual(p, op) {
|
||||
err := proptools.PrependProperties(p, op, nil)
|
||||
err := proptools.AppendProperties(p, op, nil)
|
||||
if err != nil {
|
||||
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
|
||||
ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
|
||||
|
@ -148,13 +153,6 @@ func (b *OverridableModuleBase) override(ctx BaseModuleContext, o OverrideModule
|
|||
}
|
||||
}
|
||||
}
|
||||
// Adds the base module to the overrides property, if exists, of the overriding module. See the
|
||||
// comment on OverridableModuleBase.overridesProperty for details.
|
||||
if b.overridesProperty != nil {
|
||||
*b.overridesProperty = append(*b.overridesProperty, b.Name())
|
||||
}
|
||||
// The base module name property has to be updated separately for Name() to work as intended.
|
||||
b.module.base().nameProperties.Name = proptools.StringPtr(o.Name())
|
||||
}
|
||||
|
||||
// Mutators for override/overridable modules. All the fun happens in these functions. It is critical
|
||||
|
|
|
@ -877,6 +877,7 @@ func TestOverrideAndroidApp(t *testing.T) {
|
|||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
certificate: "expiredkey",
|
||||
overrides: ["baz"],
|
||||
}
|
||||
|
||||
|
@ -909,7 +910,7 @@ func TestOverrideAndroidApp(t *testing.T) {
|
|||
{
|
||||
variantName: "android_common",
|
||||
apkPath: "/target/product/test_device/system/app/foo/foo.apk",
|
||||
signFlag: "build/target/product/security/testkey.x509.pem build/target/product/security/testkey.pk8",
|
||||
signFlag: "build/target/product/security/expiredkey.x509.pem build/target/product/security/expiredkey.pk8",
|
||||
overrides: []string{"baz"},
|
||||
aaptFlag: "",
|
||||
},
|
||||
|
@ -923,7 +924,7 @@ func TestOverrideAndroidApp(t *testing.T) {
|
|||
{
|
||||
variantName: "baz_android_common",
|
||||
apkPath: "/target/product/test_device/system/app/baz/baz.apk",
|
||||
signFlag: "build/target/product/security/testkey.x509.pem build/target/product/security/testkey.pk8",
|
||||
signFlag: "build/target/product/security/expiredkey.x509.pem build/target/product/security/expiredkey.pk8",
|
||||
overrides: []string{"baz", "foo"},
|
||||
aaptFlag: "--rename-manifest-package org.dandroid.bp",
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue