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

@@ -99,6 +99,16 @@ func PrintStringIntDict(dict map[string]int, indentLevel int) string {
return PrintDict(valDict, indentLevel)
}
// PrintStringStringDict returns a Starlark-compatible string formatted as dictionary with
// string keys and string values.
func PrintStringStringDict(dict map[string]string, indentLevel int) string {
valDict := make(map[string]string, len(dict))
for k, v := range dict {
valDict[k] = fmt.Sprintf(`"%s"`, v)
}
return PrintDict(valDict, indentLevel)
}
// PrintDict returns a starlark-compatible string containing a dictionary with string keys and
// values printed with no additional formatting.
func PrintDict(dict map[string]string, indentLevel int) string {