rules_rsAPI docs @0.0.61

@rules_rs//rs:cargo_build_script.bzl

Functions & Macros

cargo_build_script

Compile and execute a rust build script to generate build attributes

This rules take the same arguments as rust_binary.

Example:

Suppose you have a crate with a cargo build script build.rs:

[workspace]/ hello_lib/ BUILD build.rs src/ lib.rs

Then you want to use the build script in the following:

hello_lib/BUILD:

package(default_visibility = ["//visibility:public"]) load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library") load("@rules_rust//cargo:defs.bzl", "cargo_build_script") # This will run the build script from the root of the workspace, and # collect the outputs. cargo_build_script( name = "build_script", srcs = ["build.rs"], # Optional environment variables passed during build.rs compilation rustc_env = { "CARGO_PKG_VERSION": "0.1.2", }, # Optional environment variables passed during build.rs execution. # Note that as the build script's working directory is not execroot, # execpath/location will return an absolute path, instead of a relative # one. build_script_env = { "SOME_TOOL_OR_FILE": "$(execpath @tool//:binary)" }, # Optional data/tool dependencies data = ["@tool//:binary"], ) rust_library( name = "hello_lib", srcs = [ "src/lib.rs", ], deps = [":build_script"], )

The hello_lib target will be build with the flags and the environment variables declared by the build script in addition to the file generated by it.

Parameters
*name

The name for the underlying rule. This should be the name of the package
being compiled, optionally with a suffix of _bs. Otherwise, you can set the package name via pkg_name.

edition

The rust edition to use for the internal binary crate.

Default: None
crate_name

Crate name to use for build script.

Default: None
crate_root

The file that will be passed to rustc to be used for building this crate.

Default: None
srcs

Source files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made.

Default: []
crate_features

A list of features to enable for the build script.

Default: []
version

The semantic version (semver) of the crate.

Default: None
deps

The build-dependencies of the crate.

Default: []
link_deps

The subset of the (normal) dependencies of the crate that have the
links attribute and therefore provide environment variables to this build script.

Default: []
proc_macro_deps

List of rust_proc_macro targets used to build the script.

Default: []
build_script_env

Environment variables for build scripts.

Default: {}
build_script_env_files

Files containing additional environment variables to set
when running the build script.

Default: []
use_default_shell_env

Whether or not to include the default shell environment for the build script action. If unset the global
setting @rules_rust//cargo/settings:use_default_shell_env will be used to determine this value.

Default: None
data

Files needed by the build script.

Default: []
compile_data

Files needed for the compilation of the build script.

Default: []
tools

Tools (executables) needed by the build script.

Default: []
links

Name of the native library this crate links against.

Default: None
rundir

A directory to cd to before the cargo_build_script is run. This should be a path relative to the exec root.

The default behaviour (and the behaviour if rundir is set to the empty string) is to change to the relative path corresponding to the cargo manifest directory, which replicates the normal behaviour of cargo so it is easy to write compatible build scripts.

If set to ., the cargo build script will run in the exec root.

Default: None
rustc_env

Environment variables to set in rustc when compiling the build script.

Default: {}
rustc_env_files

Files containing additional environment variables to set for rustc
when building the build script.

Default: []
rustc_flags

List of compiler flags passed to rustc.

Default: []
visibility

Visibility to apply to the generated build script output.

Default: None
tags

(list of str, optional): Tags to apply to the generated build script output.

Default: None
aliases

Remap crates to a new name or moniker for linkage to this target. These are other rust_library targets and will be presented as the new name given.

Default: None
pkg_name

Override the package name used for the build script. This is useful if the build target name gets too long otherwise.

Default: None
kwargs

Forwards to the underlying rust_binary rule. An exception is the compatible_with
attribute, which shouldn't be forwarded to the rust_binary, as the rust_binary is only
built and used in exec mode. We propagate the compatible_with attribute to the _build_script_run
target.

@rules_rs//rs:extensions.bzl

Module Extensions

crate
Tag Classes
annotation

A collection of extra attributes and settings for a particular crate.

AttributeTypeDescription
*cratestring

