rules_rsAPI docs @0.0.44

@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: []
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_experimental_platformsboolean

If true, use experimental rules_rs platforms. If false, use the stable rules_rust 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: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

Rules

rust_shared_library

Builds a Rust shared library.

This shared library will contain all transitively reachable crates and native objects.
It is meant to be used when producing an artifact that is then consumed by some other build system
(for example to produce a shared library that Python program links against).

This rule provides CcInfo, so it can be used everywhere Bazel expects rules_cc.

When building the whole binary in Bazel, use rust_library instead.

AttributeTypeDescription
*namename

A unique name for this target.

aliasesdictionary: Label → String

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: {}
alwayslinkboolean

If 1, any binary that depends (directly or indirectly) on this library
will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers.

Default: False
compile_datalist of labels

List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into
the library, such as via the
include_str!
macro.

Default: []
crate_featureslist of strings

List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")]
configuration option. The features listed here will be passed to rustc
with --cfg feature="${feature_name}" flags.

Default: []
crate_namestring

Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores.
Defaults to the target name, with any hyphens replaced by underscores.

Default: ""
crate_rootlabel

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

If crate_root is not set, then this rule will look for a lib.rs file (or main.rs for rust_binary)
or the single file in srcs if srcs contains only one file.

Default: None
datalist of labels

List of files used by this rule at compile time and runtime.

If including data at compile time with include_str!() and similar,
prefer compile_data over data, to prevent the data also being included
in the runfiles.

Default: []
depslist of labels

List of other libraries to be linked to this library target.

These can be either other rust_library targets or cc_library targets if
linking a native library.

Default: []
editionstring

The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain.

Default: ""
lint_configlabel

Set of lints to apply when building this crate.

Default: None
proc_macro_depslist of labels

Copy of deps in exec configuration. This should really be called exec_configured_deps.

Rule implementations use this to select exec-configured rust_proc_macro targets.
User code should pass all deps to deps for the macros loaded from defs.bzl.

Default: []
require_explicit_unstable_featuresinteger

Whether to require all unstable features to be explicitly opted in to using -Zallow-features=.... Possible values: [-1, 0, 1]. -1 means delegate to the toolchain.require_explicit_unstable_features boolean build setting; 0 means False; 1 means True.

Default: -1
rustc_envdictionary: String → String

Dictionary of additional "key": "value" environment variables to set for rustc.

