summaryrefslogtreecommitdiff
path: root/android/variable.go
diff options
context:
space:
mode:
author Sam Delmerico <delmerico@google.com> 2022-01-07 20:39:21 +0000
committer Sam Delmerico <delmerico@google.com> 2022-01-12 16:26:44 +0000
commit0e33c9d772a5652ee30edda5cb642bb62fe8f574 (patch)
tree10ac975a9002badc11a0031c4da95680862a0211 /android/variable.go
parent865d5e6c9d9c863b4efc5fdd90fad90cc45d9e18 (diff)
Support `enabled` flag in product variable config
Some Android.bp modules have `enabled: false` but only use a product variable such as `source_build` to enable the module. Currently b2build does not handle this case at all. This commit adds the functionality to support this use case. Also, remove `__enabled` suffix in ProductVariable SelectKey. Bug: 210546943 Test: go test ./bp2build Topic: use_enabled_flag_product_variable_config Change-Id: I459c17a84c172df010666391066bf4d11d19253e
Diffstat (limited to 'android/variable.go')
-rw-r--r--android/variable.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/android/variable.go b/android/variable.go
index b300267ba..40dd2d82c 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -601,10 +601,16 @@ func (p *ProductConfigProperty) SelectKey() string {
value := p.FullConfig
if value == p.Name {
- value = "enabled"
+ value = ""
}
- // e.g. acme__feature1__enabled, android__board__soc_a
- return strings.ToLower(strings.Join([]string{p.Namespace, p.Name, value}, "__"))
+
+ // e.g. acme__feature1, android__board__soc_a
+ selectKey := strings.ToLower(strings.Join([]string{p.Namespace, p.Name}, "__"))
+ if value != "" {
+ selectKey = strings.ToLower(strings.Join([]string{selectKey, value}, "__"))
+ }
+
+ return selectKey
}
// ProductConfigProperties is a map of maps to group property values according