Skip to content

Commit

Permalink
Fix annotations' crate.select for lists (#2981)
Browse files Browse the repository at this point in the history
Fixes #2940 

This changes fixes `crate.select`, used for annotations, for list flags.

A [recent fix](#2394) for
bzlmod introduced a remapping of `annotation` labels to lists. This did
not originally recurse into `select` structs. This fixes that issue.

Should I create one for `_stringify_label` too?
  • Loading branch information
nmattia authored Nov 5, 2024
1 parent c635541 commit d1f397b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion crate_universe/private/crate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,21 @@ def _stringify_label(value):
def _stringify_list(values):
if not values:
return values
return [str(x) for x in values]

if type(values) == "list":
return [str(x) for x in values]

# if values is a struct with a "selects" attribute, assume it was created with
# crate.select() and map values for all platforms
if type(values) == "struct" and type(values.selects) != "NoneType":
new_selects = {}

for k, v in values.selects.items():
new_selects[k] = [str(x) for x in v]

return struct(common = [str(x) for x in values.common], selects = new_selects)

fail("Cannot stringify unknown type for list '{}'".format(values))

def _select(common, selects):
"""A Starlark Select for `crate.annotation()`.
Expand Down

0 comments on commit d1f397b

Please sign in to comment.