The name of the crate the annotation is applied to

versionstring

The version of the crate the annotation is applied to. Defaults to all versions.

Default: "*"
repositorieslist of strings

A list of repository names specified from crate.from_cargo(name=...) that this annotation is applied to. Defaults to all repositories.

Default: []
additive_build_filelabel

A file containing extra contents to write to the bottom of generated BUILD files.

Default: None
additive_build_file_contentstring

Extra contents to write to the bottom of generated BUILD files.

Default: ""
build_script_datalist of strings

A list of labels to add to a crate's cargo_build_script::data attribute.

Default: []
build_script_data_selectdictionary: String → List of strings

A list of labels to add to a crate's cargo_build_script::data attribute. Keys should be the platform triplet. Value should be a list of labels.

Default: {}
build_script_envdictionary: String → String

Additional environment variables to set on a crate's cargo_build_script::env attribute.

Default: {}
build_script_env_selectdictionary: String → String

Additional environment variables to set on a crate's cargo_build_script::env attribute. Key should be the platform triplet. Value should be a JSON encoded dictionary mapping variable names to values, for example {"FOO": "bar"}.

Default: {}
build_script_toolchainslist of labels

A list of labels to set on a crates's cargo_build_script::toolchains attribute.

Default: []
build_script_tagslist of strings

A list of tags to add to a crate's cargo_build_script target.

Default: []
build_script_toolslist of strings

A list of labels to add to a crate's cargo_build_script::tools attribute.

Default: []
build_script_tools_selectdictionary: String → List of strings

A list of labels to add to a crate's cargo_build_script::tools attribute. Keys should be the platform triplet. Value should be a list of labels.

Default: {}
crate_featureslist of strings

A list of strings to add to a crate's rust_library::crate_features attribute.

Default: []
crate_features_selectdictionary: String → List of strings

A list of strings to add to a crate's rust_library::crate_features attribute. Keys should be the platform triplet. Value should be a list of features.

Default: {}
datalist of strings

A list of labels to add to a crate's rust_library::data attribute.

Default: []
depslist of strings

A list of labels to add to a crate's rust_library::deps attribute.

Default: []
tagslist of strings

A list of tags to add to a crate's generated targets.

Default: []
extra_aliased_targetsdictionary: String → String

A list of targets to add to the generated aliases in the root crate repository.

Default: {}
gen_binarieslist of strings

As a list, the subset of the crate's bins that should get rust_binary targets produced.

Default: []
gen_build_scriptstring

An authoritative flag to determine whether or not to produce cargo_build_script targets for the current crate. Supported values are 'on', 'off', and 'auto'.

Default: "auto"
patch_argslist of strings

The patch_args attribute of a Bazel repository rule. See http_archive.patch_args

Default: []
patch_toolstring

The patch_tool attribute of a Bazel repository rule. See http_archive.patch_tool

Default: ""
patcheslist of labels

The patches attribute of a Bazel repository rule. See http_archive.patches

Default: []
rustc_flagslist of strings

A list of strings to set on a crate's rust_library::rustc_flags attribute.

Default: []
rustc_flags_selectdictionary: String → List of strings

A list of strings to set on a crate's rust_library::rustc_flags attribute. Keys should be the platform triplet. Value should be a list of flags.

Default: {}
strip_prefixstring
Default: ""
workspace_cargo_tomlstring

For crates from git, the ruleset assumes the (workspace) Cargo.toml is in the repo root. This attribute overrides the assumption.

Default: "Cargo.toml"
from_cargo

Generates a repo @crates from a Cargo.toml / Cargo.lock pair.

AttributeTypeDescription
namename

The name of the repo to generate

Default: "crates"
cargo_tomllabel

The workspace-level Cargo.toml. There can be multiple crates in the workspace.

Default: None
cargo_locklabel
Default: None
cargo_configlabel
Default: None
use_home_cargo_credentialsboolean

If set, the ruleset will load ~/cargo/credentials.toml and attach those credentials to registry requests.

Default: False
*platform_tripleslist of strings

