bazelbuild / bazelbuild/bazel-skylib

Provide `TRUE`/`FALSE` config_setting(s) for use in negating configs

Open
#403 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
444
Forks
202
PR merge metrics
No merged PRs in 30d

Description

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 `selects` which negates a given `config_setting` or `constraint_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",
},
)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.