rust_test()/rust_binary() rules can use $(rootpath //package:target) to pass in the
location of a generated file or external tool. Cargo build scripts that wish to
expand locations should use cargo_build_script()'s build_script_env argument instead,
as build scripts are run in a different environment - see cargo_build_script()'s
documentation for more.

Default: {}
rustc_env_fileslist of labels

Files containing additional environment variables to set for rustc.

These files should contain a single variable per line, of format
NAME=value, and newlines may be included in a value by ending a
line with a trailing back-slash (\\).

The order that these files will be processed is unspecified, so
multiple definitions of a particular variable are discouraged.

Note that the variables here are subject to
workspace status
stamping should the stamp attribute be enabled. Stamp variables
should be wrapped in brackets in order to be resolved. E.g.
NAME={WORKSPACE_STATUS_VARIABLE}.

Default: []
rustc_flagslist of strings

List of compiler flags passed to rustc.

These strings are subject to Make variable expansion for predefined
source/output path variables like $location, $execpath, and
$rootpath. This expansion is useful if you wish to pass a generated
file of arguments to rustc: @$(location //package:target).

Default: []
srcslist of labels

List of Rust .rs source files used to build the library.

If srcs contains more than one file, then there must be a file either
named lib.rs. Otherwise, crate_root must be set to the source file that
is the root of the crate to be passed to rustc to build this crate.

Default: []
stampinteger

Whether to encode build information into the Rustc action. Possible values:

  • stamp = 1: Always stamp the build information into the Rustc action, even in --nostamp builds. This setting should be avoided, since it potentially kills remote caching for the target and any downstream actions that depend on it.

  • stamp = 0: Always replace build information by constant values. This gives good build result caching.

  • stamp = -1: Embedding of build information is controlled by the --[no]stamp flag.

Stamped targets are not rebuilt unless their dependencies change.

For example if a rust_library is stamped, and a rust_binary depends on that library, the stamped
library won't be rebuilt when we change sources of the rust_binary. This is different from how
cc_library.linkstamps
behaves.

Default: 0
versionstring

A version to inject in the cargo environment variable.

Default: "0.0.0"
allocator_librarieslabel
Default: "@rules_rust//ffi/rs:default_allocator_libraries"
experimental_use_cc_common_linkinteger

Whether to use cc_common.link to link rust binaries. Possible values: [-1, 0, 1]. -1 means use the value of the toolchain.experimental_use_cc_common_link boolean build setting to determine. 0 means do not use cc_common.link (use rustc instead). 1 means use cc_common.link.

Default: -1
malloclabel

Override the default dependency on malloc.

By default, Rust binaries linked with cc_common.link are linked against
//rust/private/cc:malloc", which is an empty library and the resulting binary will use
libc's malloc. This label must refer to a cc_library rule.

Default: "@rules_rust//rust/private/cc:malloc"
platformlabel

Optional platform to transition the shared library to.

Default: None

@rules_rs//rs:rust_static_library.bzl

Rules

rust_static_library

Builds a Rust static library.

This static library will contain all transitively reachable crates and native objects.
It is meant to be used when producing an artifact that is then consumed by some other build system
(for example to produce an archive that Python program links against).

This rule provides CcInfo, so it can be used everywhere Bazel expects rules_cc.

When building the whole binary in Bazel, use rust_library instead.

AttributeTypeDescription
*namename

A unique name for this target.

aliasesdictionary: Label → String

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: {}
alwayslinkboolean

If 1, any binary that depends (directly or indirectly) on this library
will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers.

Default: False
compile_datalist of labels

List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into
the library, such as via the
include_str!
macro.

Default: []
crate_featureslist of strings

List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")]
configuration option. The features listed here will be passed to rustc
with --cfg feature="${feature_name}" flags.

Default: []
crate_namestring

Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores.
Defaults to the target name, with any hyphens replaced by underscores.

Default: ""
crate_rootlabel

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

If crate_root is not set, then this rule will look for a lib.rs file (or main.rs for rust_binary)
or the single file in srcs if srcs contains only one file.

Default: None
datalist of labels

List of files used by this rule at compile time and runtime.

If including data at compile time with include_str!() and similar,
prefer compile_data over data, to prevent the data also being included
in the runfiles.

Default: []
depslist of labels

List of other libraries to be linked to this library target.

These can be either other rust_library targets or cc_library targets if
linking a native library.

Default: []
editionstring

The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain.

Default: ""
lint_configlabel

Set of lints to apply when building this crate.

Default: None
proc_macro_depslist of labels

Copy of deps in exec configuration. This should really be called exec_configured_deps.

Rule implementations use this to select exec-configured rust_proc_macro targets.
User code should pass all deps to deps for the macros loaded from defs.bzl.

Default: []
require_explicit_unstable_featuresinteger

Whether to require all unstable features to be explicitly opted in to using -Zallow-features=.... Possible values: [-1, 0, 1]. -1 means delegate to the toolchain.require_explicit_unstable_features boolean build setting; 0 means False; 1 means True.

Default: -1
rustc_envdictionary: String → String

Dictionary of additional "key": "value" environment variables to set for rustc.

rust_test()/rust_binary() rules can use $(rootpath //package:target) to pass in the
location of a generated file or external tool. Cargo build scripts that wish to
expand locations should use cargo_build_script()'s build_script_env argument instead,
as build scripts are run in a different environment - see cargo_build_script()'s
documentation for more.

Default: {}
rustc_env_fileslist of labels

Files containing additional environment variables to set for rustc.

These files should contain a single variable per line, of format
NAME=value, and newlines may be included in a value by ending a
line with a trailing back-slash (\\).

The order that these files will be processed is unspecified, so
multiple definitions of a particular variable are discouraged.

Note that the variables here are subject to
workspace status
stamping should the stamp attribute be enabled. Stamp variables
should be wrapped in brackets in order to be resolved. E.g.
NAME={WORKSPACE_STATUS_VARIABLE}.

Default: []
rustc_flagslist of strings

List of compiler flags passed to rustc.

These strings are subject to Make variable expansion for predefined
source/output path variables like $location, $execpath, and
$rootpath. This expansion is useful if you wish to pass a generated
file of arguments to rustc: @$(location //package:target).

Default: []
srcslist of labels

List of Rust .rs source files used to build the library.

If srcs contains more than one file, then there must be a file either
named lib.rs. Otherwise, crate_root must be set to the source file that
is the root of the crate to be passed to rustc to build this crate.

Default: []
stampinteger

Whether to encode build information into the Rustc action. Possible values:

  • stamp = 1: Always stamp the build information into the Rustc action, even in --nostamp builds. This setting should be avoided, since it potentially kills remote caching for the target and any downstream actions that depend on it.

  • stamp = 0: Always replace build information by constant values. This gives good build result caching.

  • stamp = -1: Embedding of build information is controlled by the --[no]stamp flag.

Stamped targets are not rebuilt unless their dependencies change.

For example if a rust_library is stamped, and a rust_binary depends on that library, the stamped
library won't be rebuilt when we change sources of the rust_binary. This is different from how
cc_library.linkstamps
behaves.

Default: 0
versionstring

A version to inject in the cargo environment variable.

Default: "0.0.0"
allocator_librarieslabel
Default: "@rules_rust//ffi/rs:default_allocator_libraries"
platformlabel

Optional platform to transition the static library to.

Default: None

@rules_rs//rs:rust_test.bzl

@rules_rs//rs/experimental:rules_rust_prost.bzl

Module extension that provisions the rules_rust_prost repository.

Module Extensions

rules_rust_prost

@rules_rs//rs/experimental: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/experimental/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/experimental/platforms:triples.bzl

Functions & Macros

triple_to_constraint_set
Parameters
*target_triple

@rules_rs//rs/experimental/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/experimental/toolchains:declare_rustc_toolchains.bzl

Functions & Macros

declare_rustc_toolchains

Declare toolchains for all supported target platforms.

Parameters
*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"]
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/experimental/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/experimental/toolchains:module_extension.bzl

Module extension for configuring experimental 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: ""
editionstring

Default edition to apply to toolchains.

Default: "2021"

@rules_rs//rs/experimental/toolchains:toolchain_utils.bzl

Shared helpers for toolchain generation.

Functions & Macros

sanitize_triple
Parameters
*triple_str
sanitize_version
Parameters
*version