The set of triples to resolve for. They must correspond to the union of any exec/target platforms that will participate in your build.

use_legacy_rules_rust_platformsboolean

If true, use the legacy rules_rust platforms. If false, use rules_rs platforms.

Default: False
validate_lockfileboolean

If true, fail if Cargo.lock versions don't satisfy Cargo.toml requirements.

Default: True
debugboolean
Default: False

@rules_rs//rs:rules_rust_prost.bzl

Module extension that provisions the rules_rust_prost repository.

Module Extensions

rules_rust_prost

@rules_rs//rs:rules_rust_reexported_extensions.bzl

Module Extensions

rust

Rust toolchain extension.

Tag Classes
repository_set

Tags for defining rust repository sets (where toolchains are defined).

AttributeTypeDescription
authdictionary: String → String

Auth object compatible with repository_ctx.download to use when downloading files.

Default: {}
auth_patternsdictionary: String → String

Override mapping of hostnames to authorization patterns; mirrors the eponymous attribute from http_archive.

Default: {}
exec_compatible_withlist of labels

A list of constraints for the execution platform for this toolchain.

Default: []
exec_triplestring

Exec triple for this repository_set.

Default: ""
extra_exec_rustc_flagslist of strings

Extra flags to pass to rustc in exec configuration.

Default: []
extra_rustc_flagslist of strings

Extra flags to pass to rustc in non-exec configuration.

Default: []
namename

Name of the repository_set - if you're looking to replace default toolchains you must use the exact name you're replacing.

Default: ""
netrcstring

.netrc file to use for authentication; mirrors the eponymous attribute from http_archive.

Default: ""
opt_leveldictionary: String → String

Rustc optimization levels. For more details see the documentation for rust_toolchain.opt_level.

Default: {}
strip_leveldictionary: String → String

Rustc strip levels. For more details see the documentation for rust_toolchain.strip_level.

Default: {}
target_compatible_withlist of labels

List of platform constraints this toolchain produces, for the particular target_triple this call is for.

Default: []
target_settingslist of labels

A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution.

Default: []
target_triplestring

target_triple to configure.

Default: ""
versionslist of strings

A list of toolchain versions to download. This parameter only accepts one version per channel. E.g. ["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]. May be set to an empty list ([]) to inhibit rules_rust from registering toolchains.

Default: []
allocator_librarylabel

Target that provides allocator functions when rust_library targets are embedded in a cc_binary.

Default: None
dev_componentsboolean

Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly".

Default: False
editionstring

The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its edition attribute.

Default: ""
global_allocator_librarylabel

Target that provides allocator functions when global allocator is used with cc_common.link.

Default: None
rustfmt_versionstring

The version of the tool among "nightly", "beta", or an exact version.

Default: "nightly/2026-04-16"
sha256sdictionary: String → String

A dict associating tool subdirectories to sha256 hashes. See rust_repositories for more details.

Default: {}
urlslist of strings

A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format).

Default: ["https://static.rust-lang.org/dist/{}.tar.xz"]
toolchain

Tags for defining rust toolchains (where toolchain tools are fetched).

AttributeTypeDescription
aliasesdictionary: String → String

Map of full toolchain repository name to an alias. If any repository is created by this extension matches a key in this dictionary, the name of the created repository will be remapped to the value instead. This may be required to work around path length limits on Windows.

Default: {}
extra_exec_rustc_flagslist of strings

Extra flags to pass to rustc in exec configuration

Default: []
extra_rustc_flagslist of strings

Extra flags to pass to rustc in non-exec configuration

Default: []
extra_rustc_flags_triplesdictionary: String → List of strings

Extra flags to pass to rustc in non-exec configuration. Key is the triple, value is the flag.

Default: {}
extra_target_tripleslist of strings
Default: ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "wasm32-unknown-unknown", "wasm32-wasip1", "wasm32-wasip2"]
rust_analyzer_versionstring

The version of Rustc to pair with rust-analyzer.

Default: ""
rustfmt_toolchain_triplesdictionary: String → String

Like toolchain_triples, but for rustfmt toolchains. Mapping of rust target triple to repository name.

