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
This commit is contained in:
Sam Delmerico
2022-01-07 20:39:21 +00:00
parent 865d5e6c9d
commit 0e33c9d772
3 changed files with 227 additions and 21 deletions

View File

@@ -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