Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions site/en/extending/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,39 @@ final values can be affected by configuration. In Starlark, this will replace
the [`configuration_field`](/rules/lib/globals/bzl#configuration_field)
API.

#### `label_flag` and `label_setting` {:#label-flag-setting}

These rules serve as label-typed build settings used for transitions and command-line configuration. They function as aliases that can be redirected by the configuration.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This sentence is slightly misleading. While both label_flag and label_setting are label-typed build settings, only label_flag can be configured on the command line. label_setting is meant for internal configuration, for example via transitions. It would be clearer to explicitly state this difference.

Suggested change
These rules serve as label-typed build settings used for transitions and command-line configuration. They function as aliases that can be redirected by the configuration.
These rules are label-typed build settings. `label_flag` can be set on the command line, while `label_setting` is for internal configuration (e.g. via transitions). Both function as aliases that can be redirected by the configuration.


**Attributes:**

* `name`: (required) A unique name for this target.
* `build_setting_default`: (required) The default label this alias points to.
* `visibility`: (optional) Standard visibility attribute.

**Example:**

```python
# //example/BUILD
label_flag(
name = "my_flag",
build_setting_default = ":default_target",
visibility = ["//visibility:public"],
)

cc_library(
name = "default_target",
srcs = ["default.cc"],
)
```

You can then override this flag on the command line:

```shell
$ bazel build //my:target --//example:my_flag=//other:target
```


```python
# example/rules.bzl
MyProvider = provider(fields = ["my_field"])
Expand Down