diff --git a/android/override_module.go b/android/override_module.go index 45f7be070..5bc787b54 100644 --- a/android/override_module.go +++ b/android/override_module.go @@ -155,11 +155,6 @@ 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, ctx.ModuleName()) - } for _, p := range b.overridableProperties { for _, op := range o.getOverridingProperties() { if proptools.TypeEqual(p, op) { @@ -174,6 +169,11 @@ 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, ctx.ModuleName()) + } b.properties.OverriddenBy = o.Name() } diff --git a/apex/androidmk.go b/apex/androidmk.go index a231a907c..1b02bcbca 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -182,7 +182,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.ToMakePath().String()) fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix()) fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable()) - fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(a.properties.Overrides, " ")) + fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(a.overridableProperties.Overrides, " ")) if len(moduleNames) > 0 { fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(moduleNames, " ")) } diff --git a/apex/apex.go b/apex/apex.go index 488d3d32f..8340aac73 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -333,13 +333,6 @@ type apexBundleProperties struct { // also built with the SDKs specified here. Uses_sdks []string - // Names of modules to be overridden. Listed modules can only be other binaries - // (in Make or Soong). - // This does not completely prevent installation of the overridden binaries, but if both - // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed - // from PRODUCT_PACKAGES. - Overrides []string - // Whenever apex_payload.img of the APEX should include dm-verity hashtree. // Should be only used in tests#. Test_only_no_hashtree *bool @@ -376,6 +369,13 @@ type apexTargetBundleProperties struct { type overridableProperties struct { // List of APKs to package inside APEX Apps []string + + // Names of modules to be overridden. Listed modules can only be other binaries + // (in Make or Soong). + // This does not completely prevent installation of the overridden binaries, but if both + // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed + // from PRODUCT_PACKAGES. + Overrides []string } type apexPackaging int @@ -1240,7 +1240,7 @@ func newApexBundle() *apexBundle { android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) android.InitDefaultableModule(module) android.InitSdkAwareModule(module) - android.InitOverridableModule(module, &module.properties.Overrides) + android.InitOverridableModule(module, &module.overridableProperties.Overrides) return module } diff --git a/apex/apex_test.go b/apex/apex_test.go index 0c6572bbf..7ac830858 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -3027,12 +3027,14 @@ func TestOverrideApex(t *testing.T) { name: "myapex", key: "myapex.key", apps: ["app"], + overrides: ["oldapex"], } override_apex { name: "override_myapex", base: "myapex", apps: ["override_app"], + overrides: ["unknownapex"], } apex_key { @@ -3085,6 +3087,7 @@ func TestOverrideApex(t *testing.T) { ensureContains(t, androidMk, "LOCAL_MODULE := override_app.override_myapex") ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.override_myapex") ensureContains(t, androidMk, "LOCAL_MODULE_STEM := override_myapex.apex") + ensureContains(t, androidMk, "LOCAL_OVERRIDES_MODULES := unknownapex myapex") ensureNotContains(t, androidMk, "LOCAL_MODULE := app.myapex") ensureNotContains(t, androidMk, "LOCAL_MODULE := override_app.myapex") ensureNotContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.myapex")