blob: bde33e99b388ab3f6031ba673a3ad864c50fcde7 [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]
Yu Liu12ce0292025-03-19 19:43:15 +000010 for _, pattern := range SortedKeys(cases) {
11 value := cases[pattern]
Cole Fausta963b942024-04-11 17:43:00 -070012 if pattern == "" {
13 resultCases = append(resultCases, proptools.NewConfigurableCase(
14 []proptools.ConfigurablePattern{proptools.NewDefaultConfigurablePattern()},
15 value,
16 ))
17 } else {
18 resultCases = append(resultCases, proptools.NewConfigurableCase(
19 []proptools.ConfigurablePattern{proptools.NewStringConfigurablePattern(pattern)},
20 value,
21 ))
22 }
23 }
24
25 return proptools.NewConfigurable(
26 []proptools.ConfigurableCondition{proptools.NewConfigurableCondition("os", nil)},
27 resultCases,
28 )
29}
Cole Faust12ff57d2024-07-30 13:17:28 -070030
31func NewSimpleConfigurable[T proptools.ConfigurableElements](value T) proptools.Configurable[T] {
32 return proptools.NewConfigurable(nil, []proptools.ConfigurableCase[T]{
33 proptools.NewConfigurableCase(nil, &value),
34 })
35}