Skip to content

Commit

Permalink
Support select()
Browse files Browse the repository at this point in the history
  • Loading branch information
yrom committed Nov 22, 2022
1 parent 3bb6d78 commit d73e68f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions refresh_compile_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def refresh_compile_commands(
# In Python, `type(x) == y` is an antipattern, but [Starlark doesn't support inheritance](https://bazel.build/rules/language), so `isinstance` doesn't exist, and this is the correct way to switch on type.
if not targets: # Default to all targets in main workspace
targets = {"@//...": ""}
elif type(targets) == "select": # Allow select: https://bazel.build/reference/be/functions#select
# Pass select() to _expand_template to make it work
# see https://bazel.build/docs/configurable-attributes#faq-select-macro
pass
elif type(targets) == "list": # Allow specifying a list of targets w/o arguments
targets = {target: "" for target in targets}
elif type(targets) != "dict": # Assume they've supplied a single string/label and wrap it
Expand Down

0 comments on commit d73e68f

Please sign in to comment.