Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate all settings labels from aliases to using settings package #3032

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,12 @@ tasks:
- "--@rules_rust//rust/toolchain/channel=nightly"
- "--@rules_rust//rust/settings:experimental_use_cc_common_link=True"
- "--@rules_rust//rust/settings:experimental_use_global_allocator=True"
- "--@rules_rust//:no_std=alloc"
- "--@rules_rust//rust/settings:no_std=alloc"
test_flags:
- "--@rules_rust//rust/toolchain/channel=nightly"
- "--@rules_rust//rust/settings:experimental_use_cc_common_link=True"
- "--@rules_rust//rust/settings:experimental_use_global_allocator=True"
- "--@rules_rust//:no_std=alloc"
- "--@rules_rust//rust/settings:no_std=alloc"
no_std_ubuntu2004:
name: Build with no_std + alloc
platform: ubuntu2004
Expand All @@ -568,10 +568,10 @@ tasks:
- "//..."
build_flags:
- "--@rules_rust//rust/toolchain/channel=nightly"
- "--@rules_rust//:no_std=alloc"
- "--@rules_rust//rust/settings:no_std=alloc"
test_flags:
- "--@rules_rust//rust/toolchain/channel=nightly"
- "--@rules_rust//:no_std=alloc"
- "--@rules_rust//rust/settings:no_std=alloc"
bzlmod_repo_mapping_runfiles:
name: bzlmod repo mapping test
platform: ubuntu2004
Expand Down
2 changes: 1 addition & 1 deletion docs/rust_analyzer.vm
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ to ensure a `rust-project.json` file is created and up to date when the editor i

Add the following to your bazelrc:
```
build --@rules_rust//:rustc_output_diagnostics=true --output_groups=+rust_lib_rustc_output,+rust_metadata_rustc_output
build --@rules_rust//rust/settings:rustc_output_diagnostics=true --output_groups=+rust_lib_rustc_output,+rust_metadata_rustc_output
```

