Minor refactoring of Append/PrependProperties() methods

Test: `m nothing` and compare ninja file
Bug: n/a

Change-Id: If6e4a0de0a8f4f479fe3cbe044cf50d07648c8d9
This commit is contained in:
Usta
2021-11-23 12:31:55 -05:00
parent b5f81d2a6a
commit ef3676c94b
3 changed files with 16 additions and 29 deletions

View File

@@ -529,10 +529,10 @@ func (t *topDownMutatorContext) CreateBazelTargetModule(
mod.base().addBp2buildInfo(info)
}
func (t *topDownMutatorContext) AppendProperties(props ...interface{}) {
func (t *topDownMutatorContext) appendPrependHelper(props []interface{},
extendFn func([]interface{}, interface{}, proptools.ExtendPropertyFilterFunc) error) {
for _, p := range props {
err := proptools.AppendMatchingProperties(t.Module().base().customizableProperties,
p, nil)
err := extendFn(t.Module().base().customizableProperties, p, nil)
if err != nil {
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
t.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
@@ -543,18 +543,12 @@ func (t *topDownMutatorContext) AppendProperties(props ...interface{}) {
}
}
func (t *topDownMutatorContext) AppendProperties(props ...interface{}) {
t.appendPrependHelper(props, proptools.AppendMatchingProperties)
}
func (t *topDownMutatorContext) PrependProperties(props ...interface{}) {
for _, p := range props {
err := proptools.PrependMatchingProperties(t.Module().base().customizableProperties,
p, nil)
if err != nil {
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
t.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
} else {
panic(err)
}
}
}
t.appendPrependHelper(props, proptools.PrependMatchingProperties)
}
// android.topDownMutatorContext either has to embed blueprint.TopDownMutatorContext, in which case every method that