selects
Skylib module containing convenience interfaces for select().
Macros and Functions
selects.with_or
Drop-in replacement for select()
that supports ORed keys.
Example:
```build
deps = selects.with_or({
"//configs:one": [":dep1"],
("//configs:two", "//configs:three"): [":dep2or3"],
"//configs:four": [":dep4"],
"//conditions:default": [":default"]
})
```
Key labels may appear at most once anywhere in the input.
Example usage (generated):
load("@bazel_skylib//lib:selects.bzl", "selects")
selects.with_or(
# The same dictionary `select()` takes, except keys may take
input_dict = None,
)
input_dict
Required.
The same dictionary select()
takes, except keys may take
either the usual form "//foo:config1"
or
("//foo:config1", "//foo:config2", ...)
to signify
//foo:config1
OR //foo:config2
OR ...
.
no_match_error
Optional. Default: ""
Optional custom error to report if no condition matches.
selects.with_or_dict
Variation of with_or
that returns the dict of the select()
.
Unlike select()
, the contents of the dict can be inspected by Starlark
macros.
Example usage (generated):
load("@bazel_skylib//lib:selects.bzl", "selects")
selects.with_or_dict(
# Same as `with_or`.
input_dict = None,
)
input_dict
Required.
Same as with_or
.
selects.config_setting_group
Matches if all or any of its member config_setting
s match.
Example:
config_setting(name = "one", define_values = {"foo": "true"})
config_setting(name = "two", define_values = {"bar": "false"})
config_setting(name = "three", define_values = {"baz": "more_false"})
config_setting_group(
name = "one_two_three",
match_all = [":one", ":two", ":three"]
)
cc_binary(
name = "myapp",
srcs = ["myapp.cc"],
deps = select({
":one_two_three": [":special_deps"],
"//conditions:default": [":default_deps"]
})
Example usage (generated):
load("@bazel_skylib//lib:selects.bzl", "selects")
selects.config_setting_group(
# The group's name
name = "",
)
name
Required.
The group's name. This is how select()
s reference it.
match_any
Optional. Default: []
A list of config_settings
. This group matches if any member
in the list matches. If this is set, match_all
must not be set.
match_all
Optional. Default: []
A list of config_settings
. This group matches if every
member in the list matches. If this is set, match_any
must be not
set.
visibility
Optional. Default: None
Visibility of the config_setting_group.