Default: {}
strip_leveldictionary: String → String

Rustc strip levels. For more details see the documentation for rust_toolchain.strip_level.

Default: {}
target_settingslist of labels

A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution.

Default: []
versionslist of strings

A list of toolchain versions to download. This parameter only accepts one version per channel. E.g. ["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]. May be set to an empty list ([]) to inhibit rules_rust from registering toolchains.

Default: ["1.95.0", "nightly/2026-04-16"]
allocator_librarylabel

Target that provides allocator functions when rust_library targets are embedded in a cc_binary.

Default: None
dev_componentsboolean

Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly".

Default: False
editionstring

The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its edition attribute.

Default: ""
global_allocator_librarylabel

Target that provides allocator functions when global allocator is used with cc_common.link.

Default: None
rustfmt_versionstring

The version of the tool among "nightly", "beta", or an exact version.

Default: "nightly/2026-04-16"
sha256sdictionary: String → String

A dict associating tool subdirectories to sha256 hashes. See rust_repositories for more details.

Default: {}
urlslist of strings

A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format).

Default: ["https://static.rust-lang.org/dist/{}.tar.xz"]
rust_host_tools

An extension which exposes Rust tools compatible with the current host platform.

Tag Classes
host_tools
AttributeTypeDescription
namename

The name of the module to create

Default: "rust_host_tools"
versionstring

The version of Rust to use for tools executed on the Bazel host.

Default: "1.95.0"
allocator_librarylabel

Target that provides allocator functions when rust_library targets are embedded in a cc_binary.

Default: None
dev_componentsboolean

Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly".

Default: False
editionstring

The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its edition attribute.

Default: ""
global_allocator_librarylabel

Target that provides allocator functions when global allocator is used with cc_common.link.

Default: None
rustfmt_versionstring

The version of the tool among "nightly", "beta", or an exact version.

Default: "nightly/2026-04-16"
sha256sdictionary: String → String

A dict associating tool subdirectories to sha256 hashes. See rust_repositories for more details.

Default: {}
urlslist of strings

A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format).

Default: ["https://static.rust-lang.org/dist/{}.tar.xz"]

@rules_rs//rs:rules_rust.bzl

Module extension that provisions the rules_rust repository.

Module Extensions

rules_rust
Tag Classes
patch

Additional patches to apply to the pinned rules_rust archive.

AttributeTypeDescription
patcheslist of labels

Additional patch files to apply to rules_rust.

Default: []
stripinteger

Equivalent to adding -pN when applying patches.

Default: 0

@rules_rs//rs:rust_binary.bzl

@rules_rs//rs:rust_library.bzl

@rules_rs//rs:rust_proc_macro.bzl

Functions & Macros

rust_proc_macro
Parameters
*name
deps
Default: []
proc_macro_deps
Default: []
kwargs

@rules_rs//rs:rust_shared_library.bzl

Functions & Macros

rust_shared_library
Parameters
*name
deps
Default: []
proc_macro_deps
Default: []
kwargs

@rules_rs//rs:rust_static_library.bzl

Functions & Macros

rust_static_library
Parameters
*name
deps
Default: []
proc_macro_deps
Default: []
kwargs

@rules_rs//rs:rust_test.bzl

@rules_rs//rs/platforms:declare_platforms.bzl

Platform definitions for Rust target triples.

Functions & Macros