Then you can use a prototype [rust-analyzer plugin](https://marketplace.visualstudio.com/items?itemName=MattStark.bazel-rust-analyzer) that automatically collects the outputs whenever you recompile.
Expand Down
2 changes: 1 addition & 1 deletion docs/rust_clippy.vm
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ the upstream implementation of clippy, this file must be named either `.clippy.t
`clippy.toml`. Using a custom config file requires Rust 1.34.0 or newer.

```text
build --@rules_rust//:clippy.toml=//:clippy.toml
build --@rules_rust//rust/settings:clippy.toml=//:clippy.toml
```
6 changes: 3 additions & 3 deletions docs/rust_fmt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Overview
]]#

[Rustfmt][rustfmt] is a tool for formatting Rust code according to style guidelines.
[Rustfmt][rustfmt] is a tool for formatting Rust code according to style guidelines.
By default, Rustfmt uses a style which conforms to the [Rust style guide][rsg] that
has been formalized through the [style RFC process][rfcp]. A complete list of all
configuration options can be found in the [Rustfmt GitHub Pages][rgp].
Expand Down Expand Up @@ -30,13 +30,13 @@ build --output_groups=+rustfmt_checks
It's recommended to only enable this aspect in your CI environment so formatting issues do not
impact user's ability to rapidly iterate on changes.

The `rustfmt_aspect` also uses a `--@rules_rust//:rustfmt.toml` setting which determines the
The `rustfmt_aspect` also uses a `--@rules_rust//rust/settings:rustfmt.toml` setting which determines the
[configuration file][rgp] used by the formatter (`@rules_rust//tools/rustfmt`) and the aspect
(`rustfmt_aspect`). This flag can be added to your `.bazelrc` file to ensure a consistent config
file is used whenever `rustfmt` is run:

```text
build --@rules_rust//:rustfmt.toml=//:rustfmt.toml
build --@rules_rust//rust/settings:rustfmt.toml=//:rustfmt.toml
```
#[[
### Tips
Expand Down
8 changes: 4 additions & 4 deletions docs/src/flatten.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ A rule for generating variables for dependent `cargo_build_script`s without a bu
error_format(<a href="#error_format-name">name</a>)
</pre>

Change the [--error-format](https://doc.rust-lang.org/rustc/command-line-arguments.html#option-error-format) flag from the command line with `--@rules_rust//:error_format`. See rustc documentation for valid values.
Change the [--error-format](https://doc.rust-lang.org/rustc/command-line-arguments.html#option-error-format) flag from the command line with `--@rules_rust//rust/settings:error_format`. See rustc documentation for valid values.

**ATTRIBUTES**

Expand All @@ -106,7 +106,7 @@ Change the [--error-format](https://doc.rust-lang.org/rustc/command-line-argumen
extra_rustc_flag(<a href="#extra_rustc_flag-name">name</a>)
</pre>

Add additional rustc_flag from the command line with `--@rules_rust//:extra_rustc_flag`. Multiple uses are accumulated and appended after the extra_rustc_flags.
Add additional rustc_flag from the command line with `--@rules_rust//rust/settings:extra_rustc_flag`. Multiple uses are accumulated and appended after the extra_rustc_flags.

**ATTRIBUTES**

Expand All @@ -124,7 +124,7 @@ Add additional rustc_flag from the command line with `--@rules_rust//:extra_rust
extra_rustc_flags(<a href="#extra_rustc_flags-name">name</a>)
</pre>

Add additional rustc_flags from the command line with `--@rules_rust//:extra_rustc_flags`. This flag should only be used for flags that need to be applied across the entire build. For options that apply to individual crates, use the rustc_flags attribute on the individual crate's rule instead. NOTE: These flags not applied to the exec configuration (proc-macros, cargo_build_script, etc); use `--@rules_rust//:extra_exec_rustc_flags` to apply flags to the exec configuration.
Add additional rustc_flags from the command line with `--@rules_rust//rust/settings:extra_rustc_flags`. This flag should only be used for flags that need to be applied across the entire build. For options that apply to individual crates, use the rustc_flags attribute on the individual crate's rule instead. NOTE: These flags not applied to the exec configuration (proc-macros, cargo_build_script, etc); use `--@rules_rust//rust/settings:extra_exec_rustc_flags` to apply flags to the exec configuration.

**ATTRIBUTES**

Expand Down Expand Up @@ -1669,7 +1669,7 @@ Output Groups:

- `rustfmt_checks`: Executes `rustfmt --check` on the specified target.

The build setting `@rules_rust//:rustfmt.toml` is used to control the Rustfmt [configuration settings][cs]
The build setting `@rules_rust//rust/settings:rustfmt.toml` is used to control the Rustfmt [configuration settings][cs]
used at runtime.

[cs]: https://rust-lang.github.io/rustfmt/
Expand Down
6 changes: 3 additions & 3 deletions docs/src/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Control whether to print clippy output or store it to a file, using the configur
error_format(<a href="#error_format-name">name</a>)
</pre>

Change the [--error-format](https://doc.rust-lang.org/rustc/command-line-arguments.html#option-error-format) flag from the command line with `--@rules_rust//:error_format`. See rustc documentation for valid values.
Change the [--error-format](https://doc.rust-lang.org/rustc/command-line-arguments.html#option-error-format) flag from the command line with `--@rules_rust//rust/settings:error_format`. See rustc documentation for valid values.

**ATTRIBUTES**

Expand All @@ -58,7 +58,7 @@ Change the [--error-format](https://doc.rust-lang.org/rustc/command-line-argumen
extra_rustc_flag(<a href="#extra_rustc_flag-name">name</a>)
</pre>

Add additional rustc_flag from the command line with `--@rules_rust//:extra_rustc_flag`. Multiple uses are accumulated and appended after the extra_rustc_flags.
Add additional rustc_flag from the command line with `--@rules_rust//rust/settings:extra_rustc_flag`. Multiple uses are accumulated and appended after the extra_rustc_flags.

**ATTRIBUTES**

Expand All @@ -76,7 +76,7 @@ Add additional rustc_flag from the command line with `--@rules_rust//:extra_rust
extra_rustc_flags(<a href="#extra_rustc_flags-name">name</a>)
</pre>

Add additional rustc_flags from the command line with `--@rules_rust//:extra_rustc_flags`. This flag should only be used for flags that need to be applied across the entire build. For options that apply to individual crates, use the rustc_flags attribute on the individual crate's rule instead. NOTE: These flags not applied to the exec configuration (proc-macros, cargo_build_script, etc); use `--@rules_rust//:extra_exec_rustc_flags` to apply flags to the exec configuration.
Add additional rustc_flags from the command line with `--@rules_rust//rust/settings:extra_rustc_flags`. This flag should only be used for flags that need to be applied across the entire build. For options that apply to individual crates, use the rustc_flags attribute on the individual crate's rule instead. NOTE: These flags not applied to the exec configuration (proc-macros, cargo_build_script, etc); use `--@rules_rust//rust/settings:extra_exec_rustc_flags` to apply flags to the exec configuration.

**ATTRIBUTES**

Expand Down
2 changes: 1 addition & 1 deletion docs/src/rust_analyzer.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ to ensure a `rust-project.json` file is created and up to date when the editor i

Add the following to your bazelrc:
```
build --@rules_rust//:rustc_output_diagnostics=true --output_groups=+rust_lib_rustc_output,+rust_metadata_rustc_output
build --@rules_rust//rust/settings:rustc_output_diagnostics=true --output_groups=+rust_lib_rustc_output,+rust_metadata_rustc_output
```

Then you can use a prototype [rust-analyzer plugin](https://marketplace.visualstudio.com/items?itemName=MattStark.bazel-rust-analyzer) that automatically collects the outputs whenever you recompile.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/rust_clippy.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ the upstream implementation of clippy, this file must be named either `.clippy.t
`clippy.toml`. Using a custom config file requires Rust 1.34.0 or newer.

```text
build --@rules_rust//:clippy.toml=//:clippy.toml
build --@rules_rust//rust/settings:clippy.toml=//:clippy.toml
```

<a id="rust_clippy"></a>
Expand Down
8 changes: 4 additions & 4 deletions docs/src/rust_fmt.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## Overview


[Rustfmt][rustfmt] is a tool for formatting Rust code according to style guidelines.
[Rustfmt][rustfmt] is a tool for formatting Rust code according to style guidelines.
By default, Rustfmt uses a style which conforms to the [Rust style guide][rsg] that
has been formalized through the [style RFC process][rfcp]. A complete list of all
configuration options can be found in the [Rustfmt GitHub Pages][rgp].
Expand Down Expand Up @@ -37,13 +37,13 @@ build --output_groups=+rustfmt_checks
It's recommended to only enable this aspect in your CI environment so formatting issues do not
impact user's ability to rapidly iterate on changes.

The `rustfmt_aspect` also uses a `--@rules_rust//:rustfmt.toml` setting which determines the
The `rustfmt_aspect` also uses a `--@rules_rust//rust/settings:rustfmt.toml` setting which determines the
[configuration file][rgp] used by the formatter (`@rules_rust//tools/rustfmt`) and the aspect
(`rustfmt_aspect`). This flag can be added to your `.bazelrc` file to ensure a consistent config
file is used whenever `rustfmt` is run:

```text
build --@rules_rust//:rustfmt.toml=//:rustfmt.toml
build --@rules_rust//rust/settings:rustfmt.toml=//:rustfmt.toml
```

### Tips
Expand Down Expand Up @@ -113,7 +113,7 @@ Output Groups:

- `rustfmt_checks`: Executes `rustfmt --check` on the specified target.

The build setting `@rules_rust//:rustfmt.toml` is used to control the Rustfmt [configuration settings][cs]
The build setting `@rules_rust//rust/settings:rustfmt.toml` is used to control the Rustfmt [configuration settings][cs]
used at runtime.

[cs]: https://rust-lang.github.io/rustfmt/
Expand Down
18 changes: 9 additions & 9 deletions rust/private/clippy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _clippy_flag_impl(ctx):

clippy_flag = rule(
doc = (
"Add a custom clippy flag from the command line with `--@rules_rust//:clippy_flag`." +
"Add a custom clippy flag from the command line with `--@rules_rust//rust/settings:clippy_flag`." +
"Multiple uses are accumulated and appended after the extra_rustc_flags."
),
implementation = _clippy_flag_impl,
Expand All @@ -51,7 +51,7 @@ def _clippy_flags_impl(ctx):

clippy_flags = rule(
doc = (
"Add custom clippy flags from the command line with `--@rules_rust//:clippy_flags`."
"Add custom clippy flags from the command line with `--@rules_rust//rust/settings:clippy_flags`."
),
implementation = _clippy_flags_impl,
build_setting = config.string_list(flag = True),
Expand Down Expand Up @@ -210,7 +210,7 @@ rust_clippy_aspect = aspect(
attrs = {
"_capture_output": attr.label(
doc = "Value of the `capture_clippy_output` build setting",
default = Label("//:capture_clippy_output"),
default = Label("//rust/settings:capture_clippy_output"),
),
"_cc_toolchain": attr.label(
doc = (
Expand All @@ -222,26 +222,26 @@ rust_clippy_aspect = aspect(
"_clippy_flag": attr.label(
doc = "Arguments to pass to clippy." +
"Multiple uses are accumulated and appended after the extra_rustc_flags.",
default = Label("//:clippy_flag"),
default = Label("//rust/settings:clippy_flag"),
),
"_clippy_flags": attr.label(
doc = "Arguments to pass to clippy",
default = Label("//:clippy_flags"),
default = Label("//rust/settings:clippy_flags"),
),
"_config": attr.label(
doc = "The `clippy.toml` file used for configuration",
allow_single_file = True,
default = Label("//:clippy.toml"),
default = Label("//rust/settings:clippy.toml"),
),
"_error_format": attr.label(
doc = "The desired `--error-format` flags for clippy",
default = "//:error_format",
default = "//rust/settings:error_format",
),
"_extra_rustc_flag": attr.label(
default = Label("//:extra_rustc_flag"),
default = Label("//rust/settings:extra_rustc_flag"),
),
"_per_crate_rustc_flag": attr.label(
default = Label("//:experimental_per_crate_rustc_flag"),
default = Label("//rust/settings:experimental_per_crate_rustc_flag"),
),
"_process_wrapper": attr.label(
doc = "A process wrapper for running clippy on all platforms",
Expand Down
14 changes: 7 additions & 7 deletions rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -538,19 +538,19 @@ RUSTC_ATTRS = {
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
),
"_error_format": attr.label(
default = Label("//:error_format"),
default = Label("//rust/settings:error_format"),
),
"_extra_exec_rustc_flag": attr.label(
default = Label("//:extra_exec_rustc_flag"),
default = Label("//rust/settings:extra_exec_rustc_flag"),
),
"_extra_exec_rustc_flags": attr.label(
default = Label("//:extra_exec_rustc_flags"),
default = Label("//rust/settings:extra_exec_rustc_flags"),
),
"_extra_rustc_flag": attr.label(
default = Label("//:extra_rustc_flag"),
default = Label("//rust/settings:extra_rustc_flag"),
),
"_extra_rustc_flags": attr.label(
default = Label("//:extra_rustc_flags"),
default = Label("//rust/settings:extra_rustc_flags"),
),
"_is_proc_macro_dep": attr.label(
default = Label("//rust/private:is_proc_macro_dep"),
Expand All @@ -559,7 +559,7 @@ RUSTC_ATTRS = {
default = Label("//rust/private:is_proc_macro_dep_enabled"),
),
"_per_crate_rustc_flag": attr.label(
default = Label("//:experimental_per_crate_rustc_flag"),
default = Label("//rust/settings:experimental_per_crate_rustc_flag"),
),
"_process_wrapper": attr.label(
doc = "A process wrapper for running rustc on all platforms.",
Expand All @@ -569,7 +569,7 @@ RUSTC_ATTRS = {
cfg = "exec",
),
"_rustc_output_diagnostics": attr.label(
default = Label("//:rustc_output_diagnostics"),
default = Label("//rust/settings:rustc_output_diagnostics"),
),
}

Expand Down
18 changes: 9 additions & 9 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,7 @@ def _error_format_impl(ctx):
error_format = rule(
doc = (
"Change the [--error-format](https://doc.rust-lang.org/rustc/command-line-arguments.html#option-error-format) " +
"flag from the command line with `--@rules_rust//:error_format`. See rustc documentation for valid values."
"flag from the command line with `--@rules_rust//rust/settings:error_format`. See rustc documentation for valid values."
),
implementation = _error_format_impl,
build_setting = config.string(flag = True),
Expand All @@ -2176,7 +2176,7 @@ def _rustc_output_diagnostics_impl(ctx):

rustc_output_diagnostics = rule(
doc = (
"Setting this flag from the command line with `--@rules_rust//:rustc_output_diagnostics` " +
"Setting this flag from the command line with `--@rules_rust//rust/settings:rustc_output_diagnostics` " +
"makes rules_rust save rustc json output(suitable for consumption by rust-analyzer) in a file. " +
"These are accessible via the " +
"`rustc_rmeta_output`(for pipelined compilation) and `rustc_output` output groups. " +
Expand All @@ -2191,11 +2191,11 @@ def _extra_rustc_flags_impl(ctx):

extra_rustc_flags = rule(
doc = (
"Add additional rustc_flags from the command line with `--@rules_rust//:extra_rustc_flags`. " +
"Add additional rustc_flags from the command line with `--@rules_rust//rust/settings:extra_rustc_flags`. " +
"This flag should only be used for flags that need to be applied across the entire build. For options that " +
"apply to individual crates, use the rustc_flags attribute on the individual crate's rule instead. NOTE: " +
"These flags not applied to the exec configuration (proc-macros, cargo_build_script, etc); " +
"use `--@rules_rust//:extra_exec_rustc_flags` to apply flags to the exec configuration."
"use `--@rules_rust//rust/settings:extra_exec_rustc_flags` to apply flags to the exec configuration."
),
implementation = _extra_rustc_flags_impl,
build_setting = config.string_list(flag = True),
Expand All @@ -2206,7 +2206,7 @@ def _extra_rustc_flag_impl(ctx):

extra_rustc_flag = rule(
doc = (
"Add additional rustc_flag from the command line with `--@rules_rust//:extra_rustc_flag`. " +
"Add additional rustc_flag from the command line with `--@rules_rust//rust/settings:extra_rustc_flag`. " +
"Multiple uses are accumulated and appended after the extra_rustc_flags."
),
implementation = _extra_rustc_flag_impl,
Expand All @@ -2218,7 +2218,7 @@ def _extra_exec_rustc_flags_impl(ctx):

extra_exec_rustc_flags = rule(
doc = (
"Add additional rustc_flags in the exec configuration from the command line with `--@rules_rust//:extra_exec_rustc_flags`. " +
"Add additional rustc_flags in the exec configuration from the command line with `--@rules_rust//rust/settings:extra_exec_rustc_flags`. " +
"This flag should only be used for flags that need to be applied across the entire build. " +
"These flags only apply to the exec configuration (proc-macros, cargo_build_script, etc)."
),
Expand All @@ -2231,7 +2231,7 @@ def _extra_exec_rustc_flag_impl(ctx):

extra_exec_rustc_flag = rule(
doc = (
"Add additional rustc_flags in the exec configuration from the command line with `--@rules_rust//:extra_exec_rustc_flag`. " +
"Add additional rustc_flags in the exec configuration from the command line with `--@rules_rust//rust/settings:extra_exec_rustc_flag`. " +
"Multiple uses are accumulated and appended after the extra_exec_rustc_flags."
),
implementation = _extra_exec_rustc_flag_impl,
Expand All @@ -2243,7 +2243,7 @@ def _per_crate_rustc_flag_impl(ctx):

per_crate_rustc_flag = rule(
doc = (
"Add additional rustc_flag to matching crates from the command line with `--@rules_rust//:experimental_per_crate_rustc_flag`. " +
"Add additional rustc_flag to matching crates from the command line with `--@rules_rust//rust/settings:experimental_per_crate_rustc_flag`. " +
"The expected flag format is prefix_filter@flag, where any crate with a label or execution path starting with the prefix filter will be built with the given flag." +
"The label matching uses the canonical form of the label (i.e //package:label_name)." +
"The execution path is the relative path to your workspace directory including the base name (including extension) of the crate root." +
Expand All @@ -2265,7 +2265,7 @@ no_std = rule(
"No std; we need this so that we can distinguish between host and exec"
),
attrs = {
"_no_std": attr.label(default = "//:no_std"),
"_no_std": attr.label(default = "//rust/settings:no_std"),
},
implementation = _no_std_impl,
)
Loading