Use Module.GetProperties() instead of ModuleBase.generalProperties

ModuleBase.generalProperties served the pupose of being a subset
of ModuleBase.customizableProperties. But now with the removal of
the latter, the former is simply a redirection to Module.GetProperties()

Bug: 206961391
Test: m nothing and diff the ninja files
Change-Id: I6dd8b7ba74eb5e7ffb61029b0f9129eec2ccfdaf
This commit is contained in:
Usta
2022-01-05 23:42:33 -05:00
committed by Usta Shrestha
parent e508f6a50b
commit 851a3271ce
10 changed files with 13 additions and 28 deletions

View File

@@ -993,8 +993,6 @@ func initArchModule(m Module) {
base := m.base() base := m.base()
// Store the original list of top level property structs
base.generalProperties = m.GetProperties()
if len(base.archProperties) != 0 { if len(base.archProperties) != 0 {
panic(fmt.Errorf("module %s already has archProperties", m.Name())) panic(fmt.Errorf("module %s already has archProperties", m.Name()))
} }
@@ -1015,7 +1013,7 @@ func initArchModule(m Module) {
return t return t
} }
for _, properties := range base.generalProperties { for _, properties := range m.GetProperties() {
t := getStructType(properties) t := getStructType(properties)
// Get or create the arch-specific property struct types for this property struct type. // Get or create the arch-specific property struct types for this property struct type.
archPropTypes := archPropTypeMap.Once(NewCustomOnceKey(t), func() interface{} { archPropTypes := archPropTypeMap.Once(NewCustomOnceKey(t), func() interface{} {
@@ -1036,7 +1034,6 @@ func initArchModule(m Module) {
m.AddProperties(archProperties...) m.AddProperties(archProperties...)
} }
base.generalProperties = m.GetProperties()
} }
func maybeBlueprintEmbed(src reflect.Value) reflect.Value { func maybeBlueprintEmbed(src reflect.Value) reflect.Value {
@@ -1110,7 +1107,7 @@ func (m *ModuleBase) setOSProperties(ctx BottomUpMutatorContext) {
os := m.commonProperties.CompileOS os := m.commonProperties.CompileOS
for i := range m.archProperties { for i := range m.archProperties {
genProps := m.generalProperties[i] genProps := m.GetProperties()[i]
if m.archProperties[i] == nil { if m.archProperties[i] == nil {
continue continue
} }
@@ -1438,7 +1435,7 @@ func (m *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
os := m.Os() os := m.Os()
for i := range m.archProperties { for i := range m.archProperties {
genProps := m.generalProperties[i] genProps := m.GetProperties()[i]
if m.archProperties[i] == nil { if m.archProperties[i] == nil {
continue continue
} }
@@ -2016,8 +2013,8 @@ func (m *ModuleBase) GetArchVariantProperties(ctx ArchVariantContext, propertySe
var archProperties []interface{} var archProperties []interface{}
// First find the property set in the module that corresponds to the requested // First find the property set in the module that corresponds to the requested
// one. m.archProperties[i] corresponds to m.generalProperties[i]. // one. m.archProperties[i] corresponds to m.GetProperties()[i].
for i, generalProp := range m.generalProperties { for i, generalProp := range m.GetProperties() {
srcType := reflect.ValueOf(generalProp).Type() srcType := reflect.ValueOf(generalProp).Type()
if srcType == dstType { if srcType == dstType {
archProperties = m.archProperties[i] archProperties = m.archProperties[i]

View File

@@ -96,8 +96,6 @@ func InitDefaultableModule(module DefaultableModule) {
module.setProperties(module.GetProperties(), module.base().variableProperties) module.setProperties(module.GetProperties(), module.base().variableProperties)
module.AddProperties(module.defaults()) module.AddProperties(module.defaults())
module.base().generalProperties = module.GetProperties()
} }
// A restricted subset of context methods, similar to LoadHookContext. // A restricted subset of context methods, similar to LoadHookContext.

View File

@@ -68,7 +68,7 @@ func (l *loadHookContext) moduleFactories() map[string]blueprint.ModuleFactory {
func (l *loadHookContext) appendPrependHelper(props []interface{}, func (l *loadHookContext) appendPrependHelper(props []interface{},
extendFn func([]interface{}, interface{}, proptools.ExtendPropertyFilterFunc) error) { extendFn func([]interface{}, interface{}, proptools.ExtendPropertyFilterFunc) error) {
for _, p := range props { for _, p := range props {
err := extendFn(l.Module().base().generalProperties, p, nil) err := extendFn(l.Module().base().GetProperties(), p, nil)
if err != nil { if err != nil {
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok { if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
l.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error()) l.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())

View File

@@ -80,8 +80,6 @@ func LicenseFactory() Module {
base := module.base() base := module.base()
module.AddProperties(&base.nameProperties, &module.properties) module.AddProperties(&base.nameProperties, &module.properties)
base.generalProperties = module.GetProperties()
// The visibility property needs to be checked and parsed by the visibility module. // The visibility property needs to be checked and parsed by the visibility module.
setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility) setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)

View File

@@ -53,8 +53,6 @@ func LicenseKindFactory() Module {
base := module.base() base := module.base()
module.AddProperties(&base.nameProperties, &module.properties) module.AddProperties(&base.nameProperties, &module.properties)
base.generalProperties = module.GetProperties()
// The visibility property needs to be checked and parsed by the visibility module. // The visibility property needs to be checked and parsed by the visibility module.
setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility) setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)

View File

@@ -779,8 +779,6 @@ func newMockLicensesBadModule() Module {
base := m.base() base := m.base()
m.AddProperties(&base.nameProperties, &m.properties) m.AddProperties(&base.nameProperties, &m.properties)
base.generalProperties = m.GetProperties()
// The default_visibility property needs to be checked and parsed by the visibility module during // The default_visibility property needs to be checked and parsed by the visibility module during
// its checking and parsing phases so make it the primary visibility property. // its checking and parsing phases so make it the primary visibility property.
setPrimaryVisibilityProperty(m, "visibility", &m.properties.Visibility) setPrimaryVisibilityProperty(m, "visibility", &m.properties.Visibility)

View File

@@ -1032,8 +1032,6 @@ func InitAndroidModule(m Module) {
initProductVariableModule(m) initProductVariableModule(m)
base.generalProperties = m.GetProperties()
// The default_visibility property needs to be checked and parsed by the visibility module during // The default_visibility property needs to be checked and parsed by the visibility module during
// its checking and parsing phases so make it the primary visibility property. // its checking and parsing phases so make it the primary visibility property.
setPrimaryVisibilityProperty(m, "visibility", &base.commonProperties.Visibility) setPrimaryVisibilityProperty(m, "visibility", &base.commonProperties.Visibility)
@@ -1207,13 +1205,12 @@ type ModuleBase struct {
distProperties distProperties distProperties distProperties
variableProperties interface{} variableProperties interface{}
hostAndDeviceProperties hostAndDeviceProperties hostAndDeviceProperties hostAndDeviceProperties
generalProperties []interface{}
// Arch specific versions of structs in generalProperties. The outer index // Arch specific versions of structs in GetProperties() prior to
// has the same order as generalProperties as initialized in // initialization in InitAndroidArchModule, lets call it `generalProperties`.
// InitAndroidArchModule, and the inner index chooses the props specific to // The outer index has the same order as generalProperties and the inner index
// the architecture. The interface{} value is an archPropRoot that is // chooses the props specific to the architecture. The interface{} value is an
// filled with arch specific values by the arch mutator. // archPropRoot that is filled with arch specific values by the arch mutator.
archProperties [][]interface{} archProperties [][]interface{}
// Properties specific to the Blueprint to BUILD migration. // Properties specific to the Blueprint to BUILD migration.

View File

@@ -33,7 +33,7 @@ func registerPathDepsMutator(ctx RegisterMutatorsContext) {
// The pathDepsMutator automatically adds dependencies on any module that is listed with the // The pathDepsMutator automatically adds dependencies on any module that is listed with the
// ":module" module reference syntax in a property that is tagged with `android:"path"`. // ":module" module reference syntax in a property that is tagged with `android:"path"`.
func pathDepsMutator(ctx BottomUpMutatorContext) { func pathDepsMutator(ctx BottomUpMutatorContext) {
props := ctx.Module().base().generalProperties props := ctx.Module().base().GetProperties()
addPathDepsForProps(ctx, props) addPathDepsForProps(ctx, props)
} }

View File

@@ -183,7 +183,6 @@ type PrebuiltSrcsSupplier func(ctx BaseModuleContext, prebuilt Module) []string
func initPrebuiltModuleCommon(module PrebuiltInterface) *Prebuilt { func initPrebuiltModuleCommon(module PrebuiltInterface) *Prebuilt {
p := module.Prebuilt() p := module.Prebuilt()
module.AddProperties(&p.properties) module.AddProperties(&p.properties)
module.base().generalProperties = module.GetProperties()
return p return p
} }

View File

@@ -1029,7 +1029,7 @@ func (m *ModuleBase) setVariableProperties(ctx BottomUpMutatorContext,
printfIntoProperties(ctx, prefix, productVariablePropertyValue, variableValue) printfIntoProperties(ctx, prefix, productVariablePropertyValue, variableValue)
err := proptools.AppendMatchingProperties(m.generalProperties, err := proptools.AppendMatchingProperties(m.GetProperties(),
productVariablePropertyValue.Addr().Interface(), nil) productVariablePropertyValue.Addr().Interface(), nil)
if err != nil { if err != nil {
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok { if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {