Support constraint_value directly in select()
No more need for a redundant config_setting. See #8583 for an example.
This was a bit subtle. constraint_value can't directly export a ConfigMatchingProvider because it needs to know the
platform to determine if it's a match. But platforms are built out of constraint_values, so the platform isn't available
yet. So the parent target with the select() provides this detail.
Also beautifies "invalid select() key" errors in support of https://github.com/bazelbuild/bazel/issues/11984.
Fixes https://github.com/bazelbuild/bazel/issues/8583.
RELNOTES[NEW]: select() directly supports constraint_value (no need for an intermediate config_setting).
Closes #12071.
PiperOrigin-RevId: 331181346
diff --git a/site/docs/configurable-attributes.md b/site/docs/configurable-attributes.md
index ddede2b..0316388 100644
--- a/site/docs/configurable-attributes.md
+++ b/site/docs/configurable-attributes.md
@@ -144,10 +144,15 @@
## Configuration conditions
Each key in a configurable attribute is a label reference to a
-[`config_setting`](be/general.html#config_setting). This is just a collection of
+[`config_setting`](be/general.html#config_setting) or
+[`constraint_value`](be/platform.html#constraint_value).
+
+`config_setting` is just a collection of
expected command line flag settings. By encapsulating these in a target, it's
easy to maintain "standard" conditions users can reference from multiple places.
+`constraint_value` provides support for [multi-platform behavior](#platforms).
+
### Built-in flags
@@ -263,7 +268,7 @@
flexibility, it can also be burdensome to individually set each one every time
you want to build a target.
[Platforms](platforms.html)
-allow you to consolidate these into simple bundles.
+let you consolidate these into simple bundles.
```python
# myapp/BUILD
@@ -338,8 +343,26 @@
bazel build //my_app:my_rocks --define color=white --define texture=smooth --define type=metamorphic
```
-Platforms are still under development. See the [documentation](platforms.html)
-and [roadmap](https://bazel.build/roadmaps/platforms.html) for details.
+`select()` can also directly read `constraint_value`s:
+
+```python
+constraint_setting(name = "type")
+constraint_value(name = "igneous", constraint_setting = "type")
+constraint_value(name = "metamorphic", constraint_setting = "type")
+sh_binary(
+ name = "my_rocks",
+ srcs = select({
+ ":igneous": ["igneous.sh"],
+ ":metamorphic" ["metamorphic.sh"],
+ }),
+)
+```
+
+This saves the need for boilerplate `config_setting`s when you only need to
+check against single values.
+
+Platforms are still under development. See the
+[documentation](platforms-intro.html) for details.
## Combining `select()`s