bazel-skylib
bazel-skylib copied to clipboard
Provide `TRUE`/`FALSE` config_setting(s) for use in negating configs
A pattern I have used (and seen elsewhere) is to "negate" a config through the use of a pre-defined bool_setting.
It might be nice to provide this in Skylib.
This could be provided with either (or both):
- a predefined "always true"
:true_setting - a function in
selectswhich negates a givenconfig_settingorconstraint_value
Here's an example usage:
# Define a toolchain viable for ~anything but arm64:
toolchain(
...
target_settings = [":not_arm64"],
...
)
alias(
name = "not_arm64",
actual = select({
"@platforms//cpu:arm64": ":FALSE",
"//conditions:default": ":TRUE",
}),
)
bool_setting(
name = "true_setting",
build_setting_default = True,
visibility = ["//visibility:private"],
)
config_setting(
name = "TRUE",
flag_values = {
":true_setting": "True",
},
)
config_setting(
name = "FALSE",
flag_values = {
":true_setting": "False",
},
)