• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package 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 := range SortedKeys(cases) {
11		value := cases[pattern]
12		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}
30
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}
36