blob: 2c794a186413222270890cf46ce2bb2ed2822116 [file] [log] [blame]
Cole Fausta963b942024-04-11 17:43:00 -07001package android
2
3import "github.com/google/blueprint/proptools"
4
5// CreateSelectOsToBool is a utility function that makes it easy to create a
6// Configurable property value that maps from os to a bool. Use an empty string
7// to indicate a "default" case.
8func CreateSelectOsToBool(cases map[string]*bool) proptools.Configurable[bool] {
9 var resultCases []proptools.ConfigurableCase[bool]
10 for pattern, value := range cases {
11 if pattern == "" {
12 resultCases = append(resultCases, proptools.NewConfigurableCase(
13 []proptools.ConfigurablePattern{proptools.NewDefaultConfigurablePattern()},
14 value,
15 ))
16 } else {
17 resultCases = append(resultCases, proptools.NewConfigurableCase(
18 []proptools.ConfigurablePattern{proptools.NewStringConfigurablePattern(pattern)},
19 value,
20 ))
21 }
22 }
23
24 return proptools.NewConfigurable(
25 []proptools.ConfigurableCondition{proptools.NewConfigurableCondition("os", nil)},
26 resultCases,
27 )
28}
Cole Faust12ff57d2024-07-30 13:17:28 -070029
30func NewSimpleConfigurable[T proptools.ConfigurableElements](value T) proptools.Configurable[T] {
31 return proptools.NewConfigurable(nil, []proptools.ConfigurableCase[T]{
32 proptools.NewConfigurableCase(nil, &value),
33 })
34}