Add a function to create config_setting(s)

The use case for this is creating config_setting(s) specific to an apex
variant and selecting stub/impl in that config_setting. We likely need
only a handful of such config_setting(s), but determining that list
requires iterating the build graph.

Test: go test ./bp2build
Change-Id: I9aa552e3d0bcf67513023c3a7d4bbf8fae464ee4
This commit is contained in:
Spandan Das
2023-04-19 17:36:12 +00:00
parent c741160d81
commit 6a448ec1a3
7 changed files with 108 additions and 0 deletions

View File

@@ -1424,3 +1424,14 @@ func TryVariableSubstitution(s string, productVariable string) (string, bool) {
sub := productVariableSubstitutionPattern.ReplaceAllString(s, "$("+productVariable+")")
return sub, s != sub
}
// StringMapAttribute is a map of strings.
// The use case for this is storing the flag_values in a config_setting object.
// Bazel rules do not support map attributes, and this should NOT be used in Bazel rules.
type StringMapAttribute map[string]string
// ConfigSettingAttributes stores the keys of a config_setting object.
type ConfigSettingAttributes struct {
// Each key in Flag_values is a label to a custom string_setting
Flag_values StringMapAttribute
}