declare_platforms
Parameters
targets
Default: ["aarch64-apple-darwin", "aarch64-pc-windows-msvc", "aarch64-unknown-linux-gnu", "i686-pc-windows-msvc", "i686-unknown-linux-gnu", "x86_64-pc-windows-gnu", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", "aarch64-pc-windows-gnullvm", "aarch64-unknown-linux-musl", "arm-unknown-linux-gnueabi", "arm-unknown-linux-gnueabihf", "armv7-unknown-linux-gnueabihf", "i686-pc-windows-gnu", "powerpc-unknown-linux-gnu", "powerpc64-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", "powerpc64le-unknown-linux-musl", "riscv64gc-unknown-linux-gnu", "s390x-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-gnullvm", "x86_64-unknown-freebsd", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "aarch64-apple-ios", "aarch64-apple-ios-macabi", "aarch64-apple-ios-sim", "aarch64-linux-android", "aarch64-unknown-fuchsia", "aarch64-unknown-none", "aarch64-unknown-none-softfloat", "aarch64-unknown-uefi", "arm-linux-androideabi", "arm-unknown-linux-musleabi", "arm-unknown-linux-musleabihf", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabi", "armv7-unknown-linux-musleabi", "armv7-unknown-linux-musleabihf", "i686-linux-android", "i686-pc-windows-gnullvm", "i686-unknown-freebsd", "i686-unknown-linux-musl", "i686-unknown-uefi", "riscv32imc-unknown-none-elf", "riscv64gc-unknown-linux-musl", "riscv64gc-unknown-none-elf", "thumbv6m-none-eabi", "thumbv7em-none-eabi", "thumbv7em-none-eabihf", "thumbv7m-none-eabi", "thumbv8m.main-none-eabi", "thumbv8m.main-none-eabihf", "wasm32-unknown-emscripten", "wasm32-unknown-unknown", "wasm32-wasip1", "wasm32-wasip1-threads", "wasm32-wasip2", "x86_64-apple-ios", "x86_64-apple-ios-macabi", "x86_64-linux-android", "x86_64-unknown-fuchsia", "x86_64-unknown-none", "x86_64-unknown-uefi"]

@rules_rs//rs/platforms:triples.bzl

Functions & Macros

triple_to_constraint_set
Parameters
*target_triple

@rules_rs//rs/platforms/config:declare_config_settings.bzl

Config settings for Rust target triples.

Functions & Macros

declare_config_settings
Parameters
targets
Default: ["aarch64-apple-darwin", "aarch64-pc-windows-msvc", "aarch64-unknown-linux-gnu", "i686-pc-windows-msvc", "i686-unknown-linux-gnu", "x86_64-pc-windows-gnu", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", "aarch64-pc-windows-gnullvm", "aarch64-unknown-linux-musl", "arm-unknown-linux-gnueabi", "arm-unknown-linux-gnueabihf", "armv7-unknown-linux-gnueabihf", "i686-pc-windows-gnu", "powerpc-unknown-linux-gnu", "powerpc64-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", "powerpc64le-unknown-linux-musl", "riscv64gc-unknown-linux-gnu", "s390x-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-gnullvm", "x86_64-unknown-freebsd", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "aarch64-apple-ios", "aarch64-apple-ios-macabi", "aarch64-apple-ios-sim", "aarch64-linux-android", "aarch64-unknown-fuchsia", "aarch64-unknown-none", "aarch64-unknown-none-softfloat", "aarch64-unknown-uefi", "arm-linux-androideabi", "arm-unknown-linux-musleabi", "arm-unknown-linux-musleabihf", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabi", "armv7-unknown-linux-musleabi", "armv7-unknown-linux-musleabihf", "i686-linux-android", "i686-pc-windows-gnullvm", "i686-unknown-freebsd", "i686-unknown-linux-musl", "i686-unknown-uefi", "riscv32imc-unknown-none-elf", "riscv64gc-unknown-linux-musl", "riscv64gc-unknown-none-elf", "thumbv6m-none-eabi", "thumbv7em-none-eabi", "thumbv7em-none-eabihf", "thumbv7m-none-eabi", "thumbv8m.main-none-eabi", "thumbv8m.main-none-eabihf", "wasm32-unknown-emscripten", "wasm32-unknown-unknown", "wasm32-wasip1", "wasm32-wasip1-threads", "wasm32-wasip2", "x86_64-apple-ios", "x86_64-apple-ios-macabi", "x86_64-linux-android", "x86_64-unknown-fuchsia", "x86_64-unknown-none", "x86_64-unknown-uefi"]

@rules_rs//rs/toolchains:declare_rust_analyzer_toolchains.bzl

Functions & Macros

