aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android/config.go34
-rw-r--r--android/config_test.go7
-rw-r--r--android/variable.go2
3 files changed, 43 insertions, 0 deletions
diff --git a/android/config.go b/android/config.go
index 6463f877..b89ae488 100644
--- a/android/config.go
+++ b/android/config.go
@@ -65,6 +65,20 @@ type DeviceConfig struct {
*deviceConfig
}
+type VendorConfig interface {
+ // Bool interprets the variable named `name` as a boolean, returning true if, after
+ // lowercasing, it matches one of "1", "y", "yes", "on", or "true". Unset, or any other
+ // value will return false.
+ Bool(name string) bool
+
+ // String returns the string value of `name`. If the variable was not set, it will
+ // return the empty string.
+ String(name string) string
+
+ // IsSet returns whether the variable `name` was set by Make.
+ IsSet(name string) bool
+}
+
type config struct {
FileConfigurableOptions
productVariables productVariables
@@ -107,6 +121,8 @@ type deviceConfig struct {
OncePer
}
+type vendorConfig map[string]string
+
type jsonConfigurable interface {
SetDefaultConfig()
}
@@ -788,6 +804,24 @@ func (c *config) CFIEnabledForPath(path string) bool {
return PrefixInList(path, *c.productVariables.CFIIncludePaths)
}
+func (c *config) VendorConfig(name string) VendorConfig {
+ return vendorConfig(c.productVariables.VendorVars[name])
+}
+
+func (c vendorConfig) Bool(name string) bool {
+ v := strings.ToLower(c[name])
+ return v == "1" || v == "y" || v == "yes" || v == "on" || v == "true"
+}
+
+func (c vendorConfig) String(name string) string {
+ return c[name]
+}
+
+func (c vendorConfig) IsSet(name string) bool {
+ _, ok := c[name]
+ return ok
+}
+
func stringSlice(s *[]string) []string {
if s != nil {
return *s
diff --git a/android/config_test.go b/android/config_test.go
index 5eb6ed51..72942eb5 100644
--- a/android/config_test.go
+++ b/android/config_test.go
@@ -84,3 +84,10 @@ func TestProductConfigAnnotations(t *testing.T) {
t.Errorf(err.Error())
}
}
+
+func TestMissingVendorConfig(t *testing.T) {
+ c := &config{}
+ if c.VendorConfig("test").Bool("not_set") {
+ t.Errorf("Expected false")
+ }
+}
diff --git a/android/variable.go b/android/variable.go
index 831c50a5..a386b9df 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -226,6 +226,8 @@ type productVariables struct {
NamespacesToExport []string `json:",omitempty"`
PgoAdditionalProfileDirs []string `json:",omitempty"`
+
+ VendorVars map[string]map[string]string `json:",omitempty"`
}
func boolPtr(v bool) *bool {