Make required a configurable property
So that users can use select statements with it.
Fixes: 347605145
Bug: 342006386
Test: m nothing --no-skip-soong-tests
Change-Id: Ica0ca6d1725b000b3748c0293e5a9f9b38ed87f9
diff --git a/android/androidmk.go b/android/androidmk.go
index 66f42f9..9699ce5 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -499,6 +499,7 @@
Config() Config
moduleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool)
ModuleType(module blueprint.Module) string
+ OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{})
}
func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint.Module) {
@@ -514,7 +515,7 @@
if a.Include == "" {
a.Include = "$(BUILD_PREBUILT)"
}
- a.Required = append(a.Required, amod.RequiredModuleNames()...)
+ a.Required = append(a.Required, amod.RequiredModuleNames(ctx)...)
a.Host_required = append(a.Host_required, amod.HostRequiredModuleNames()...)
a.Target_required = append(a.Target_required, amod.TargetRequiredModuleNames()...)
diff --git a/android/module.go b/android/module.go
index dc585d2..d629aa5 100644
--- a/android/module.go
+++ b/android/module.go
@@ -113,7 +113,7 @@
// Get information about the properties that can contain visibility rules.
visibilityProperties() []visibilityProperty
- RequiredModuleNames() []string
+ RequiredModuleNames(ctx ConfigAndErrorContext) []string
HostRequiredModuleNames() []string
TargetRequiredModuleNames() []string
@@ -422,7 +422,7 @@
Vintf_fragments []string `android:"path"`
// names of other modules to install if this module is installed
- Required []string `android:"arch_variant"`
+ Required proptools.Configurable[[]string] `android:"arch_variant"`
// names of other modules to install on host if this module is installed
Host_required []string `android:"arch_variant"`
@@ -1101,7 +1101,7 @@
hostTargets = append(hostTargets, ctx.Config().BuildOSCommonTarget)
if ctx.Device() {
- for _, depName := range ctx.Module().RequiredModuleNames() {
+ for _, depName := range ctx.Module().RequiredModuleNames(ctx) {
for _, target := range deviceTargets {
addDep(target, depName)
}
@@ -1114,7 +1114,7 @@
}
if ctx.Host() {
- for _, depName := range ctx.Module().RequiredModuleNames() {
+ for _, depName := range ctx.Module().RequiredModuleNames(ctx) {
for _, target := range hostTargets {
// When a host module requires another host module, don't make a
// dependency if they have different OSes (i.e. hostcross).
@@ -1619,8 +1619,8 @@
return m.base().commonProperties.ImageVariation == RecoveryVariation
}
-func (m *ModuleBase) RequiredModuleNames() []string {
- return m.base().commonProperties.Required
+func (m *ModuleBase) RequiredModuleNames(ctx ConfigAndErrorContext) []string {
+ return m.base().commonProperties.Required.GetOrDefault(m.ConfigurableEvaluator(ctx), nil)
}
func (m *ModuleBase) HostRequiredModuleNames() []string {
@@ -1992,7 +1992,7 @@
TargetDependencies: targetRequired,
HostDependencies: hostRequired,
Data: data,
- Required: m.RequiredModuleNames(),
+ Required: m.RequiredModuleNames(ctx),
}
SetProvider(ctx, ModuleInfoJSONProvider, m.moduleInfoJSON)
}
diff --git a/android/module_context.go b/android/module_context.go
index 591e270..e2677a4 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -183,7 +183,7 @@
InstallInVendor() bool
InstallForceOS() (*OsType, *ArchType)
- RequiredModuleNames() []string
+ RequiredModuleNames(ctx ConfigAndErrorContext) []string
HostRequiredModuleNames() []string
TargetRequiredModuleNames() []string
@@ -755,8 +755,8 @@
return OptionalPath{}
}
-func (m *moduleContext) RequiredModuleNames() []string {
- return m.module.RequiredModuleNames()
+func (m *moduleContext) RequiredModuleNames(ctx ConfigAndErrorContext) []string {
+ return m.module.RequiredModuleNames(ctx)
}
func (m *moduleContext) HostRequiredModuleNames() []string {
diff --git a/android/soongconfig/modules.go b/android/soongconfig/modules.go
index 87af774..f6046d0 100644
--- a/android/soongconfig/modules.go
+++ b/android/soongconfig/modules.go
@@ -824,11 +824,16 @@
}
field.Set(newField)
case reflect.Struct:
- fieldName = append(fieldName, propStruct.Type().Field(i).Name)
- if err := s.printfIntoPropertyRecursive(fieldName, field, configValues); err != nil {
- return err
+ if proptools.IsConfigurable(field.Type()) {
+ fieldName = append(fieldName, propStruct.Type().Field(i).Name)
+ return fmt.Errorf("soong_config_variables.%s.%s: list variables are not supported on configurable properties", s.variable, strings.Join(fieldName, "."))
+ } else {
+ fieldName = append(fieldName, propStruct.Type().Field(i).Name)
+ if err := s.printfIntoPropertyRecursive(fieldName, field, configValues); err != nil {
+ return err
+ }
+ fieldName = fieldName[:len(fieldName)-1]
}
- fieldName = fieldName[:len(fieldName)-1]
default:
fieldName = append(fieldName, propStruct.Type().Field(i).Name)
return fmt.Errorf("soong_config_variables.%s.%s: unsupported property type %q", s.variable, strings.Join(fieldName, "."), kind)
diff --git a/android/testing.go b/android/testing.go
index 6518f4a..b9c2717 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -224,6 +224,10 @@
})
}
+func (ctx *TestContext) OtherModulePropertyErrorf(module Module, property string, fmt_ string, args ...interface{}) {
+ panic(fmt.Sprintf(fmt_, args...))
+}
+
// registeredComponentOrder defines the order in which a sortableComponent type is registered at
// runtime and provides support for reordering the components registered for a test in the same
// way.