declare_rust_analyzer_toolchains
Parameters
*version
*rust_analyzer_version
execs
Default: ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc", "x86_64-apple-darwin", "aarch64-apple-darwin"]

@rules_rs//rs/toolchains:declare_rustc_toolchains.bzl

Functions & Macros

declare_rustc_toolchains

Declare toolchains for all supported target platforms.

Parameters
*version
*edition
extra_rustc_flags
Default: {}
extra_exec_rustc_flags
Default: {}
execs
Default: ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc", "x86_64-apple-darwin", "aarch64-apple-darwin"]
targets
Default: ["aarch64-apple-darwin", "aarch64-pc-windows-msvc", "aarch64-unknown-linux-gnu", "i686-pc-windows-msvc", "i686-unknown-linux-gnu", "x86_64-pc-windows-gnu", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", "aarch64-pc-windows-gnullvm", "aarch64-unknown-linux-musl", "arm-unknown-linux-gnueabi", "arm-unknown-linux-gnueabihf", "armv7-unknown-linux-gnueabihf", "i686-pc-windows-gnu", "powerpc-unknown-linux-gnu", "powerpc64-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", "powerpc64le-unknown-linux-musl", "riscv64gc-unknown-linux-gnu", "s390x-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-gnullvm", "x86_64-unknown-freebsd", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "aarch64-apple-ios", "aarch64-apple-ios-macabi", "aarch64-apple-ios-sim", "aarch64-linux-android", "aarch64-unknown-fuchsia", "aarch64-unknown-none", "aarch64-unknown-none-softfloat", "aarch64-unknown-uefi", "arm-linux-androideabi", "arm-unknown-linux-musleabi", "arm-unknown-linux-musleabihf", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabi", "armv7-unknown-linux-musleabi", "armv7-unknown-linux-musleabihf", "i686-linux-android", "i686-pc-windows-gnullvm", "i686-unknown-freebsd", "i686-unknown-linux-musl", "i686-unknown-uefi", "riscv32imc-unknown-none-elf", "riscv64gc-unknown-linux-musl", "riscv64gc-unknown-none-elf", "thumbv6m-none-eabi", "thumbv7em-none-eabi", "thumbv7em-none-eabihf", "thumbv7m-none-eabi", "thumbv8m.main-none-eabi", "thumbv8m.main-none-eabihf", "wasm32-unknown-emscripten", "wasm32-unknown-unknown", "wasm32-wasip1", "wasm32-wasip1-threads", "wasm32-wasip2", "x86_64-apple-ios", "x86_64-apple-ios-macabi", "x86_64-linux-android", "x86_64-unknown-fuchsia", "x86_64-unknown-none", "x86_64-unknown-uefi"]

@rules_rs//rs/toolchains:declare_rustfmt_toolchains.bzl

Functions & Macros

declare_rustfmt_toolchains
Parameters
*version
*rustfmt_version
*edition
execs
Default: ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc", "x86_64-apple-darwin", "aarch64-apple-darwin"]

@rules_rs//rs/toolchains:module_extension.bzl

Module extension for configuring rules_rs Rust toolchains.

Module Extensions

toolchains
Tag Classes
toolchain
AttributeTypeDescription
namename

Name of the generated toolchain repo.

Default: "default_rust_toolchains"
versionstring

Rust version (e.g. 1.86.0 or nightly/2025-04-03)

Default: "1.92.0"
rustfmt_versionstring

Rustfmt version (e.g. 1.86.0 or nightly/2025-04-03)

Default: ""
rust_analyzer_versionstring

Rust-analyzer version (e.g. 1.86.0 or nightly/2025-04-03)

Default: ""
editionstring

Default edition to apply to toolchains.

Default: "2021"
extra_rustc_flagsdictionary: String → List of strings

Additional rustc flags by target triple.

Default: {}
extra_exec_rustc_flagsdictionary: String → List of strings

Additional rustc flags by exec triple.

Default: {}

@rules_rs//rs/toolchains:toolchain_utils.bzl

Shared helpers for toolchain generation.

Functions & Macros

sanitize_triple
Parameters
*triple_str
sanitize_version
Parameters
*version