diff options
author | 2023-04-19 17:36:12 +0000 | |
---|---|---|
committer | 2023-04-28 19:43:43 +0000 | |
commit | 6a448ec1a346b5ace5f12687fc65933e75081a3f (patch) | |
tree | f40c2f8af7d199425b22f97b222748d2486316aa /starlark_fmt | |
parent | c741160d81b5f192a33ef476cbfd4b8f712a05c6 (diff) |
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
Diffstat (limited to 'starlark_fmt')
-rw-r--r-- | starlark_fmt/format.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/starlark_fmt/format.go b/starlark_fmt/format.go index a97f71b87..42095075c 100644 --- a/starlark_fmt/format.go +++ b/starlark_fmt/format.go @@ -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 { |