To replace soong config modules with selects. Bug: 342006386 Test: m nothing --no-skip-soong-tests Change-Id: I56080c9a1647a072836d4e4e50d6a5d2c1a69d28
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package android
|
|
|
|
import "github.com/google/blueprint/proptools"
|
|
|
|
// CreateSelectOsToBool is a utility function that makes it easy to create a
|
|
// Configurable property value that maps from os to a bool. Use an empty string
|
|
// to indicate a "default" case.
|
|
func CreateSelectOsToBool(cases map[string]*bool) proptools.Configurable[bool] {
|
|
var resultCases []proptools.ConfigurableCase[bool]
|
|
for pattern, value := range cases {
|
|
if pattern == "" {
|
|
resultCases = append(resultCases, proptools.NewConfigurableCase(
|
|
[]proptools.ConfigurablePattern{proptools.NewDefaultConfigurablePattern()},
|
|
value,
|
|
))
|
|
} else {
|
|
resultCases = append(resultCases, proptools.NewConfigurableCase(
|
|
[]proptools.ConfigurablePattern{proptools.NewStringConfigurablePattern(pattern)},
|
|
value,
|
|
))
|
|
}
|
|
}
|
|
|
|
return proptools.NewConfigurable(
|
|
[]proptools.ConfigurableCondition{proptools.NewConfigurableCondition("os", nil)},
|
|
resultCases,
|
|
)
|
|
}
|
|
|
|
func NewSimpleConfigurable[T proptools.ConfigurableElements](value T) proptools.Configurable[T] {
|
|
return proptools.NewConfigurable(nil, []proptools.ConfigurableCase[T]{
|
|
proptools.NewConfigurableCase(nil, &value),
|
|
})
|
|
}
|