summaryrefslogtreecommitdiff
path: root/android/configurable_properties.go
blob: 2c794a186413222270890cf46ce2bb2ed2822116 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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),
	})
}