' that takes a single label parameter 'actual'. See '@crate_index//:alias_rules.bzl' for an example. | `"alias"` |
+| default_package_name | The default package name to use in the rendered macros. This affects the auto package detection of things like `all_crate_deps`. | `None` |
+| generate_target_compatible_with | Whether to generate `target_compatible_with` annotations on the generated BUILD files. This catches a `target_triple`being targeted that isn't declared in `supported_platform_triples`. | `True` |
+| platforms_template | The base template to use for platform names. See [platforms documentation](https://docs.bazel.build/versions/main/platforms.html). The available format keys are [`{triple}`]. | `"@rules_rust//rust/platform:{triple}"` |
| regen_command | An optional command to demonstrate how generated files should be regenerated. | `None` |
| vendor_mode | An optional configuration for rendirng content to be rendered into repositories. | `None` |
| generate_rules_license_metadata | Whether to generate rules license metedata | `False` |
@@ -869,10 +737,152 @@ Various settings used to configure Cargo manifest splicing behavior.
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
-| resolver_version | The [resolver version][rv] to use in generated Cargo manifests. This flag is **only** used when splicing a manifest from direct package definitions. See crates_repository::packages
. | `"2"` |
+| resolver_version | The [resolver version][rv] to use in generated Cargo manifests. This flag is **only** used when splicing a manifest from direct package definitions. See `crates_repository::packages`. | `"2"` |
**RETURNS**
str: A json encoded string of the parameters provided
+
+
+## crates_repository
+
+
+crates_repository(name , annotations , cargo_config , cargo_lockfile , generate_binaries ,
+ generate_build_scripts , generate_target_compatible_with , generator ,
+ generator_sha256s , generator_urls , isolated , lockfile , manifests , packages , quiet ,
+ render_config , repo_mapping , rust_toolchain_cargo_template ,
+ rust_toolchain_rustc_template , rust_version , splicing_config ,
+ supported_platform_triples )
+
+
+A rule for defining and downloading Rust dependencies (crates). This rule
+handles all the same [workflows](#workflows) `crate_universe` rules do.
+
+Environment Variables:
+
+| variable | usage |
+| --- | --- |
+| `CARGO_BAZEL_GENERATOR_SHA256` | The sha256 checksum of the file located at `CARGO_BAZEL_GENERATOR_URL` |
+| `CARGO_BAZEL_GENERATOR_URL` | The URL of a cargo-bazel binary. This variable takes precedence over attributes and can use `file://` for local paths |
+| `CARGO_BAZEL_ISOLATED` | An authorative flag as to whether or not the `CARGO_HOME` environment variable should be isolated from the host configuration |
+| `CARGO_BAZEL_REPIN` | An indicator that the dependencies represented by the rule should be regenerated. `REPIN` may also be used. See [Repinning / Updating Dependencies](#repinning--updating-dependencies) for more details. |
+| `CARGO_BAZEL_REPIN_ONLY` | A comma-delimited allowlist for rules to execute repinning. Can be useful if multiple instances of the repository rule are used in a Bazel workspace, but repinning should be limited to one of them. |
+
+Example:
+
+Given the following workspace structure:
+
+```text
+[workspace]/
+ WORKSPACE.bazel
+ BUILD.bazel
+ Cargo.toml
+ Cargo.Bazel.lock
+ src/
+ main.rs
+```
+
+The following is something that'd be found in the `WORKSPACE` file:
+
+```python
+load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "crate")
+
+crates_repository(
+ name = "crate_index",
+ annotations = {
+ "rand": [crate.annotation(
+ default_features = False,
+ features = ["small_rng"],
+ )],
+ },
+ cargo_lockfile = "//:Cargo.Bazel.lock",
+ lockfile = "//:cargo-bazel-lock.json",
+ manifests = ["//:Cargo.toml"],
+ # Should match the version represented by the currently registered `rust_toolchain`.
+ rust_version = "1.60.0",
+)
+```
+
+The above will create an external repository which contains aliases and macros for accessing
+Rust targets found in the dependency graph defined by the given manifests.
+
+**NOTE**: The `cargo_lockfile` and `lockfile` must be manually created. The rule unfortunately does not yet create
+it on its own. When initially setting up this rule, an empty file should be created and then
+populated by repinning dependencies.
+
+### Repinning / Updating Dependencies
+
+Dependency syncing and updating is done in the repository rule which means it's done during the
+analysis phase of builds. As mentioned in the environments variable table above, the `CARGO_BAZEL_REPIN`
+(or `REPIN`) environment variables can be used to force the rule to update dependencies and potentially
+render a new lockfile. Given an instance of this repository rule named `crate_index`, the easiest way to
+repin dependencies is to run:
+
+```shell
+CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index
+```
+
+This will result in all dependencies being updated for a project. The `CARGO_BAZEL_REPIN` environment variable
+can also be used to customize how dependencies are updated. The following table shows translations from environment
+variable values to the equivilant [cargo update](https://doc.rust-lang.org/cargo/commands/cargo-update.html) command
+that is called behind the scenes to update dependencies.
+
+| Value | Cargo command |
+| --- | --- |
+| Any of [`true`, `1`, `yes`, `on`, `workspace`] | `cargo update --workspace` |
+| Any of [`full`, `eager`, `all`] | `cargo update` |
+| `package_name` | `cargo upgrade --package package_name` |
+| `package_name@1.2.3` | `cargo upgrade --package package_name@1.2.3` |
+| `package_name@1.2.3=4.5.6` | `cargo upgrade --package package_name@1.2.3 --precise=4.5.6` |
+
+If the `crates_repository` is used multiple times in the same Bazel workspace (e.g. for multiple independent
+Rust workspaces), it may additionally be useful to use the `CARGO_BAZEL_REPIN_ONLY` environment variable, which
+limits execution of the repinning to one or multiple instances of the `crates_repository` rule via a comma-delimited
+allowlist:
+
+```shell
+CARGO_BAZEL_REPIN=1 CARGO_BAZEL_REPIN_ONLY=crate_index bazel sync --only=crate_index
+```
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| name | A unique name for this repository. | Name | required | |
+| annotations | Extra settings to apply to crates. See [crate.annotation](#crateannotation). | Dictionary: String -> List of strings | optional | `{}` |
+| cargo_config | A [Cargo configuration](https://doc.rust-lang.org/cargo/reference/config.html) file | Label | optional | `None` |
+| cargo_lockfile | The path used to store the `crates_repository` specific [Cargo.lock](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html) file. In the case that your `crates_repository` corresponds directly with an existing `Cargo.toml` file which has a paired `Cargo.lock` file, that `Cargo.lock` file should be used here, which will keep the versions used by cargo and bazel in sync. | Label | required | |
+| generate_binaries | Whether to generate `rust_binary` targets for all the binary crates in every package. By default only the `rust_library` targets are generated. | Boolean | optional | `False` |
+| generate_build_scripts | Whether or not to generate [cargo build scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html) by default. | Boolean | optional | `True` |
+| generate_target_compatible_with | DEPRECATED: Moved to `render_config`. | Boolean | optional | `True` |
+| generator | The absolute label of a generator. Eg. `@cargo_bazel_bootstrap//:cargo-bazel`. This is typically used when bootstrapping | String | optional | `""` |
+| generator_sha256s | Dictionary of `host_triple` -> `sha256` for a `cargo-bazel` binary. | Dictionary: String -> String | optional | `{}` |
+| generator_urls | URL template from which to download the `cargo-bazel` binary. `{host_triple}` and will be filled in according to the host platform. | Dictionary: String -> String | optional | `{}` |
+| isolated | If true, `CARGO_HOME` will be overwritten to a directory within the generated repository in order to prevent other uses of Cargo from impacting having any effect on the generated targets produced by this rule. For users who either have multiple `crate_repository` definitions in a WORKSPACE or rapidly re-pin dependencies, setting this to false may improve build times. This variable is also controled by `CARGO_BAZEL_ISOLATED` environment variable. | Boolean | optional | `True` |
+| lockfile | The path to a file to use for reproducible renderings. If set, this file must exist within the workspace (but can be empty) before this rule will work. | Label | optional | `None` |
+| manifests | A list of Cargo manifests (`Cargo.toml` files). | List of labels | optional | `[]` |
+| packages | A set of crates (packages) specifications to depend on. See [crate.spec](#crate.spec). | Dictionary: String -> String | optional | `{}` |
+| quiet | If stdout and stderr should not be printed to the terminal. | Boolean | optional | `True` |
+| render_config | The configuration flags to use for rendering. Use `//crate_universe:defs.bzl\%render_config` to generate the value for this field. If unset, the defaults defined there will be used. | String | optional | `""` |
+| repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository. For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`). This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | Dictionary: String -> String | optional | |
+| rust_toolchain_cargo_template | The template to use for finding the host `cargo` binary. `{version}` (eg. '1.53.0'), `{triple}` (eg. 'x86_64-unknown-linux-gnu'), `{arch}` (eg. 'aarch64'), `{vendor}` (eg. 'unknown'), `{system}` (eg. 'darwin'), `{cfg}` (eg. 'exec'), `{channel}` (eg. 'stable'), and `{tool}` (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | `"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"` |
+| rust_toolchain_rustc_template | The template to use for finding the host `rustc` binary. `{version}` (eg. '1.53.0'), `{triple}` (eg. 'x86_64-unknown-linux-gnu'), `{arch}` (eg. 'aarch64'), `{vendor}` (eg. 'unknown'), `{system}` (eg. 'darwin'), `{cfg}` (eg. 'exec'), `{channel}` (eg. 'stable'), and `{tool}` (eg. 'cargo.exe') will be replaced in the string if present. | String | optional | `"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"` |
+| rust_version | The version of Rust the currently registered toolchain is using. Eg. `1.56.0`, or `nightly/2021-09-08` | String | optional | `"1.79.0"` |
+| splicing_config | The configuration flags to use for splicing Cargo maniests. Use `//crate_universe:defs.bzl\%rsplicing_config` to generate the value for this field. If unset, the defaults defined there will be used. | String | optional | `""` |
+| supported_platform_triples | A set of all platform triples to consider when generating dependencies. | List of strings | optional | `["aarch64-unknown-linux-gnu", "aarch64-unknown-nixos-gnu", "i686-apple-darwin", "i686-pc-windows-msvc", "i686-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", "x86_64-unknown-nixos-gnu", "aarch64-apple-darwin", "aarch64-apple-ios-sim", "aarch64-apple-ios", "aarch64-fuchsia", "aarch64-linux-android", "aarch64-pc-windows-msvc", "arm-unknown-linux-gnueabi", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabi", "i686-linux-android", "i686-unknown-freebsd", "powerpc-unknown-linux-gnu", "riscv32imc-unknown-none-elf", "riscv64gc-unknown-none-elf", "s390x-unknown-linux-gnu", "thumbv7em-none-eabi", "thumbv8m.main-none-eabi", "wasm32-unknown-unknown", "wasm32-wasi", "x86_64-apple-ios", "x86_64-fuchsia", "x86_64-linux-android", "x86_64-unknown-freebsd", "x86_64-unknown-none", "aarch64-unknown-nto-qnx710"]` |
+
+**ENVIRONMENT VARIABLES**
+
+This repository rule depends on the following environment variables:
+* `CARGO_BAZEL_GENERATOR_URL`
+* `CARGO_BAZEL_GENERATOR_SHA256`
+* `CARGO_BAZEL_REPIN`
+* `REPIN`
+* `CARGO_BAZEL_REPIN_ONLY`
+* `CARGO_BAZEL_ISOLATED`
+* `CARGO_BAZEL_DEBUG`
+
+
diff --git a/docs/crate_universe_bzlmod.md b/docs/crate_universe_bzlmod.md
new file mode 100644
index 0000000000..32f65d3c5b
--- /dev/null
+++ b/docs/crate_universe_bzlmod.md
@@ -0,0 +1,142 @@
+
+
+# Crate Universe
+
+Crate Universe is a set of Bazel rule for generating Rust targets using Cargo.
+
+This doc describes using crate_universe with bzlmod.
+
+If you're using a WORKSPACE file, please see [the WORKSPACE equivalent of this doc](crate_universe.html).
+
+There are some examples of using crate_universe with bzlmod:
+
+* https://github.com/bazelbuild/rules_rust/blob/main/examples/bzlmod/hello_world/MODULE.bazel
+* https://github.com/bazelbuild/rules_rust/blob/main/examples/bzlmod/override_target/MODULE.bazel
+* https://github.com/bazelbuild/rules_rust/blob/main/examples/bzlmod/all_crate_deps/MODULE.bazel
+
+
+
+## crate
+
+
+crate = use_extension("@rules_rust//crate_universe:docs_bzlmod.bzl", "crate")
+crate.from_cargo(name , cargo_config , cargo_lockfile , generate_binaries , generate_build_scripts ,
+ manifests , supported_platform_triples )
+crate.annotation(deps , data , additive_build_file , additive_build_file_content , alias_rule ,
+ build_script_data , build_script_data_glob , build_script_deps , build_script_env ,
+ build_script_proc_macro_deps , build_script_rundir , build_script_rustc_env ,
+ build_script_toolchains , build_script_tools , compile_data , compile_data_glob , crate ,
+ crate_features , data_glob , disable_pipelining , extra_aliased_targets ,
+ gen_all_binaries , gen_binaries , gen_build_script , override_target_bin ,
+ override_target_build_script , override_target_lib , override_target_proc_macro ,
+ patch_args , patch_tool , patches , proc_macro_deps , repositories , rustc_env ,
+ rustc_env_files , rustc_flags , shallow_since , version )
+crate.from_specs(name , cargo_config , generate_binaries , generate_build_scripts ,
+ supported_platform_triples )
+crate.spec(artifact , branch , default_features , features , git , lib , package , rev , tag , version )
+
+
+
+**TAG CLASSES**
+
+
+
+### from_cargo
+
+Generates a repo @crates from a Cargo.toml / Cargo.lock pair
+
+**Attributes**
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| name | The name of the repo to generate | Name | optional | `"crates"` |
+| cargo_config | A [Cargo configuration](https://doc.rust-lang.org/cargo/reference/config.html) file. | Label | optional | `None` |
+| cargo_lockfile | The path to an existing `Cargo.lock` file | Label | optional | `None` |
+| generate_binaries | Whether to generate `rust_binary` targets for all the binary crates in every package. By default only the `rust_library` targets are generated. | Boolean | optional | `False` |
+| generate_build_scripts | Whether or not to generate [cargo build scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html) by default. | Boolean | optional | `True` |
+| manifests | A list of Cargo manifests (`Cargo.toml` files). | List of labels | optional | `[]` |
+| supported_platform_triples | A set of all platform triples to consider when generating dependencies. | List of strings | optional | `["aarch64-unknown-linux-gnu", "aarch64-unknown-nixos-gnu", "i686-apple-darwin", "i686-pc-windows-msvc", "i686-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", "x86_64-unknown-nixos-gnu", "aarch64-apple-darwin", "aarch64-apple-ios-sim", "aarch64-apple-ios", "aarch64-fuchsia", "aarch64-linux-android", "aarch64-pc-windows-msvc", "arm-unknown-linux-gnueabi", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabi", "i686-linux-android", "i686-unknown-freebsd", "powerpc-unknown-linux-gnu", "riscv32imc-unknown-none-elf", "riscv64gc-unknown-none-elf", "s390x-unknown-linux-gnu", "thumbv7em-none-eabi", "thumbv8m.main-none-eabi", "wasm32-unknown-unknown", "wasm32-wasi", "x86_64-apple-ios", "x86_64-fuchsia", "x86_64-linux-android", "x86_64-unknown-freebsd", "x86_64-unknown-none", "aarch64-unknown-nto-qnx710"]` |
+
+
+
+### annotation
+
+**Attributes**
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| deps | A list of labels to add to a crate's `rust_library::deps` attribute. | List of strings | optional | `[]` |
+| data | A list of labels to add to a crate's `rust_library::data` attribute. | List of strings | optional | `[]` |
+| additive_build_file | A file containing extra contents to write to the bottom of generated BUILD files. | Label | optional | `None` |
+| additive_build_file_content | Extra contents to write to the bottom of generated BUILD files. | String | optional | `""` |
+| alias_rule | Alias rule to use instead of `native.alias()`. Overrides [render_config](#render_config)'s 'default_alias_rule'. | String | optional | `""` |
+| build_script_data | A list of labels to add to a crate's `cargo_build_script::data` attribute. | List of strings | optional | `[]` |
+| build_script_data_glob | A list of glob patterns to add to a crate's `cargo_build_script::data` attribute | List of strings | optional | `[]` |
+| build_script_deps | A list of labels to add to a crate's `cargo_build_script::deps` attribute. | List of strings | optional | `[]` |
+| build_script_env | Additional environment variables to set on a crate's `cargo_build_script::env` attribute. | Dictionary: String -> String | optional | `{}` |
+| build_script_proc_macro_deps | A list of labels to add to a crate's `cargo_build_script::proc_macro_deps` attribute. | List of strings | optional | `[]` |
+| build_script_rundir | An override for the build script's rundir attribute. | String | optional | `""` |
+| build_script_rustc_env | Additional environment variables to set on a crate's `cargo_build_script::env` attribute. | Dictionary: String -> String | optional | `{}` |
+| build_script_toolchains | A list of labels to set on a crates's `cargo_build_script::toolchains` attribute. | List of labels | optional | `[]` |
+| build_script_tools | A list of labels to add to a crate's `cargo_build_script::tools` attribute. | List of strings | optional | `[]` |
+| compile_data | A list of labels to add to a crate's `rust_library::compile_data` attribute. | List of strings | optional | `[]` |
+| compile_data_glob | A list of glob patterns to add to a crate's `rust_library::compile_data` attribute. | List of strings | optional | `[]` |
+| crate | The name of the crate the annotation is applied to | String | required | |
+| crate_features | A list of strings to add to a crate's `rust_library::crate_features` attribute. | List of strings | optional | `[]` |
+| data_glob | A list of glob patterns to add to a crate's `rust_library::data` attribute. | List of strings | optional | `[]` |
+| disable_pipelining | If True, disables pipelining for library targets for this crate. | Boolean | optional | `False` |
+| extra_aliased_targets | A list of targets to add to the generated aliases in the root crate_universe repository. | Dictionary: String -> String | optional | `{}` |
+| gen_all_binaries | If true, generates `rust_binary` targets for all of the crates bins | Boolean | optional | `False` |
+| gen_binaries | As a list, the subset of the crate's bins that should get `rust_binary` targets produced. | List of strings | optional | `[]` |
+| gen_build_script | An authorative flag to determine whether or not to produce `cargo_build_script` targets for the current crate. Supported values are 'on', 'off', and 'auto'. | String | optional | `"auto"` |
+| override_target_bin | An optional alternate taget to use when something depends on this crate to allow the parent repo to provide its own version of this dependency. | Label | optional | `None` |
+| override_target_build_script | An optional alternate taget to use when something depends on this crate to allow the parent repo to provide its own version of this dependency. | Label | optional | `None` |
+| override_target_lib | An optional alternate taget to use when something depends on this crate to allow the parent repo to provide its own version of this dependency. | Label | optional | `None` |
+| override_target_proc_macro | An optional alternate taget to use when something depends on this crate to allow the parent repo to provide its own version of this dependency. | Label | optional | `None` |
+| patch_args | The `patch_args` attribute of a Bazel repository rule. See [http_archive.patch_args](https://docs.bazel.build/versions/main/repo/http.html#http_archive-patch_args) | List of strings | optional | `[]` |
+| patch_tool | The `patch_tool` attribute of a Bazel repository rule. See [http_archive.patch_tool](https://docs.bazel.build/versions/main/repo/http.html#http_archive-patch_tool) | String | optional | `""` |
+| patches | The `patches` attribute of a Bazel repository rule. See [http_archive.patches](https://docs.bazel.build/versions/main/repo/http.html#http_archive-patches) | List of labels | optional | `[]` |
+| proc_macro_deps | A list of labels to add to a crate's `rust_library::proc_macro_deps` attribute. | List of strings | optional | `[]` |
+| repositories | A list of repository names specified from `crate.from_cargo(name=...)` that this annotation is applied to. Defaults to all repositories. | List of strings | optional | `[]` |
+| rustc_env | Additional variables to set on a crate's `rust_library::rustc_env` attribute. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | A list of labels to set on a crate's `rust_library::rustc_env_files` attribute. | List of strings | optional | `[]` |
+| rustc_flags | A list of strings to set on a crate's `rust_library::rustc_flags` attribute. | List of strings | optional | `[]` |
+| shallow_since | An optional timestamp used for crates originating from a git repository instead of a crate registry. This flag optimizes fetching the source code. | String | optional | `""` |
+| version | The versions of the crate the annotation is applied to. Defaults to all versions. | String | optional | `"*"` |
+
+
+
+### from_specs
+
+Generates a repo @crates from the defined `spec` tags
+
+**Attributes**
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| name | The name of the repo to generate | Name | optional | `"crates"` |
+| cargo_config | A [Cargo configuration](https://doc.rust-lang.org/cargo/reference/config.html) file. | Label | optional | `None` |
+| generate_binaries | Whether to generate `rust_binary` targets for all the binary crates in every package. By default only the `rust_library` targets are generated. | Boolean | optional | `False` |
+| generate_build_scripts | Whether or not to generate [cargo build scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html) by default. | Boolean | optional | `True` |
+| supported_platform_triples | A set of all platform triples to consider when generating dependencies. | List of strings | optional | `["aarch64-unknown-linux-gnu", "aarch64-unknown-nixos-gnu", "i686-apple-darwin", "i686-pc-windows-msvc", "i686-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", "x86_64-unknown-nixos-gnu", "aarch64-apple-darwin", "aarch64-apple-ios-sim", "aarch64-apple-ios", "aarch64-fuchsia", "aarch64-linux-android", "aarch64-pc-windows-msvc", "arm-unknown-linux-gnueabi", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabi", "i686-linux-android", "i686-unknown-freebsd", "powerpc-unknown-linux-gnu", "riscv32imc-unknown-none-elf", "riscv64gc-unknown-none-elf", "s390x-unknown-linux-gnu", "thumbv7em-none-eabi", "thumbv8m.main-none-eabi", "wasm32-unknown-unknown", "wasm32-wasi", "x86_64-apple-ios", "x86_64-fuchsia", "x86_64-linux-android", "x86_64-unknown-freebsd", "x86_64-unknown-none", "aarch64-unknown-nto-qnx710"]` |
+
+
+
+### spec
+
+**Attributes**
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| artifact | Set to 'bin' to pull in a binary crate as an artifact dependency. Requires a nightly Cargo. | String | optional | `""` |
+| branch | The git branch of the remote crate. Tied with the `git` param. Only one of branch, tag or rev may be specified. Specifying `rev` is recommended for fully-reproducible builds. | String | optional | `""` |
+| default_features | Maps to the `default-features` flag. | Boolean | optional | `True` |
+| features | A list of features to use for the crate. | List of strings | optional | `[]` |
+| git | The Git url to use for the crate. Cannot be used with `version`. | String | optional | `""` |
+| lib | If using `artifact = 'bin'`, additionally setting `lib = True` declares a dependency on both the package's library and binary, as opposed to just the binary. | Boolean | optional | `False` |
+| package | The explicit name of the package. | String | required | |
+| rev | The git revision of the remote crate. Tied with the `git` param. Only one of branch, tag or rev may be specified. | String | optional | `""` |
+| tag | The git tag of the remote crate. Tied with the `git` param. Only one of branch, tag or rev may be specified. Specifying `rev` is recommended for fully-reproducible builds. | String | optional | `""` |
+| version | The exact version of the crate. Cannot be used with `git`. | String | optional | `""` |
+
+
diff --git a/docs/defs.md b/docs/defs.md
index 90fee223d0..6cadad94bf 100644
--- a/docs/defs.md
+++ b/docs/defs.md
@@ -91,9 +91,10 @@ Add additional rustc_flags from the command line with `--@rules_rust//:extra_rus
## rust_binary
-rust_binary(name , aliases , compile_data , crate_features , crate_name , crate_root , crate_type , data ,
- deps , edition , env , experimental_use_cc_common_link , linker_script , malloc , out_binary ,
- platform , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , srcs , stamp , version )
+rust_binary(name , deps , srcs , data , aliases , compile_data , crate_features , crate_name , crate_root ,
+ crate_type , edition , env , experimental_use_cc_common_link , linker_script , malloc ,
+ out_binary , platform , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , stamp ,
+ version )
Builds a Rust binary crate.
@@ -124,7 +125,7 @@ pub struct Greeter {
}
impl Greeter {
- pub fn new(greeting: &str) -> Greeter {
+ pub fn new(greeting: &str) -> Greeter {
Greeter { greeting: greeting.to_string(), }
}
@@ -189,28 +190,28 @@ is available under the key `dsym_folder` in `OutputGroupInfo`.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| crate_type | Crate type that will be passed to rustc
to be used for building this crate. This option is a temporary workaround and should be used only when building for WebAssembly targets (//rust/platform:wasi and //rust/platform:wasm). | String | optional | "bin"
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| env | Specifies additional environment variables to set when the target is executed by bazel run. Values are subject to $(rootpath)
, $(execpath)
, location, and ["Make variable"](https://docs.bazel.build/versions/master/be/make-variables.html) substitution. Execpath returns absolute path, and in order to be able to construct the absolute path we need to wrap the test binary in a launcher. Using a launcher comes with complications, such as more complicated debugger attachment. | Dictionary: String -> String | optional | {}
|
-| experimental_use_cc_common_link | 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. | Integer | optional | -1
|
-| linker_script | Link script to forward into linker via rustc options. | Label | optional | None
|
-| malloc | Override the default dependency on malloc
. By default, Rust binaries linked with cc_common.link are linked against @bazel_tools//tools/cpp:malloc"
, which is an empty library and the resulting binary will use libc's malloc
. This label must refer to a cc_library
rule. | Label | optional | @bazel_tools//tools/cpp:malloc
|
-| out_binary | Force a target, regardless of it's crate_type
, to always mark the file as executable. This attribute is only used to support wasm targets but is expected to be removed following a resolution to https://github.com/bazelbuild/rules_rust/issues/771. | Boolean | optional | False
|
-| platform | Optional platform to transition the binary to. | Label | optional | None
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | -1
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| crate_type | Crate type that will be passed to `rustc` to be used for building this crate. This option is a temporary workaround and should be used only when building for WebAssembly targets (//rust/platform:wasi and //rust/platform:wasm). | String | optional | `"bin"` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| env | Specifies additional environment variables to set when the target is executed by bazel run. Values are subject to `$(rootpath)`, `$(execpath)`, location, and ["Make variable"](https://docs.bazel.build/versions/master/be/make-variables.html) substitution. Execpath returns absolute path, and in order to be able to construct the absolute path we need to wrap the test binary in a launcher. Using a launcher comes with complications, such as more complicated debugger attachment. | Dictionary: String -> String | optional | `{}` |
+| experimental_use_cc_common_link | 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. | Integer | optional | `-1` |
+| linker_script | Link script to forward into linker via rustc options. | Label | optional | `None` |
+| malloc | Override the default dependency on `malloc`. By default, Rust binaries linked with cc_common.link are linked against `@bazel_tools//tools/cpp:malloc"`, which is an empty library and the resulting binary will use libc's `malloc`. This label must refer to a `cc_library` rule. | Label | optional | `"@bazel_tools//tools/cpp:malloc"` |
+| out_binary | Force a target, regardless of it's `crate_type`, to always mark the file as executable. This attribute is only used to support wasm targets but is expected to be removed following a resolution to https://github.com/bazelbuild/rules_rust/issues/771. | Boolean | optional | `False` |
+| platform | Optional platform to transition the binary to. | Label | optional | `None` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `-1` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -218,9 +219,9 @@ is available under the key `dsym_folder` in `OutputGroupInfo`.
## rust_library
-rust_library(name , aliases , compile_data , crate_features , crate_name , crate_root , data , deps ,
+rust_library(name , deps , srcs , data , aliases , compile_data , crate_features , crate_name , crate_root ,
disable_pipelining , edition , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags ,
- srcs , stamp , version )
+ stamp , version )
Builds a Rust library crate.
@@ -246,7 +247,7 @@ pub struct Greeter {
}
impl Greeter {
- pub fn new(greeting: &str) -> Greeter {
+ pub fn new(greeting: &str) -> Greeter {
Greeter { greeting: greeting.to_string(), }
}
@@ -286,29 +287,28 @@ bazel-bin/examples/rust/hello_lib/libhello_lib.rlib
INFO: Elapsed time: 1.245s, Critical Path: 1.01s
```
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| disable_pipelining | Disables pipelining for this rule if it is globally enabled. This will cause this rule to not produce a .rmeta
file and all the dependent crates will instead use the .rlib
file. | Boolean | optional | False
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | 0
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| disable_pipelining | Disables pipelining for this rule if it is globally enabled. This will cause this rule to not produce a `.rmeta` file and all the dependent crates will instead use the `.rlib` file. | Boolean | optional | `False` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `0` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -352,14 +352,13 @@ rust_library(
)
```
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| deps | Other dependencies to forward through this crate group. | List of labels | optional | []
|
+| deps | Other dependencies to forward through this crate group. | List of labels | optional | `[]` |
@@ -367,35 +366,34 @@ rust_library(
## rust_proc_macro
-rust_proc_macro(name , aliases , compile_data , crate_features , crate_name , crate_root , data , deps ,
- edition , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , srcs , stamp ,
+rust_proc_macro(name , deps , srcs , data , aliases , compile_data , crate_features , crate_name ,
+ crate_root , edition , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , stamp ,
version )
Builds a Rust proc-macro crate.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | 0
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `0` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -403,9 +401,9 @@ Builds a Rust proc-macro crate.
## rust_shared_library
-rust_shared_library(name , aliases , compile_data , crate_features , crate_name , crate_root , data , deps ,
- edition , experimental_use_cc_common_link , malloc , platform , proc_macro_deps ,
- rustc_env , rustc_env_files , rustc_flags , srcs , stamp , version )
+rust_shared_library(name , deps , srcs , data , aliases , compile_data , crate_features , crate_name ,
+ crate_root , edition , experimental_use_cc_common_link , malloc , platform ,
+ proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , stamp , version )
Builds a Rust shared library.
@@ -418,31 +416,30 @@ 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.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| experimental_use_cc_common_link | 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. | Integer | optional | -1
|
-| malloc | Override the default dependency on malloc
. By default, Rust binaries linked with cc_common.link are linked against @bazel_tools//tools/cpp:malloc"
, which is an empty library and the resulting binary will use libc's malloc
. This label must refer to a cc_library
rule. | Label | optional | @bazel_tools//tools/cpp:malloc
|
-| platform | Optional platform to transition the shared library to. | Label | optional | None
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | 0
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| experimental_use_cc_common_link | 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. | Integer | optional | `-1` |
+| malloc | Override the default dependency on `malloc`. By default, Rust binaries linked with cc_common.link are linked against `@bazel_tools//tools/cpp:malloc"`, which is an empty library and the resulting binary will use libc's `malloc`. This label must refer to a `cc_library` rule. | Label | optional | `"@bazel_tools//tools/cpp:malloc"` |
+| platform | Optional platform to transition the shared library to. | Label | optional | `None` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `0` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -450,9 +447,9 @@ When building the whole binary in Bazel, use `rust_library` instead.
## rust_static_library
-rust_static_library(name , aliases , compile_data , crate_features , crate_name , crate_root , data , deps ,
- edition , platform , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , srcs ,
- stamp , version )
+rust_static_library(name , deps , srcs , data , aliases , compile_data , crate_features , crate_name ,
+ crate_root , edition , platform , proc_macro_deps , rustc_env , rustc_env_files ,
+ rustc_flags , stamp , version )
Builds a Rust static library.
@@ -465,29 +462,28 @@ 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.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| platform | Optional platform to transition the static library to. | Label | optional | None
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | 0
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| platform | Optional platform to transition the static library to. | Label | optional | `None` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `0` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -495,9 +491,10 @@ When building the whole binary in Bazel, use `rust_library` instead.
## rust_test
-rust_test(name , aliases , compile_data , crate , crate_features , crate_name , crate_root , data , deps ,
- edition , env , experimental_use_cc_common_link , malloc , platform , proc_macro_deps , rustc_env ,
- rustc_env_files , rustc_flags , srcs , stamp , use_libtest_harness , version )
+rust_test(name , deps , srcs , data , aliases , compile_data , crate , crate_features , crate_name ,
+ crate_root , edition , env , experimental_use_cc_common_link , malloc , platform ,
+ proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , stamp , use_libtest_harness ,
+ version )
Builds a Rust test crate.
@@ -522,11 +519,11 @@ pub struct Greeter {
}
impl Greeter {
- pub fn new(greeting: &str) -> Greeter {
+ pub fn new(greeting: &str) -> Greeter {
Greeter { greeting: greeting.to_string(), }
}
- pub fn greet(&self, thing: &str) -> String {
+ pub fn greet(&self, thing: &str) -> String {
format!("{} {}", &self.greeting, thing)
}
}
@@ -625,27 +622,27 @@ Run the test with `bazel test //hello_lib:greeting_test`.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate | Target inline tests declared in the given crate These tests are typically those that would be held out under #[cfg(test)]
declarations. | Label | optional | None
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| env | Specifies additional environment variables to set when the test is executed by bazel test. Values are subject to $(rootpath)
, $(execpath)
, location, and ["Make variable"](https://docs.bazel.build/versions/master/be/make-variables.html) substitution. | Dictionary: String -> String | optional | {}
|
-| experimental_use_cc_common_link | 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. | Integer | optional | -1
|
-| malloc | Override the default dependency on malloc
. By default, Rust binaries linked with cc_common.link are linked against @bazel_tools//tools/cpp:malloc"
, which is an empty library and the resulting binary will use libc's malloc
. This label must refer to a cc_library
rule. | Label | optional | @bazel_tools//tools/cpp:malloc
|
-| platform | Optional platform to transition the test to. | Label | optional | None
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | 0
|
-| use_libtest_harness | Whether to use libtest
. For targets using this flag, individual tests can be run by using the [--test_arg](https://docs.bazel.build/versions/4.0.0/command-line-reference.html#flag--test_arg) flag. E.g. bazel test //src:rust_test --test_arg=foo::test::test_fn
. | Boolean | optional | True
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate | Target inline tests declared in the given crate These tests are typically those that would be held out under `#[cfg(test)]` declarations. | Label | optional | `None` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| env | Specifies additional environment variables to set when the test is executed by bazel test. Values are subject to `$(rootpath)`, `$(execpath)`, location, and ["Make variable"](https://docs.bazel.build/versions/master/be/make-variables.html) substitution. | Dictionary: String -> String | optional | `{}` |
+| experimental_use_cc_common_link | 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. | Integer | optional | `-1` |
+| malloc | Override the default dependency on `malloc`. By default, Rust binaries linked with cc_common.link are linked against `@bazel_tools//tools/cpp:malloc"`, which is an empty library and the resulting binary will use libc's `malloc`. This label must refer to a `cc_library` rule. | Label | optional | `"@bazel_tools//tools/cpp:malloc"` |
+| platform | Optional platform to transition the test to. | Label | optional | `None` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `0` |
+| use_libtest_harness | Whether to use `libtest`. For targets using this flag, individual tests can be run by using the [--test_arg](https://docs.bazel.build/versions/4.0.0/command-line-reference.html#flag--test_arg) flag. E.g. `bazel test //src:rust_test --test_arg=foo::test::test_fn`. | Boolean | optional | `True` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -707,8 +704,8 @@ rust_test_suite(
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
-| name | The name of the test_suite
. | none |
-| srcs | All test sources, typically glob(["tests/**/*.rs"])
. | none |
-| kwargs | Additional keyword arguments for the underyling [rust_test](#rust_test) targets. The tags
argument is also passed to the generated test_suite
target. | none |
+| name | The name of the `test_suite`. | none |
+| srcs | All test sources, typically `glob(["tests/**/*.rs"])`. | none |
+| kwargs | Additional keyword arguments for the underyling [rust_test](#rust_test) targets. The `tags` argument is also passed to the generated `test_suite` target. | none |
diff --git a/docs/flatten.md b/docs/flatten.md
index 153dc6e286..334b507086 100644
--- a/docs/flatten.md
+++ b/docs/flatten.md
@@ -80,44 +80,12 @@ Control whether to print clippy output or store it to a file, using the configur
| name | A unique name for this target. | Name | required | |
-
-
-## cargo_bootstrap_repository
-
-
-cargo_bootstrap_repository(name , binary , build_mode , cargo_lockfile , cargo_toml , env , env_label ,
- repo_mapping , rust_toolchain_cargo_template , rust_toolchain_rustc_template ,
- srcs , timeout , version )
-
-
-A rule for bootstrapping a Rust binary using [Cargo](https://doc.rust-lang.org/cargo/)
-
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this repository. | Name | required | |
-| binary | The binary to build (the --bin
parameter for Cargo). If left empty, the repository name will be used. | String | optional | ""
|
-| build_mode | The build mode the binary should be built with | String | optional | "release"
|
-| cargo_lockfile | The lockfile of the crate_universe resolver | Label | required | |
-| cargo_toml | The path of the crate_universe resolver manifest (Cargo.toml
file) | Label | required | |
-| env | A mapping of platform triple to a set of environment variables. See [cargo_env](#cargo_env) for usage details. Additionally, the platform triple *
applies to all platforms. | Dictionary: String -> String | optional | {}
|
-| env_label | A mapping of platform triple to a set of environment variables. This attribute differs from env
in that all variables passed here must be fully qualified labels of files. See [cargo_env](#cargo_env) for usage details. Additionally, the platform triple *
applies to all platforms. | Dictionary: String -> String | optional | {}
|
-| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar"
declares that, for any time this repository depends on @foo
(such as a dependency on @foo//some:target
, it should actually resolve that dependency within globally-declared @bar
(@bar//some:target
). | Dictionary: String -> String | required | |
-| rust_toolchain_cargo_template | The template to use for finding the host cargo
binary. {version}
(eg. '1.53.0'), {triple}
(eg. 'x86_64-unknown-linux-gnu'), {arch}
(eg. 'aarch64'), {vendor}
(eg. 'unknown'), {system}
(eg. 'darwin'), {channel}
(eg. 'stable'), and {tool}
(eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"
|
-| rust_toolchain_rustc_template | The template to use for finding the host rustc
binary. {version}
(eg. '1.53.0'), {triple}
(eg. 'x86_64-unknown-linux-gnu'), {arch}
(eg. 'aarch64'), {vendor}
(eg. 'unknown'), {system}
(eg. 'darwin'), {channel}
(eg. 'stable'), and {tool}
(eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"
|
-| srcs | Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made | List of labels | optional | []
|
-| timeout | Maximum duration of the Cargo build command in seconds | Integer | optional | 600
|
-| version | The version of Rust the currently registered toolchain is using. Eg. 1.56.0
, or nightly/2021-09-08
| String | optional | "1.79.0"
|
-
-
## cargo_dep_env
-cargo_dep_env(name , out_dir , src )
+cargo_dep_env(name , src , out_dir )
A rule for generating variables for dependent `cargo_build_script`s without a build script. This is useful for using Bazel rules instead of a build script, while also generating configuration information for build scripts which depend on this crate.
@@ -128,8 +96,8 @@ A rule for generating variables for dependent `cargo_build_script`s without a bu
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| out_dir | Folder containing additional inputs when building all direct dependencies. This has the same effect as a cargo_build_script
which prints puts files into $OUT_DIR
, but without requiring a build script. | Label | optional | None
|
-| src | File containing additional environment variables to set for build scripts of direct dependencies. This has the same effect as a cargo_build_script
which prints cargo:VAR=VALUE
lines, but without requiring a build script. This 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 (\\
). | Label | required | |
+| src | File containing additional environment variables to set for build scripts of direct dependencies. This has the same effect as a `cargo_build_script` which prints `cargo:VAR=VALUE` lines, but without requiring a build script. This 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 (`\\`). | Label | required | |
+| out_dir | Folder containing additional inputs when building all direct dependencies. This has the same effect as a `cargo_build_script` which prints puts files into `$OUT_DIR`, but without requiring a build script. | Label | optional | `None` |
@@ -221,8 +189,8 @@ A toolchain for [rust-analyzer](https://rust-analyzer.github.io/).
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| proc_macro_srv | The path to a rust_analyzer_proc_macro_srv
binary. | Label | optional | None
|
-| rustc | The path to a rustc
binary. | Label | required | |
+| proc_macro_srv | The path to a `rust_analyzer_proc_macro_srv` binary. | Label | optional | `None` |
+| rustc | The path to a `rustc` binary. | Label | required | |
| rustc_srcs | The source code of rustc. | Label | required | |
@@ -231,9 +199,10 @@ A toolchain for [rust-analyzer](https://rust-analyzer.github.io/).
## rust_binary
-rust_binary(name , aliases , compile_data , crate_features , crate_name , crate_root , crate_type , data ,
- deps , edition , env , experimental_use_cc_common_link , linker_script , malloc , out_binary ,
- platform , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , srcs , stamp , version )
+rust_binary(name , deps , srcs , data , aliases , compile_data , crate_features , crate_name , crate_root ,
+ crate_type , edition , env , experimental_use_cc_common_link , linker_script , malloc ,
+ out_binary , platform , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , stamp ,
+ version )
Builds a Rust binary crate.
@@ -264,7 +233,7 @@ pub struct Greeter {
}
impl Greeter {
- pub fn new(greeting: &str) -> Greeter {
+ pub fn new(greeting: &str) -> Greeter {
Greeter { greeting: greeting.to_string(), }
}
@@ -329,28 +298,28 @@ is available under the key `dsym_folder` in `OutputGroupInfo`.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| crate_type | Crate type that will be passed to rustc
to be used for building this crate. This option is a temporary workaround and should be used only when building for WebAssembly targets (//rust/platform:wasi and //rust/platform:wasm). | String | optional | "bin"
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| env | Specifies additional environment variables to set when the target is executed by bazel run. Values are subject to $(rootpath)
, $(execpath)
, location, and ["Make variable"](https://docs.bazel.build/versions/master/be/make-variables.html) substitution. Execpath returns absolute path, and in order to be able to construct the absolute path we need to wrap the test binary in a launcher. Using a launcher comes with complications, such as more complicated debugger attachment. | Dictionary: String -> String | optional | {}
|
-| experimental_use_cc_common_link | 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. | Integer | optional | -1
|
-| linker_script | Link script to forward into linker via rustc options. | Label | optional | None
|
-| malloc | Override the default dependency on malloc
. By default, Rust binaries linked with cc_common.link are linked against @bazel_tools//tools/cpp:malloc"
, which is an empty library and the resulting binary will use libc's malloc
. This label must refer to a cc_library
rule. | Label | optional | @bazel_tools//tools/cpp:malloc
|
-| out_binary | Force a target, regardless of it's crate_type
, to always mark the file as executable. This attribute is only used to support wasm targets but is expected to be removed following a resolution to https://github.com/bazelbuild/rules_rust/issues/771. | Boolean | optional | False
|
-| platform | Optional platform to transition the binary to. | Label | optional | None
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | -1
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| crate_type | Crate type that will be passed to `rustc` to be used for building this crate. This option is a temporary workaround and should be used only when building for WebAssembly targets (//rust/platform:wasi and //rust/platform:wasm). | String | optional | `"bin"` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| env | Specifies additional environment variables to set when the target is executed by bazel run. Values are subject to `$(rootpath)`, `$(execpath)`, location, and ["Make variable"](https://docs.bazel.build/versions/master/be/make-variables.html) substitution. Execpath returns absolute path, and in order to be able to construct the absolute path we need to wrap the test binary in a launcher. Using a launcher comes with complications, such as more complicated debugger attachment. | Dictionary: String -> String | optional | `{}` |
+| experimental_use_cc_common_link | 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. | Integer | optional | `-1` |
+| linker_script | Link script to forward into linker via rustc options. | Label | optional | `None` |
+| malloc | Override the default dependency on `malloc`. By default, Rust binaries linked with cc_common.link are linked against `@bazel_tools//tools/cpp:malloc"`, which is an empty library and the resulting binary will use libc's `malloc`. This label must refer to a `cc_library` rule. | Label | optional | `"@bazel_tools//tools/cpp:malloc"` |
+| out_binary | Force a target, regardless of it's `crate_type`, to always mark the file as executable. This attribute is only used to support wasm targets but is expected to be removed following a resolution to https://github.com/bazelbuild/rules_rust/issues/771. | Boolean | optional | `False` |
+| platform | Optional platform to transition the binary to. | Label | optional | `None` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `-1` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -369,10 +338,10 @@ Generates a rust source file from a cc_library and a header.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| bindgen_flags | Flags to pass directly to the bindgen executable. See https://rust-lang.github.io/rust-bindgen/ for details. | List of strings | optional | []
|
-| cc_lib | The cc_library that contains the .h
file. This is used to find the transitive includes. | Label | required | |
-| clang_flags | Flags to pass directly to the clang executable. | List of strings | optional | []
|
-| header | The .h
file to generate bindings for. | Label | required | |
+| bindgen_flags | Flags to pass directly to the bindgen executable. See https://rust-lang.github.io/rust-bindgen/ for details. | List of strings | optional | `[]` |
+| cc_lib | The cc_library that contains the `.h` file. This is used to find the transitive includes. | Label | required | |
+| clang_flags | Flags to pass directly to the clang executable. | List of strings | optional | `[]` |
+| header | The `.h` file to generate bindings for. | Label | required | |
@@ -385,7 +354,7 @@ rust_bindgen_toolchain(name , name | A unique name for this target. | Name | required | |
-| bindgen | The label of a bindgen
executable. | Label | optional | None
|
-| clang | The label of a clang
executable. | Label | optional | None
|
-| default_rustfmt | If set, rust_bindgen
targets will always format generated sources with rustfmt
. | Boolean | optional | True
|
-| libclang | A cc_library that provides bindgen's runtime dependency on libclang. | Label | optional | None
|
-| libstdcxx | A cc_library that satisfies libclang's libstdc++ dependency. This is used to make the execution of clang hermetic. If None, system libraries will be used instead. | Label | optional | None
|
+| bindgen | The label of a `bindgen` executable. | Label | optional | `None` |
+| clang | The label of a `clang` executable. | Label | optional | `None` |
+| default_rustfmt | If set, `rust_bindgen` targets will always format generated sources with `rustfmt`. | Boolean | optional | `True` |
+| libclang | A cc_library that provides bindgen's runtime dependency on libclang. | Label | optional | `None` |
+| libstdcxx | A cc_library that satisfies libclang's libstdc++ dependency. This is used to make the execution of clang hermetic. If None, system libraries will be used instead. | Label | optional | `None` |
@@ -468,14 +436,13 @@ rust_clippy(
)
```
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| deps | Rust targets to run clippy on. | List of labels | optional | []
|
+| deps | Rust targets to run clippy on. | List of labels | optional | `[]` |
@@ -523,20 +490,19 @@ rust_doc(
Running `bazel build //hello_lib:hello_lib_doc` will build a zip file containing the documentation for the `hello_lib` library crate generated by `rustdoc`.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| crate | The label of the target to generate code documentation for.rust_doc
can generate HTML code documentation for the source files of rust_library
or rust_binary
targets. | Label | required | |
-| html_after_content | File to add in <body>
, after content. | Label | optional | None
|
-| html_before_content | File to add in <body>
, before content. | Label | optional | None
|
-| html_in_header | File to add to <head>
. | Label | optional | None
|
-| markdown_css | CSS files to include via <link>
in a rendered Markdown file. | List of labels | optional | []
|
-| rustc_flags | **Deprecated**: use rustdoc_flags
instead | List of strings | optional | []
|
-| rustdoc_flags | List of flags passed to rustdoc
. 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)
. | List of strings | optional | []
|
+| crate | The label of the target to generate code documentation for. `rust_doc` can generate HTML code documentation for the source files of `rust_library` or `rust_binary` targets. | Label | required | |
+| html_after_content | File to add in ``, after content. | Label | optional | `None` |
+| html_before_content | File to add in ``, before content. | Label | optional | `None` |
+| html_in_header | File to add to ``. | Label | optional | `None` |
+| markdown_css | CSS files to include via ` ` in a rendered Markdown file. | List of labels | optional | `[]` |
+| rustc_flags | **Deprecated**: use `rustdoc_flags` instead | List of strings | optional | `[]` |
+| rustdoc_flags | List of flags passed to `rustdoc`. 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)`. | List of strings | optional | `[]` |
@@ -544,7 +510,7 @@ Running `bazel build //hello_lib:hello_lib_doc` will build a zip file containing
## rust_doc_test
-rust_doc_test(name , crate , deps )
+rust_doc_test(name , deps , crate )
Runs Rust documentation tests.
@@ -584,15 +550,14 @@ rust_doc_test(
Running `bazel test //hello_lib:hello_lib_doc_test` will run all documentation tests for the `hello_lib` library crate.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| crate | The label of the target to generate code documentation for. rust_doc_test
can generate HTML code documentation for the source files of rust_library
or rust_binary
targets. | Label | required | |
-| deps | 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. | List of labels | optional | []
|
+| deps | 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. | List of labels | optional | `[]` |
+| crate | The label of the target to generate code documentation for. `rust_doc_test` can generate HTML code documentation for the source files of `rust_library` or `rust_binary` targets. | Label | required | |
@@ -600,7 +565,7 @@ Running `bazel test //hello_lib:hello_lib_doc_test` will run all documentation t
## rust_grpc_library
-rust_grpc_library(name , crate_name , deps , rust_deps , rustc_flags )
+rust_grpc_library(name , deps , crate_name , rust_deps , rustc_flags )
Builds a Rust library crate from a set of `proto_library`s suitable for gRPC.
@@ -627,17 +592,16 @@ rust_binary(
)
```
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| crate_name | 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. | String | optional | ""
|
| deps | List of proto_library dependencies that will be built. One crate for each proto_library will be created with the corresponding gRPC stubs. | List of labels | required | |
-| rust_deps | The crates the generated library depends on. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
+| crate_name | 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. | String | optional | `""` |
+| rust_deps | The crates the generated library depends on. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
@@ -645,9 +609,9 @@ rust_binary(
## rust_library
-rust_library(name , aliases , compile_data , crate_features , crate_name , crate_root , data , deps ,
+rust_library(name , deps , srcs , data , aliases , compile_data , crate_features , crate_name , crate_root ,
disable_pipelining , edition , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags ,
- srcs , stamp , version )
+ stamp , version )
Builds a Rust library crate.
@@ -673,7 +637,7 @@ pub struct Greeter {
}
impl Greeter {
- pub fn new(greeting: &str) -> Greeter {
+ pub fn new(greeting: &str) -> Greeter {
Greeter { greeting: greeting.to_string(), }
}
@@ -713,29 +677,28 @@ bazel-bin/examples/rust/hello_lib/libhello_lib.rlib
INFO: Elapsed time: 1.245s, Critical Path: 1.01s
```
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| disable_pipelining | Disables pipelining for this rule if it is globally enabled. This will cause this rule to not produce a .rmeta
file and all the dependent crates will instead use the .rlib
file. | Boolean | optional | False
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | 0
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| disable_pipelining | Disables pipelining for this rule if it is globally enabled. This will cause this rule to not produce a `.rmeta` file and all the dependent crates will instead use the `.rlib` file. | Boolean | optional | `False` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `0` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -779,14 +742,13 @@ rust_library(
)
```
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| deps | Other dependencies to forward through this crate group. | List of labels | optional | []
|
+| deps | Other dependencies to forward through this crate group. | List of labels | optional | `[]` |
@@ -794,35 +756,34 @@ rust_library(
## rust_proc_macro
-rust_proc_macro(name , aliases , compile_data , crate_features , crate_name , crate_root , data , deps ,
- edition , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , srcs , stamp ,
+rust_proc_macro(name , deps , srcs , data , aliases , compile_data , crate_features , crate_name ,
+ crate_root , edition , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , stamp ,
version )
Builds a Rust proc-macro crate.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | 0
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `0` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -842,16 +803,16 @@ Rust Prost toolchain rule.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| prost_opts | Additional options to add to Prost. | List of strings | optional | []
|
+| prost_opts | Additional options to add to Prost. | List of strings | optional | `[]` |
| prost_plugin | Additional plugins to add to Prost. | Label | required | |
-| prost_plugin_flag | Prost plugin flag format. (e.g. --plugin=protoc-gen-prost=%s
) | String | optional | "--plugin=protoc-gen-prost=%s"
|
+| prost_plugin_flag | Prost plugin flag format. (e.g. `--plugin=protoc-gen-prost=%s`) | String | optional | `"--plugin=protoc-gen-prost=%s"` |
| prost_runtime | The Prost runtime crates to use. | Label | required | |
| prost_types | The Prost types crates to use. | Label | required | |
| proto_compiler | The protoc compiler to use. | Label | required | |
-| tonic_opts | Additional options to add to Tonic. | List of strings | optional | []
|
-| tonic_plugin | Additional plugins to add to Tonic. | Label | optional | None
|
-| tonic_plugin_flag | Tonic plugin flag format. (e.g. --plugin=protoc-gen-tonic=%s
)) | String | optional | "--plugin=protoc-gen-tonic=%s"
|
-| tonic_runtime | The Tonic runtime crates to use. | Label | optional | None
|
+| tonic_opts | Additional options to add to Tonic. | List of strings | optional | `[]` |
+| tonic_plugin | Additional plugins to add to Tonic. | Label | optional | `None` |
+| tonic_plugin_flag | Tonic plugin flag format. (e.g. `--plugin=protoc-gen-tonic=%s`)) | String | optional | `"--plugin=protoc-gen-tonic=%s"` |
+| tonic_runtime | The Tonic runtime crates to use. | Label | optional | `None` |
@@ -859,7 +820,7 @@ Rust Prost toolchain rule.
## rust_proto_library
-rust_proto_library(name , crate_name , deps , rust_deps , rustc_flags )
+rust_proto_library(name , deps , crate_name , rust_deps , rustc_flags )
Builds a Rust library crate from a set of `proto_library`s.
@@ -886,17 +847,16 @@ rust_binary(
)
```
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| crate_name | 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. | String | optional | ""
|
| deps | List of proto_library dependencies that will be built. One crate for each proto_library will be created with the corresponding stubs. | List of labels | required | |
-| rust_deps | The crates the generated library depends on. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
+| crate_name | 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. | String | optional | `""` |
+| rust_deps | The crates the generated library depends on. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
@@ -904,9 +864,9 @@ rust_binary(
## rust_shared_library
-rust_shared_library(name , aliases , compile_data , crate_features , crate_name , crate_root , data , deps ,
- edition , experimental_use_cc_common_link , malloc , platform , proc_macro_deps ,
- rustc_env , rustc_env_files , rustc_flags , srcs , stamp , version )
+rust_shared_library(name , deps , srcs , data , aliases , compile_data , crate_features , crate_name ,
+ crate_root , edition , experimental_use_cc_common_link , malloc , platform ,
+ proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , stamp , version )
Builds a Rust shared library.
@@ -919,31 +879,30 @@ 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.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| experimental_use_cc_common_link | 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. | Integer | optional | -1
|
-| malloc | Override the default dependency on malloc
. By default, Rust binaries linked with cc_common.link are linked against @bazel_tools//tools/cpp:malloc"
, which is an empty library and the resulting binary will use libc's malloc
. This label must refer to a cc_library
rule. | Label | optional | @bazel_tools//tools/cpp:malloc
|
-| platform | Optional platform to transition the shared library to. | Label | optional | None
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | 0
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| experimental_use_cc_common_link | 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. | Integer | optional | `-1` |
+| malloc | Override the default dependency on `malloc`. By default, Rust binaries linked with cc_common.link are linked against `@bazel_tools//tools/cpp:malloc"`, which is an empty library and the resulting binary will use libc's `malloc`. This label must refer to a `cc_library` rule. | Label | optional | `"@bazel_tools//tools/cpp:malloc"` |
+| platform | Optional platform to transition the shared library to. | Label | optional | `None` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `0` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -951,9 +910,9 @@ When building the whole binary in Bazel, use `rust_library` instead.
## rust_static_library
-rust_static_library(name , aliases , compile_data , crate_features , crate_name , crate_root , data , deps ,
- edition , platform , proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , srcs ,
- stamp , version )
+rust_static_library(name , deps , srcs , data , aliases , compile_data , crate_features , crate_name ,
+ crate_root , edition , platform , proc_macro_deps , rustc_env , rustc_env_files ,
+ rustc_flags , stamp , version )
Builds a Rust static library.
@@ -966,29 +925,28 @@ 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.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| platform | Optional platform to transition the static library to. | Label | optional | None
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | 0
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| platform | Optional platform to transition the static library to. | Label | optional | `None` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `0` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -1015,9 +973,10 @@ A dedicated filegroup-like rule for Rust stdlib artifacts.
## rust_test
-rust_test(name , aliases , compile_data , crate , crate_features , crate_name , crate_root , data , deps ,
- edition , env , experimental_use_cc_common_link , malloc , platform , proc_macro_deps , rustc_env ,
- rustc_env_files , rustc_flags , srcs , stamp , use_libtest_harness , version )
+rust_test(name , deps , srcs , data , aliases , compile_data , crate , crate_features , crate_name ,
+ crate_root , edition , env , experimental_use_cc_common_link , malloc , platform ,
+ proc_macro_deps , rustc_env , rustc_env_files , rustc_flags , stamp , use_libtest_harness ,
+ version )
Builds a Rust test crate.
@@ -1042,11 +1001,11 @@ pub struct Greeter {
}
impl Greeter {
- pub fn new(greeting: &str) -> Greeter {
+ pub fn new(greeting: &str) -> Greeter {
Greeter { greeting: greeting.to_string(), }
}
- pub fn greet(&self, thing: &str) -> String {
+ pub fn greet(&self, thing: &str) -> String {
format!("{} {}", &self.greeting, thing)
}
}
@@ -1145,27 +1104,27 @@ Run the test with `bazel test //hello_lib:greeting_test`.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| 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. | Dictionary: Label -> String | optional | {}
|
-| compile_data | 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!
](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | []
|
-| crate | Target inline tests declared in the given crate These tests are typically those that would be held out under #[cfg(test)]
declarations. | Label | optional | None
|
-| crate_features | 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. | List of strings | optional | []
|
-| crate_name | 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. | String | optional | ""
|
-| crate_root | 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. | Label | optional | None
|
-| data | 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. | List of labels | optional | []
|
-| deps | 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. | List of labels | optional | []
|
-| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | ""
|
-| env | Specifies additional environment variables to set when the test is executed by bazel test. Values are subject to $(rootpath)
, $(execpath)
, location, and ["Make variable"](https://docs.bazel.build/versions/master/be/make-variables.html) substitution. | Dictionary: String -> String | optional | {}
|
-| experimental_use_cc_common_link | 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. | Integer | optional | -1
|
-| malloc | Override the default dependency on malloc
. By default, Rust binaries linked with cc_common.link are linked against @bazel_tools//tools/cpp:malloc"
, which is an empty library and the resulting binary will use libc's malloc
. This label must refer to a cc_library
rule. | Label | optional | @bazel_tools//tools/cpp:malloc
|
-| platform | Optional platform to transition the test to. | Label | optional | None
|
-| proc_macro_deps | List of rust_proc_macro
targets used to help build this library target. | List of labels | optional | []
|
-| rustc_env | 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. | Dictionary: String -> String | optional | {}
|
-| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}
. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
-| srcs | 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. | List of labels | optional | []
|
-| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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
](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | 0
|
-| use_libtest_harness | Whether to use libtest
. For targets using this flag, individual tests can be run by using the [--test_arg](https://docs.bazel.build/versions/4.0.0/command-line-reference.html#flag--test_arg) flag. E.g. bazel test //src:rust_test --test_arg=foo::test::test_fn
. | Boolean | optional | True
|
-| version | A version to inject in the cargo environment variable. | String | optional | "0.0.0"
|
+| deps | 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. | List of labels | optional | `[]` |
+| srcs | 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. | List of labels | optional | `[]` |
+| data | 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. | List of labels | optional | `[]` |
+| 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. | Dictionary: Label -> String | optional | `{}` |
+| compile_data | 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!`](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | `[]` |
+| crate | Target inline tests declared in the given crate These tests are typically those that would be held out under `#[cfg(test)]` declarations. | Label | optional | `None` |
+| crate_features | 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. | List of strings | optional | `[]` |
+| crate_name | 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. | String | optional | `""` |
+| crate_root | 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. | Label | optional | `None` |
+| edition | The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain. | String | optional | `""` |
+| env | Specifies additional environment variables to set when the test is executed by bazel test. Values are subject to `$(rootpath)`, `$(execpath)`, location, and ["Make variable"](https://docs.bazel.build/versions/master/be/make-variables.html) substitution. | Dictionary: String -> String | optional | `{}` |
+| experimental_use_cc_common_link | 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. | Integer | optional | `-1` |
+| malloc | Override the default dependency on `malloc`. By default, Rust binaries linked with cc_common.link are linked against `@bazel_tools//tools/cpp:malloc"`, which is an empty library and the resulting binary will use libc's `malloc`. This label must refer to a `cc_library` rule. | Label | optional | `"@bazel_tools//tools/cpp:malloc"` |
+| platform | Optional platform to transition the test to. | Label | optional | `None` |
+| proc_macro_deps | List of `rust_proc_macro` targets used to help build this library target. | List of labels | optional | `[]` |
+| rustc_env | 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. | Dictionary: String -> String | optional | `{}` |
+| rustc_env_files | 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](https://docs.bazel.build/versions/main/user-manual.html#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}`. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
+| stamp | 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](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) 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](https://docs.bazel.build/versions/main/user-manual.html#flag--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`](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | `0` |
+| use_libtest_harness | Whether to use `libtest`. For targets using this flag, individual tests can be run by using the [--test_arg](https://docs.bazel.build/versions/4.0.0/command-line-reference.html#flag--test_arg) flag. E.g. `bazel test //src:rust_test --test_arg=foo::test::test_fn`. | Boolean | optional | `True` |
+| version | A version to inject in the cargo environment variable. | String | optional | `"0.0.0"` |
@@ -1224,109 +1183,42 @@ Then, either add the label of the toolchain rule to `register_toolchains` in the
See `@rules_rust//rust:repositories.bzl` for examples of defining the `@rust_cpuX` repository with the actual binaries and libraries.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | Label | optional | @rules_rust//ffi/cc/allocator_library
|
+| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | Label | optional | `"@rules_rust//ffi/cc/allocator_library"` |
| binary_ext | The extension for binaries created from rustc. | String | required | |
-| cargo | The location of the cargo
binary. Can be a direct source or a filegroup containing one item. | Label | optional | None
|
-| clippy_driver | The location of the clippy-driver
binary. Can be a direct source or a filegroup containing one item. | Label | optional | None
|
-| debug_info | Rustc debug info levels per opt level | Dictionary: String -> String | optional | {"dbg": "2", "fastbuild": "0", "opt": "0"}
|
-| default_edition | The edition to use for rust_* rules that don't specify an edition. If absent, every rule is required to specify its edition
attribute. | String | optional | ""
|
+| cargo | The location of the `cargo` binary. Can be a direct source or a filegroup containing one item. | Label | optional | `None` |
+| clippy_driver | The location of the `clippy-driver` binary. Can be a direct source or a filegroup containing one item. | Label | optional | `None` |
+| debug_info | Rustc debug info levels per opt level | Dictionary: String -> String | optional | `{"dbg": "2", "fastbuild": "0", "opt": "0"}` |
+| default_edition | The edition to use for rust_* rules that don't specify an edition. If absent, every rule is required to specify its `edition` attribute. | String | optional | `""` |
| dylib_ext | The extension for dynamic libraries created from rustc. | String | required | |
-| env | Environment variables to set in actions. | Dictionary: String -> String | optional | {}
|
+| env | Environment variables to set in actions. | Dictionary: String -> String | optional | `{}` |
| exec_triple | The platform triple for the toolchains execution environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations | String | required | |
-| experimental_link_std_dylib | Label to a boolean build setting that controls whether whether to link libstd dynamically. | Label | optional | @rules_rust//rust/settings:experimental_link_std_dylib
|
-| experimental_use_cc_common_link | Label to a boolean build setting that controls whether cc_common.link is used to link rust binaries. | Label | optional | //rust/settings:experimental_use_cc_common_link
|
-| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | []
|
-| extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | []
|
-| extra_rustc_flags_for_crate_types | Extra flags to pass to rustc based on crate type | Dictionary: String -> List of strings | optional | {}
|
-| global_allocator_library | Target that provides allocator functions for when a global allocator is present. | Label | optional | @rules_rust//ffi/cc/global_allocator_library
|
-| llvm_cov | The location of the llvm-cov
binary. Can be a direct source or a filegroup containing one item. If None, rust code is not instrumented for coverage. | Label | optional | None
|
-| llvm_profdata | The location of the llvm-profdata
binary. Can be a direct source or a filegroup containing one item. If llvm_cov
is None, this can be None as well and rust code is not instrumented for coverage. | Label | optional | None
|
-| llvm_tools | LLVM tools that are shipped with the Rust toolchain. | Label | optional | None
|
-| opt_level | Rustc optimization levels. | Dictionary: String -> String | optional | {"dbg": "0", "fastbuild": "0", "opt": "3"}
|
-| per_crate_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | []
|
-| rust_doc | The location of the rustdoc
binary. Can be a direct source or a filegroup containing one item. | Label | required | |
+| experimental_link_std_dylib | Label to a boolean build setting that controls whether whether to link libstd dynamically. | Label | optional | `"@rules_rust//rust/settings:experimental_link_std_dylib"` |
+| experimental_use_cc_common_link | Label to a boolean build setting that controls whether cc_common.link is used to link rust binaries. | Label | optional | `"@rules_rust//rust/settings:experimental_use_cc_common_link"` |
+| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | `[]` |
+| extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | `[]` |
+| extra_rustc_flags_for_crate_types | Extra flags to pass to rustc based on crate type | Dictionary: String -> List of strings | optional | `{}` |
+| global_allocator_library | Target that provides allocator functions for when a global allocator is present. | Label | optional | `"@rules_rust//ffi/cc/global_allocator_library"` |
+| llvm_cov | The location of the `llvm-cov` binary. Can be a direct source or a filegroup containing one item. If None, rust code is not instrumented for coverage. | Label | optional | `None` |
+| llvm_profdata | The location of the `llvm-profdata` binary. Can be a direct source or a filegroup containing one item. If `llvm_cov` is None, this can be None as well and rust code is not instrumented for coverage. | Label | optional | `None` |
+| llvm_tools | LLVM tools that are shipped with the Rust toolchain. | Label | optional | `None` |
+| opt_level | Rustc optimization levels. | Dictionary: String -> String | optional | `{"dbg": "0", "fastbuild": "0", "opt": "3"}` |
+| per_crate_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | `[]` |
+| rust_doc | The location of the `rustdoc` binary. Can be a direct source or a filegroup containing one item. | Label | required | |
| rust_std | The Rust standard library. | Label | required | |
-| rustc | The location of the rustc
binary. Can be a direct source or a filegroup containing one item. | Label | required | |
-| rustc_lib | The libraries used by rustc during compilation. | Label | optional | None
|
-| rustfmt | **Deprecated**: Instead see [rustfmt_toolchain](#rustfmt_toolchain) | Label | optional | None
|
+| rustc | The location of the `rustc` binary. Can be a direct source or a filegroup containing one item. | Label | required | |
+| rustc_lib | The libraries used by rustc during compilation. | Label | optional | `None` |
+| rustfmt | **Deprecated**: Instead see [rustfmt_toolchain](#rustfmt_toolchain) | Label | optional | `None` |
| staticlib_ext | The extension for static libraries created from rustc. | String | required | |
-| stdlib_linkflags | Additional linker flags to use when Rust standard library is linked by a C++ linker (rustc will deal with these automatically). Subject to location expansion with respect to the srcs of the rust_std
attribute. | List of strings | required | |
-| strip_level | Rustc strip levels. For all potential options, see https://doc.rust-lang.org/rustc/codegen-options/index.html#strip | Dictionary: String -> String | optional | {"dbg": "none", "fastbuild": "none", "opt": "debuginfo"}
|
-| target_json | Override the target_triple with a custom target specification. For more details see: https://doc.rust-lang.org/rustc/targets/custom.html | String | optional | ""
|
-| target_triple | The platform triple for the toolchains target environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations | String | optional | ""
|
-
-
-
-
-## rust_toolchain_repository_proxy
-
-
-rust_toolchain_repository_proxy(name , exec_compatible_with , repo_mapping , target_compatible_with ,
- target_settings , toolchain , toolchain_type )
-
-
-Generates a toolchain-bearing repository that declares the toolchains from some other rust_toolchain_repository.
-
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this repository. | Name | required | |
-| exec_compatible_with | A list of constraints for the execution platform for this toolchain. | List of strings | optional | []
|
-| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar"
declares that, for any time this repository depends on @foo
(such as a dependency on @foo//some:target
, it should actually resolve that dependency within globally-declared @bar
(@bar//some:target
). | Dictionary: String -> String | required | |
-| target_compatible_with | A list of constraints for the target platform for this toolchain. | List of strings | optional | []
|
-| target_settings | A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution. | List of strings | optional | []
|
-| toolchain | The name of the toolchain implementation target. | String | required | |
-| toolchain_type | The toolchain type of the toolchain to declare | String | required | |
-
-
-
-
-## rust_toolchain_tools_repository
-
-
-rust_toolchain_tools_repository(name , allocator_library , auth , auth_patterns , dev_components ,
- edition , exec_triple , extra_exec_rustc_flags , extra_rustc_flags ,
- global_allocator_library , iso_date , netrc , opt_level , repo_mapping ,
- rustfmt_version , sha256s , target_triple , urls , version )
-
-
-Composes a single workspace containing the toolchain components for compiling on a given platform to a series of target platforms.
-
-A given instance of this rule should be accompanied by a toolchain_repository_proxy invocation to declare its toolchains to Bazel; the indirection allows separating toolchain selection from toolchain fetching.
-
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this repository. | Name | required | |
-| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | String | optional | "@rules_rust//ffi/cc/allocator_library"
|
-| auth | Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details. | Dictionary: String -> String | optional | {}
|
-| auth_patterns | A list of patterns to match against urls for which the auth object should be used. | List of strings | optional | []
|
-| dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | False
|
-| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its edition
attribute. | String | optional | ""
|
-| exec_triple | The Rust-style target that this compiler runs on | String | required | |
-| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | []
|
-| extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | []
|
-| global_allocator_library | Target that provides allocator functions when a global allocator is used with cc_common.link. | String | optional | "@rules_rust//ffi/cc/global_allocator_library"
|
-| iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | ""
|
-| netrc | .netrc file to use for authentication; mirrors the eponymous attribute from http_archive | String | optional | ""
|
-| opt_level | Rustc optimization levels. For more details see the documentation for rust_toolchain.opt_level
. | Dictionary: String -> String | optional | {}
|
-| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar"
declares that, for any time this repository depends on @foo
(such as a dependency on @foo//some:target
, it should actually resolve that dependency within globally-declared @bar
(@bar//some:target
). | Dictionary: String -> String | required | |
-| rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | ""
|
-| sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_register_toolchains](#rust_register_toolchains) for more details. | Dictionary: String -> String | optional | {}
|
-| target_triple | The Rust-style target that this compiler builds for. | String | required | |
-| urls | 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). | List of strings | optional | ["https://static.rust-lang.org/dist/{}.tar.xz"]
|
-| version | The version of the tool among "nightly", "beta", or an exact version. | String | required | |
+| stdlib_linkflags | Additional linker flags to use when Rust standard library is linked by a C++ linker (rustc will deal with these automatically). Subject to location expansion with respect to the srcs of the `rust_std` attribute. | List of strings | required | |
+| strip_level | Rustc strip levels. For all potential options, see https://doc.rust-lang.org/rustc/codegen-options/index.html#strip | Dictionary: String -> String | optional | `{"dbg": "none", "fastbuild": "none", "opt": "debuginfo"}` |
+| target_json | Override the target_triple with a custom target specification. For more details see: https://doc.rust-lang.org/rustc/targets/custom.html | String | optional | `""` |
+| target_triple | The platform triple for the toolchains target environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations | String | optional | `""` |
@@ -1343,16 +1235,15 @@ Generates javascript and typescript bindings for a webassembly module using [was
An example of this rule in use can be seen at [@rules_rust//examples/wasm](../examples/wasm)
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| bindgen_flags | Flags to pass directly to the bindgen executable. See https://github.com/rustwasm/wasm-bindgen/ for details. | List of strings | optional | []
|
-| target | The type of output to generate. See https://rustwasm.github.io/wasm-bindgen/reference/deployment.html for details. | String | optional | "bundler"
|
-| wasm_file | The .wasm
file or crate to generate bindings for. | Label | required | |
+| bindgen_flags | Flags to pass directly to the bindgen executable. See https://github.com/rustwasm/wasm-bindgen/ for details. | List of strings | optional | `[]` |
+| target | The type of output to generate. See https://rustwasm.github.io/wasm-bindgen/reference/deployment.html for details. | String | optional | `"bundler"` |
+| wasm_file | The `.wasm` file or crate to generate bindings for. | Label | required | |
@@ -1393,14 +1284,13 @@ For additional information, see the [Bazel toolchains documentation][toolchains]
[toolchains]: https://docs.bazel.build/versions/master/toolchains.html
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| bindgen | The label of a wasm-bindgen-cli
executable. | Label | optional | None
|
+| bindgen | The label of a `wasm-bindgen-cli` executable. | Label | optional | `None` |
@@ -1419,7 +1309,7 @@ A test rule for performing `rustfmt --check` on a set of targets
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| targets | Rust targets to run rustfmt --check
on. | List of labels | optional | []
|
+| targets | Rust targets to run `rustfmt --check` on. | List of labels | optional | `[]` |
@@ -1438,9 +1328,9 @@ A toolchain for [rustfmt](https://rust-lang.github.io/rustfmt/)
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| rustc | The location of the rustc
binary. Can be a direct source or a filegroup containing one item. | Label | optional | None
|
-| rustc_lib | The libraries used by rustc during compilation. | Label | optional | None
|
-| rustfmt | The location of the rustfmt
binary. Can be a direct source or a filegroup containing one item. | Label | required | |
+| rustc | The location of the `rustc` binary. Can be a direct source or a filegroup containing one item. | Label | optional | `None` |
+| rustc_lib | The libraries used by rustc during compilation. | Label | optional | `None` |
+| rustfmt | The location of the `rustfmt` binary. Can be a direct source or a filegroup containing one item. | Label | required | |
@@ -1473,14 +1363,14 @@ A provider containing general Crate information.
| owner | Label: The label of the target that produced this CrateInfo |
| proc_macro_deps | depset[DepVariantInfo]: This crate's rust proc_macro dependencies' providers. |
| root | File: The source File entrypoint to this crate, eg. lib.rs |
-| rustc_env | Dict[String, String]: Additional "key": "value"
environment variables to set for rustc. |
+| rustc_env | Dict[String, String]: Additional `"key": "value"` environment variables to set for rustc. |
| rustc_env_files | [File]: Files containing additional environment variables to set for rustc. |
| rustc_output | File: The output from rustc from producing the output file. It is optional. |
| rustc_rmeta_output | File: The rmeta file produced for this crate. It is optional. |
| srcs | depset[File]: All source Files that are part of the crate. |
| std_dylib | File: libstd.so file |
| type | str: The type of this crate (see [rustc --crate-type](https://doc.rust-lang.org/rustc/command-line-arguments.html#--crate-type-a-list-of-types-of-crates-for-the-compiler-to-emit)). |
-| wrapped_crate_type | str, optional: The original crate type for targets generated using a previously defined crate (typically tests using the rust_test::crate
attribute) |
+| wrapped_crate_type | str, optional: The original crate type for targets generated using a previously defined crate (typically tests using the `rust_test::crate` attribute) |
@@ -1527,9 +1417,9 @@ Info about wasm-bindgen outputs.
| Name | Description |
| :------------- | :------------- |
-| js | Depset[File]: The Javascript files produced by wasm-bindgen
. |
-| ts | Depset[File]: The Typescript files produced by wasm-bindgen
. |
-| wasm | File: The .wasm
file generated by wasm-bindgen
. |
+| js | Depset[File]: The Javascript files produced by `wasm-bindgen`. |
+| ts | Depset[File]: The Typescript files produced by `wasm-bindgen`. |
+| wasm | File: The `.wasm` file generated by `wasm-bindgen`. |
@@ -1549,19 +1439,19 @@ A collection of files either found within the `rust-stdlib` artifact or generate
| Name | Description |
| :------------- | :------------- |
-| alloc_files | List[File]: .a
files related to the alloc
module. |
-| between_alloc_and_core_files | List[File]: .a
files related to the compiler_builtins
module. |
-| between_core_and_std_files | List[File]: .a
files related to all modules except adler
, alloc
, compiler_builtins
, core
, and std
. |
-| core_files | List[File]: .a
files related to the core
and adler
modules |
-| dot_a_files | Depset[File]: Generated .a
files |
-| memchr_files | Depset[File]: .a
files associated with the memchr
module. |
-| panic_files | Depset[File]: .a
files associated with panic_unwind
and panic_abort
. |
-| self_contained_files | List[File]: All .o
files from the self-contained
directory. |
-| srcs | List[Target]: All targets from the original srcs
attribute. |
+| alloc_files | List[File]: `.a` files related to the `alloc` module. |
+| between_alloc_and_core_files | List[File]: `.a` files related to the `compiler_builtins` module. |
+| between_core_and_std_files | List[File]: `.a` files related to all modules except `adler`, `alloc`, `compiler_builtins`, `core`, and `std`. |
+| core_files | List[File]: `.a` files related to the `core` and `adler` modules |
+| dot_a_files | Depset[File]: Generated `.a` files |
+| memchr_files | Depset[File]: `.a` files associated with the `memchr` module. |
+| panic_files | Depset[File]: `.a` files associated with `panic_unwind` and `panic_abort`. |
+| self_contained_files | List[File]: All `.o` files from the `self-contained` directory. |
+| srcs | List[Target]: All targets from the original `srcs` attribute. |
| std_dylib | File: libstd.so file |
-| std_files | Depset[File]: .a
files associated with the std
module. |
-| std_rlibs | List[File]: All .rlib
files |
-| test_files | Depset[File]: .a
files associated with the test
module. |
+| std_files | Depset[File]: `.a` files associated with the `std` module. |
+| std_rlibs | List[File]: All `.rlib` files |
+| test_files | Depset[File]: `.a` files associated with the `test` module. |
@@ -1638,7 +1528,7 @@ The `hello_lib` target will be build with the flags and the environment variable
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
-| 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
. | none |
+| 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`. | none |
| edition | The rust edition to use for the internal binary crate. | `None` |
| crate_name | Crate name to use for build script. | `None` |
| crate_root | The file that will be passed to rustc to be used for building this crate. | `None` |
@@ -1653,15 +1543,15 @@ The `hello_lib` target will be build with the flags and the environment variable
| compile_data | Files needed for the compilation of the build script. | `[]` |
| tools | Tools (executables) needed by the build script. | `[]` |
| links | Name of the native library this crate links against. | `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. | `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. | `None` |
| rustc_env | Environment variables to set in rustc when compiling the build script. | `{}` |
| rustc_env_files | Files containing additional environment variables to set for rustc when building the build script. | `[]` |
-| rustc_flags | List of compiler flags passed to rustc
. | `[]` |
+| rustc_flags | List of compiler flags passed to `rustc`. | `[]` |
| visibility | Visibility to apply to the generated build script output. | `None` |
| tags | (list of str, optional): Tags to apply to the generated build script output. | `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. | `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. | `None` |
| pkg_name | Override the package name used for the build script. This is useful if the build target name gets too long otherwise. | `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_scirpt_run
target. | 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_scirpt_run` target. | none |
@@ -1794,9 +1684,9 @@ Arguments are the same as `rust_bindgen`, and `kwargs` are passed directly to ru
| header | The label of the .h file to generate bindings for. | none |
| cc_lib | The label of the cc_library that contains the .h file. This is used to find the transitive includes. | none |
| bindgen_flags | Flags to pass directly to the bindgen executable. See https://rust-lang.github.io/rust-bindgen/ for details. | `None` |
-| bindgen_features | The features
attribute for the rust_bindgen
target. | `None` |
+| bindgen_features | The `features` attribute for the `rust_bindgen` target. | `None` |
| clang_flags | Flags to pass directly to the clang executable. | `None` |
-| kwargs | Arguments to forward to the underlying rust_library
rule. | none |
+| kwargs | Arguments to forward to the underlying `rust_library` rule. | none |
@@ -1859,7 +1749,7 @@ A rule for generating a Rust library using Prost.
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| name | The name of the target. | none |
-| kwargs | Additional keyword arguments for the underlying rust_prost_library
rule. | none |
+| kwargs | Additional keyword arguments for the underlying `rust_prost_library` rule. | none |
@@ -1960,20 +1850,20 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | `False` |
-| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every target is required to specify its edition
attribute. | `None` |
+| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every target is required to specify its `edition` attribute. | `None` |
| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | `None` |
| global_allocator_library | Target that provides allocator functions when global allocator is used with cc_common.link. | `None` |
-| iso_date | **Deprecated**: Use versions
instead. | `None` |
-| register_toolchains | If true, repositories will be generated to produce and register rust_toolchain
targets. | `True` |
-| rustfmt_version | The version of rustfmt. If none is supplied and only a single version in versions
is given, then this defaults to that version, otherwise will default to the default nightly version. | `None` |
+| iso_date | **Deprecated**: Use `versions` instead. | `None` |
+| register_toolchains | If true, repositories will be generated to produce and register `rust_toolchain` targets. | `True` |
+| rustfmt_version | The version of rustfmt. If none is supplied and only a single version in `versions` is given, then this defaults to that version, otherwise will default to the default nightly version. | `None` |
| rust_analyzer_version | The version of Rustc to pair with rust-analyzer. | `None` |
| sha256s | A dict associating tool subdirectories to sha256 hashes. | `None` |
| extra_target_triples | Additional rust-style targets that rust toolchains should support. | `["wasm32-unknown-unknown", "wasm32-wasi"]` |
| extra_rustc_flags | Dictionary of target triples to list of extra flags to pass to rustc in non-exec configuration. | `None` |
| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration. | `None` |
| urls | 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). | `["https://static.rust-lang.org/dist/{}.tar.xz"]` |
-| version | **Deprecated**: Use versions
instead. | `None` |
-| versions | A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. ["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]
. | `[]` |
+| version | **Deprecated**: Use `versions` instead. | `None` |
+| versions | A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. `["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]`. | `[]` |
@@ -1991,7 +1881,7 @@ rust_repositories(kwargs )
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
-| kwargs | Keyword arguments for the rust_register_toolchains
macro. | none |
+| kwargs | Keyword arguments for the `rust_register_toolchains` macro. | none |
@@ -2017,13 +1907,13 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
| exec_triple | The Rust-style target that this compiler runs on | none |
| target_settings | A list of config_settings that must be satisfied by the target configuration in order for this set of toolchains to be selected during toolchain resolution. | `[]` |
| version | The version of the tool among "nightly", "beta', or an exact version. | `None` |
-| versions | A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. ["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]
. | `[]` |
+| versions | A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. `["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]`. | `[]` |
| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | `None` |
| global_allocator_library | Target that provides allocator functions a global allocator is used with cc_common.link. | `None` |
| extra_target_triples | Additional rust-style targets that this set of toolchains should support. If a map, values should be (optional) target_compatible_with lists for that particular target triple. | `{}` |
| iso_date | The date of the tool. | `None` |
| rustfmt_version | The version of rustfmt to be associated with the toolchain. | `None` |
-| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its edition
attribute. | `None` |
+| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute. | `None` |
| dev_components | Whether to download the rustc-dev components. Requires version to be "nightly". | `False` |
| extra_rustc_flags | Dictionary of target triples to list of extra flags to pass to rustc in non-exec configuration. | `None` |
| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration. | `None` |
@@ -2033,7 +1923,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
| auth | Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details. | `None` |
| netrc | .netrc file to use for authentication; mirrors the eponymous attribute from http_archive | `None` |
| auth_patterns | Override mapping of hostnames to authorization patterns; mirrors the eponymous attribute from http_archive | `None` |
-| register_toolchain | If True, the generated rust_toolchain
target will become a registered toolchain. | `True` |
+| register_toolchain | If True, the generated `rust_toolchain` target will become a registered toolchain. | `True` |
| exec_compatible_with | A list of constraints for the execution platform for this toolchain. | `None` |
| default_target_compatible_with | A list of constraints for the target platform for this toolchain when the exec platform is the same as the target platform. | `None` |
@@ -2097,9 +1987,9 @@ rust_test_suite(
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
-| name | The name of the test_suite
. | none |
-| srcs | All test sources, typically glob(["tests/**/*.rs"])
. | none |
-| kwargs | Additional keyword arguments for the underyling [rust_test](#rust_test) targets. The tags
argument is also passed to the generated test_suite
target. | none |
+| name | The name of the `test_suite`. | none |
+| srcs | All test sources, typically `glob(["tests/**/*.rs"])`. | none |
+| kwargs | Additional keyword arguments for the underyling [rust_test](#rust_test) targets. The `tags` argument is also passed to the generated `test_suite` target. | none |
@@ -2133,7 +2023,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
| global_allocator_library | Target that provides allocator functions when a global allocator is used with cc_common.link. | `None` |
| iso_date | The date of the tool. | `None` |
| rustfmt_version | The version of rustfmt to be associated with the toolchain. | `None` |
-| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its edition
attribute. | `None` |
+| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute. | `None` |
| dev_components | Whether to download the rustc-dev components. Requires version to be "nightly". Defaults to False. | `False` |
| extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration. | `None` |
| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration. | `None` |
@@ -2217,7 +2107,7 @@ Annotates rust rules with RustAnalyzerInfo later used to build a rust-project.js
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
+| name | A unique name for this target. | Name | required | |
@@ -2255,7 +2145,6 @@ Then the targets can be analyzed with clippy using the following command:
$ bazel build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect --output_groups=clippy_checks //hello_lib:all
```
-
**ASPECT ATTRIBUTES**
@@ -2265,7 +2154,7 @@ $ bazel build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
+| name | A unique name for this target. | Name | required | |
@@ -2291,7 +2180,6 @@ This aspect is executed on any target which provides the `CrateInfo` provider. H
users may tag a target with `no-rustfmt` or `no-format` to have it skipped. Additionally,
generated source files are also ignored by this aspect.
-
**ASPECT ATTRIBUTES**
@@ -2301,6 +2189,104 @@ generated source files are also ignored by this aspect.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
+| name | A unique name for this target. | Name | required | |
+
+
+
+
+## cargo_bootstrap_repository
+
+
+cargo_bootstrap_repository(name , srcs , binary , build_mode , cargo_lockfile , cargo_toml , env ,
+ env_label , repo_mapping , rust_toolchain_cargo_template ,
+ rust_toolchain_rustc_template , timeout , version )
+
+
+A rule for bootstrapping a Rust binary using [Cargo](https://doc.rust-lang.org/cargo/)
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| name | A unique name for this repository. | Name | required | |
+| srcs | Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made | List of labels | optional | `[]` |
+| binary | The binary to build (the `--bin` parameter for Cargo). If left empty, the repository name will be used. | String | optional | `""` |
+| build_mode | The build mode the binary should be built with | String | optional | `"release"` |
+| cargo_lockfile | The lockfile of the crate_universe resolver | Label | required | |
+| cargo_toml | The path of the crate_universe resolver manifest (`Cargo.toml` file) | Label | required | |
+| env | A mapping of platform triple to a set of environment variables. See [cargo_env](#cargo_env) for usage details. Additionally, the platform triple `*` applies to all platforms. | Dictionary: String -> String | optional | `{}` |
+| env_label | A mapping of platform triple to a set of environment variables. This attribute differs from `env` in that all variables passed here must be fully qualified labels of files. See [cargo_env](#cargo_env) for usage details. Additionally, the platform triple `*` applies to all platforms. | Dictionary: String -> String | optional | `{}` |
+| repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository. For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`). This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | Dictionary: String -> String | optional | |
+| rust_toolchain_cargo_template | The template to use for finding the host `cargo` binary. `{version}` (eg. '1.53.0'), `{triple}` (eg. 'x86_64-unknown-linux-gnu'), `{arch}` (eg. 'aarch64'), `{vendor}` (eg. 'unknown'), `{system}` (eg. 'darwin'), `{channel}` (eg. 'stable'), and `{tool}` (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | `"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"` |
+| rust_toolchain_rustc_template | The template to use for finding the host `rustc` binary. `{version}` (eg. '1.53.0'), `{triple}` (eg. 'x86_64-unknown-linux-gnu'), `{arch}` (eg. 'aarch64'), `{vendor}` (eg. 'unknown'), `{system}` (eg. 'darwin'), `{channel}` (eg. 'stable'), and `{tool}` (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | `"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"` |
+| timeout | Maximum duration of the Cargo build command in seconds | Integer | optional | `600` |
+| version | The version of Rust the currently registered toolchain is using. Eg. `1.56.0`, or `nightly/2021-09-08` | String | optional | `"1.79.0"` |
+
+
+
+
+## rust_toolchain_repository_proxy
+
+
+rust_toolchain_repository_proxy(name , exec_compatible_with , repo_mapping , target_compatible_with ,
+ target_settings , toolchain , toolchain_type )
+
+
+Generates a toolchain-bearing repository that declares the toolchains from some other rust_toolchain_repository.
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| name | A unique name for this repository. | Name | required | |
+| exec_compatible_with | A list of constraints for the execution platform for this toolchain. | List of strings | optional | `[]` |
+| repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository. For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`). This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | Dictionary: String -> String | optional | |
+| target_compatible_with | A list of constraints for the target platform for this toolchain. | List of strings | optional | `[]` |
+| target_settings | A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution. | List of strings | optional | `[]` |
+| toolchain | The name of the toolchain implementation target. | String | required | |
+| toolchain_type | The toolchain type of the toolchain to declare | String | required | |
+
+
+
+
+## rust_toolchain_tools_repository
+
+
+rust_toolchain_tools_repository(name , allocator_library , auth , auth_patterns , dev_components ,
+ edition , exec_triple , extra_exec_rustc_flags , extra_rustc_flags ,
+ global_allocator_library , iso_date , netrc , opt_level , repo_mapping ,
+ rustfmt_version , sha256s , target_triple , urls , version )
+
+
+Composes a single workspace containing the toolchain components for compiling on a given platform to a series of target platforms.
+
+A given instance of this rule should be accompanied by a toolchain_repository_proxy invocation to declare its toolchains to Bazel; the indirection allows separating toolchain selection from toolchain fetching.
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| name | A unique name for this repository. | Name | required | |
+| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | String | optional | `"@rules_rust//ffi/cc/allocator_library"` |
+| auth | Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details. | Dictionary: String -> String | optional | `{}` |
+| auth_patterns | A list of patterns to match against urls for which the auth object should be used. | List of strings | optional | `[]` |
+| dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | `False` |
+| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute. | String | optional | `""` |
+| exec_triple | The Rust-style target that this compiler runs on | String | required | |
+| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | `[]` |
+| extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | `[]` |
+| global_allocator_library | Target that provides allocator functions when a global allocator is used with cc_common.link. | String | optional | `"@rules_rust//ffi/cc/global_allocator_library"` |
+| iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | `""` |
+| netrc | .netrc file to use for authentication; mirrors the eponymous attribute from http_archive | String | optional | `""` |
+| opt_level | Rustc optimization levels. For more details see the documentation for `rust_toolchain.opt_level`. | Dictionary: String -> String | optional | `{}` |
+| repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository. For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`). This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | Dictionary: String -> String | optional | |
+| rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | `""` |
+| sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_register_toolchains](#rust_register_toolchains) for more details. | Dictionary: String -> String | optional | `{}` |
+| target_triple | The Rust-style target that this compiler builds for. | String | required | |
+| urls | 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). | List of strings | optional | `["https://static.rust-lang.org/dist/{}.tar.xz"]` |
+| version | The version of the tool among "nightly", "beta", or an exact version. | String | required | |
diff --git a/docs/index.md b/docs/index.md
index 21e6928e78..c00e60f5f8 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -13,7 +13,23 @@ This repository provides rules for building [Rust][rust] projects with [Bazel][b
## Setup
-To use the Rust rules, add the following to your `WORKSPACE` file to add the external repositories for the Rust toolchain:
+The rules are released, and releases can be found on [the GitHub Releases page](https://github.com/bazelbuild/rules_rust/releases). We recommend using the latest release from that page.
+
+### Bzlmod
+
+Note that rules_rust bzlmod support is still a work in progress. Most features should work, but bugs are more likely. This is not a desired end-state - please report (or better yet, help fix!) bugs you run into.
+
+To use `rules_rust` in a project using bzlmod, add the following to your `MODULE.bazel` file:
+
+```python
+bazel_dep(name = "rules_rust", version = "0.46.0")
+```
+
+Don't forget to substitute in your desired release's version number.
+
+### WORKSPACE
+
+To use `rules_rust` in a project using a WORKSPACE file, add the following to your `WORKSPACE` file to add the external repositories for the Rust toolchain:
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
@@ -22,8 +38,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# https://github.com/bazelbuild/rules_rust/releases
http_archive(
name = "rules_rust",
- sha256 = "36ab8f9facae745c9c9c1b33d225623d976e78f2cc3f729b7973d8c20934ab95",
- urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.31.0/rules_rust-v0.31.0.tar.gz"],
+ integrity = "sha256-F8U7+AC5MvMtPKGdLLnorVM84cDXKfDRgwd7/dq3rUY=",
+ urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.46.0/rules_rust-v0.46.0.tar.gz"],
)
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
@@ -33,7 +49,7 @@ rules_rust_dependencies()
rust_register_toolchains()
```
-The rules are released, and releases can be found on [the GitHub Releases page](https://github.com/bazelbuild/rules_rust/releases). We recommend using the latest release from that page.
+Don't forget to substitute in your desired release's version number and integrity hash.
## Rules
@@ -45,7 +61,8 @@ The rules are released, and releases can be found on [the GitHub Releases page](
- [rust_bindgen](rust_bindgen.md): rules for generating C++ bindings.
- [rust_wasm_bindgen](rust_wasm_bindgen.md): rules for generating [WebAssembly](https://www.rust-lang.org/what/wasm) bindings.
- [cargo](cargo.md): Rules dedicated to Cargo compatibility. ie: [`build.rs` scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html).
-- [crate_universe](crate_universe.md): Rules for generating Bazel targets for external crate dependencies.
+- [crate_universe (bzlmod)](crate_universe_bzlmod.md): Rules for generating Bazel targets for external crate dependencies when using bzlmod.
+- [crate_universe (WORKSPACE)](crate_universe.md): Rules for generating Bazel targets for external crate dependencies when using WORKSPACE files.
You can also browse the [full API in one page](flatten.md).
diff --git a/docs/providers.md b/docs/providers.md
index bed0a6ff64..7e19b7a0f9 100644
--- a/docs/providers.md
+++ b/docs/providers.md
@@ -35,14 +35,14 @@ A provider containing general Crate information.
| owner | Label: The label of the target that produced this CrateInfo |
| proc_macro_deps | depset[DepVariantInfo]: This crate's rust proc_macro dependencies' providers. |
| root | File: The source File entrypoint to this crate, eg. lib.rs |
-| rustc_env | Dict[String, String]: Additional "key": "value"
environment variables to set for rustc. |
+| rustc_env | Dict[String, String]: Additional `"key": "value"` environment variables to set for rustc. |
| rustc_env_files | [File]: Files containing additional environment variables to set for rustc. |
| rustc_output | File: The output from rustc from producing the output file. It is optional. |
| rustc_rmeta_output | File: The rmeta file produced for this crate. It is optional. |
| srcs | depset[File]: All source Files that are part of the crate. |
| std_dylib | File: libstd.so file |
| type | str: The type of this crate (see [rustc --crate-type](https://doc.rust-lang.org/rustc/command-line-arguments.html#--crate-type-a-list-of-types-of-crates-for-the-compiler-to-emit)). |
-| wrapped_crate_type | str, optional: The original crate type for targets generated using a previously defined crate (typically tests using the rust_test::crate
attribute) |
+| wrapped_crate_type | str, optional: The original crate type for targets generated using a previously defined crate (typically tests using the `rust_test::crate` attribute) |
@@ -91,18 +91,18 @@ A collection of files either found within the `rust-stdlib` artifact or generate
| Name | Description |
| :------------- | :------------- |
-| alloc_files | List[File]: .a
files related to the alloc
module. |
-| between_alloc_and_core_files | List[File]: .a
files related to the compiler_builtins
module. |
-| between_core_and_std_files | List[File]: .a
files related to all modules except adler
, alloc
, compiler_builtins
, core
, and std
. |
-| core_files | List[File]: .a
files related to the core
and adler
modules |
-| dot_a_files | Depset[File]: Generated .a
files |
-| memchr_files | Depset[File]: .a
files associated with the memchr
module. |
-| panic_files | Depset[File]: .a
files associated with panic_unwind
and panic_abort
. |
-| self_contained_files | List[File]: All .o
files from the self-contained
directory. |
-| srcs | List[Target]: All targets from the original srcs
attribute. |
+| alloc_files | List[File]: `.a` files related to the `alloc` module. |
+| between_alloc_and_core_files | List[File]: `.a` files related to the `compiler_builtins` module. |
+| between_core_and_std_files | List[File]: `.a` files related to all modules except `adler`, `alloc`, `compiler_builtins`, `core`, and `std`. |
+| core_files | List[File]: `.a` files related to the `core` and `adler` modules |
+| dot_a_files | Depset[File]: Generated `.a` files |
+| memchr_files | Depset[File]: `.a` files associated with the `memchr` module. |
+| panic_files | Depset[File]: `.a` files associated with `panic_unwind` and `panic_abort`. |
+| self_contained_files | List[File]: All `.o` files from the `self-contained` directory. |
+| srcs | List[Target]: All targets from the original `srcs` attribute. |
| std_dylib | File: libstd.so file |
-| std_files | Depset[File]: .a
files associated with the std
module. |
-| std_rlibs | List[File]: All .rlib
files |
-| test_files | Depset[File]: .a
files associated with the test
module. |
+| std_files | Depset[File]: `.a` files associated with the `std` module. |
+| std_rlibs | List[File]: All `.rlib` files |
+| test_files | Depset[File]: `.a` files associated with the `test` module. |
diff --git a/docs/rust_analyzer.md b/docs/rust_analyzer.md
index fd4be79da7..38b3d7f61f 100644
--- a/docs/rust_analyzer.md
+++ b/docs/rust_analyzer.md
@@ -105,8 +105,8 @@ A toolchain for [rust-analyzer](https://rust-analyzer.github.io/).
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| proc_macro_srv | The path to a rust_analyzer_proc_macro_srv
binary. | Label | optional | None
|
-| rustc | The path to a rustc
binary. | Label | required | |
+| proc_macro_srv | The path to a `rust_analyzer_proc_macro_srv` binary. | Label | optional | `None` |
+| rustc | The path to a `rustc` binary. | Label | required | |
| rustc_srcs | The source code of rustc. | Label | required | |
@@ -137,6 +137,6 @@ Annotates rust rules with RustAnalyzerInfo later used to build a rust-project.js
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
+| name | A unique name for this target. | Name | required | |
diff --git a/docs/rust_bindgen.md b/docs/rust_bindgen.md
index c56ce95327..aa87c3a2b7 100644
--- a/docs/rust_bindgen.md
+++ b/docs/rust_bindgen.md
@@ -64,10 +64,10 @@ Generates a rust source file from a cc_library and a header.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| bindgen_flags | Flags to pass directly to the bindgen executable. See https://rust-lang.github.io/rust-bindgen/ for details. | List of strings | optional | []
|
-| cc_lib | The cc_library that contains the .h
file. This is used to find the transitive includes. | Label | required | |
-| clang_flags | Flags to pass directly to the clang executable. | List of strings | optional | []
|
-| header | The .h
file to generate bindings for. | Label | required | |
+| bindgen_flags | Flags to pass directly to the bindgen executable. See https://rust-lang.github.io/rust-bindgen/ for details. | List of strings | optional | `[]` |
+| cc_lib | The cc_library that contains the `.h` file. This is used to find the transitive includes. | Label | required | |
+| clang_flags | Flags to pass directly to the clang executable. | List of strings | optional | `[]` |
+| header | The `.h` file to generate bindings for. | Label | required | |
@@ -80,7 +80,7 @@ rust_bindgen_toolchain(name , name | A unique name for this target. | Name | required | |
-| bindgen | The label of a bindgen
executable. | Label | optional | None
|
-| clang | The label of a clang
executable. | Label | optional | None
|
-| default_rustfmt | If set, rust_bindgen
targets will always format generated sources with rustfmt
. | Boolean | optional | True
|
-| libclang | A cc_library that provides bindgen's runtime dependency on libclang. | Label | optional | None
|
-| libstdcxx | A cc_library that satisfies libclang's libstdc++ dependency. This is used to make the execution of clang hermetic. If None, system libraries will be used instead. | Label | optional | None
|
+| bindgen | The label of a `bindgen` executable. | Label | optional | `None` |
+| clang | The label of a `clang` executable. | Label | optional | `None` |
+| default_rustfmt | If set, `rust_bindgen` targets will always format generated sources with `rustfmt`. | Boolean | optional | `True` |
+| libclang | A cc_library that provides bindgen's runtime dependency on libclang. | Label | optional | `None` |
+| libstdcxx | A cc_library that satisfies libclang's libstdc++ dependency. This is used to make the execution of clang hermetic. If None, system libraries will be used instead. | Label | optional | `None` |
@@ -158,9 +157,9 @@ Arguments are the same as `rust_bindgen`, and `kwargs` are passed directly to ru
| header | The label of the .h file to generate bindings for. | none |
| cc_lib | The label of the cc_library that contains the .h file. This is used to find the transitive includes. | none |
| bindgen_flags | Flags to pass directly to the bindgen executable. See https://rust-lang.github.io/rust-bindgen/ for details. | `None` |
-| bindgen_features | The features
attribute for the rust_bindgen
target. | `None` |
+| bindgen_features | The `features` attribute for the `rust_bindgen` target. | `None` |
| clang_flags | Flags to pass directly to the clang executable. | `None` |
-| kwargs | Arguments to forward to the underlying rust_library
rule. | none |
+| kwargs | Arguments to forward to the underlying `rust_library` rule. | none |
diff --git a/docs/rust_clippy.md b/docs/rust_clippy.md
index 9d4745e0e8..cce78d5197 100644
--- a/docs/rust_clippy.md
+++ b/docs/rust_clippy.md
@@ -81,14 +81,13 @@ rust_clippy(
)
```
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| deps | Rust targets to run clippy on. | List of labels | optional | []
|
+| deps | Rust targets to run clippy on. | List of labels | optional | `[]` |
@@ -126,7 +125,6 @@ Then the targets can be analyzed with clippy using the following command:
$ bazel build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect --output_groups=clippy_checks //hello_lib:all
```
-
**ASPECT ATTRIBUTES**
@@ -136,6 +134,6 @@ $ bazel build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
+| name | A unique name for this target. | Name | required | |
diff --git a/docs/rust_doc.md b/docs/rust_doc.md
index c6959c2088..42dff37854 100644
--- a/docs/rust_doc.md
+++ b/docs/rust_doc.md
@@ -49,20 +49,19 @@ rust_doc(
Running `bazel build //hello_lib:hello_lib_doc` will build a zip file containing the documentation for the `hello_lib` library crate generated by `rustdoc`.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| crate | The label of the target to generate code documentation for.rust_doc
can generate HTML code documentation for the source files of rust_library
or rust_binary
targets. | Label | required | |
-| html_after_content | File to add in <body>
, after content. | Label | optional | None
|
-| html_before_content | File to add in <body>
, before content. | Label | optional | None
|
-| html_in_header | File to add to <head>
. | Label | optional | None
|
-| markdown_css | CSS files to include via <link>
in a rendered Markdown file. | List of labels | optional | []
|
-| rustc_flags | **Deprecated**: use rustdoc_flags
instead | List of strings | optional | []
|
-| rustdoc_flags | List of flags passed to rustdoc
. 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)
. | List of strings | optional | []
|
+| crate | The label of the target to generate code documentation for. `rust_doc` can generate HTML code documentation for the source files of `rust_library` or `rust_binary` targets. | Label | required | |
+| html_after_content | File to add in ``, after content. | Label | optional | `None` |
+| html_before_content | File to add in ``, before content. | Label | optional | `None` |
+| html_in_header | File to add to ``. | Label | optional | `None` |
+| markdown_css | CSS files to include via ` ` in a rendered Markdown file. | List of labels | optional | `[]` |
+| rustc_flags | **Deprecated**: use `rustdoc_flags` instead | List of strings | optional | `[]` |
+| rustdoc_flags | List of flags passed to `rustdoc`. 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)`. | List of strings | optional | `[]` |
@@ -70,7 +69,7 @@ Running `bazel build //hello_lib:hello_lib_doc` will build a zip file containing
## rust_doc_test
-rust_doc_test(name , crate , deps )
+rust_doc_test(name , deps , crate )
Runs Rust documentation tests.
@@ -110,14 +109,13 @@ rust_doc_test(
Running `bazel test //hello_lib:hello_lib_doc_test` will run all documentation tests for the `hello_lib` library crate.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| crate | The label of the target to generate code documentation for. rust_doc_test
can generate HTML code documentation for the source files of rust_library
or rust_binary
targets. | Label | required | |
-| deps | 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. | List of labels | optional | []
|
+| deps | 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. | List of labels | optional | `[]` |
+| crate | The label of the target to generate code documentation for. `rust_doc_test` can generate HTML code documentation for the source files of `rust_library` or `rust_binary` targets. | Label | required | |
diff --git a/docs/rust_fmt.md b/docs/rust_fmt.md
index e33b7b8ef2..0bc065347d 100644
--- a/docs/rust_fmt.md
+++ b/docs/rust_fmt.md
@@ -75,7 +75,7 @@ A test rule for performing `rustfmt --check` on a set of targets
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| targets | Rust targets to run rustfmt --check
on. | List of labels | optional | []
|
+| targets | Rust targets to run `rustfmt --check` on. | List of labels | optional | `[]` |
@@ -94,9 +94,9 @@ A toolchain for [rustfmt](https://rust-lang.github.io/rustfmt/)
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| rustc | The location of the rustc
binary. Can be a direct source or a filegroup containing one item. | Label | optional | None
|
-| rustc_lib | The libraries used by rustc during compilation. | Label | optional | None
|
-| rustfmt | The location of the rustfmt
binary. Can be a direct source or a filegroup containing one item. | Label | required | |
+| rustc | The location of the `rustc` binary. Can be a direct source or a filegroup containing one item. | Label | optional | `None` |
+| rustc_lib | The libraries used by rustc during compilation. | Label | optional | `None` |
+| rustfmt | The location of the `rustfmt` binary. Can be a direct source or a filegroup containing one item. | Label | required | |
@@ -122,7 +122,6 @@ This aspect is executed on any target which provides the `CrateInfo` provider. H
users may tag a target with `no-rustfmt` or `no-format` to have it skipped. Additionally,
generated source files are also ignored by this aspect.
-
**ASPECT ATTRIBUTES**
@@ -132,6 +131,6 @@ generated source files are also ignored by this aspect.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
+| name | A unique name for this target. | Name | required | |
diff --git a/docs/rust_proto.md b/docs/rust_proto.md
index ea5a92b2d9..08eca3759f 100644
--- a/docs/rust_proto.md
+++ b/docs/rust_proto.md
@@ -258,7 +258,7 @@ configuration.
## rust_grpc_library
-rust_grpc_library(name , crate_name , deps , rust_deps , rustc_flags )
+rust_grpc_library(name , deps , crate_name , rust_deps , rustc_flags )
Builds a Rust library crate from a set of `proto_library`s suitable for gRPC.
@@ -285,17 +285,16 @@ rust_binary(
)
```
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| crate_name | 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. | String | optional | ""
|
| deps | List of proto_library dependencies that will be built. One crate for each proto_library will be created with the corresponding gRPC stubs. | List of labels | required | |
-| rust_deps | The crates the generated library depends on. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
+| crate_name | 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. | String | optional | `""` |
+| rust_deps | The crates the generated library depends on. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
@@ -315,16 +314,16 @@ Rust Prost toolchain rule.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| prost_opts | Additional options to add to Prost. | List of strings | optional | []
|
+| prost_opts | Additional options to add to Prost. | List of strings | optional | `[]` |
| prost_plugin | Additional plugins to add to Prost. | Label | required | |
-| prost_plugin_flag | Prost plugin flag format. (e.g. --plugin=protoc-gen-prost=%s
) | String | optional | "--plugin=protoc-gen-prost=%s"
|
+| prost_plugin_flag | Prost plugin flag format. (e.g. `--plugin=protoc-gen-prost=%s`) | String | optional | `"--plugin=protoc-gen-prost=%s"` |
| prost_runtime | The Prost runtime crates to use. | Label | required | |
| prost_types | The Prost types crates to use. | Label | required | |
| proto_compiler | The protoc compiler to use. | Label | required | |
-| tonic_opts | Additional options to add to Tonic. | List of strings | optional | []
|
-| tonic_plugin | Additional plugins to add to Tonic. | Label | optional | None
|
-| tonic_plugin_flag | Tonic plugin flag format. (e.g. --plugin=protoc-gen-tonic=%s
)) | String | optional | "--plugin=protoc-gen-tonic=%s"
|
-| tonic_runtime | The Tonic runtime crates to use. | Label | optional | None
|
+| tonic_opts | Additional options to add to Tonic. | List of strings | optional | `[]` |
+| tonic_plugin | Additional plugins to add to Tonic. | Label | optional | `None` |
+| tonic_plugin_flag | Tonic plugin flag format. (e.g. `--plugin=protoc-gen-tonic=%s`)) | String | optional | `"--plugin=protoc-gen-tonic=%s"` |
+| tonic_runtime | The Tonic runtime crates to use. | Label | optional | `None` |
@@ -332,7 +331,7 @@ Rust Prost toolchain rule.
## rust_proto_library
-rust_proto_library(name , crate_name , deps , rust_deps , rustc_flags )
+rust_proto_library(name , deps , crate_name , rust_deps , rustc_flags )
Builds a Rust library crate from a set of `proto_library`s.
@@ -359,17 +358,16 @@ rust_binary(
)
```
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| crate_name | 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. | String | optional | ""
|
| deps | List of proto_library dependencies that will be built. One crate for each proto_library will be created with the corresponding stubs. | List of labels | required | |
-| rust_deps | The crates the generated library depends on. | List of labels | optional | []
|
-| rustc_flags | 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)
. | List of strings | optional | []
|
+| crate_name | 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. | String | optional | `""` |
+| rust_deps | The crates the generated library depends on. | List of labels | optional | `[]` |
+| rustc_flags | 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)`. | List of strings | optional | `[]` |
@@ -411,7 +409,7 @@ A rule for generating a Rust library using Prost.
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| name | The name of the target. | none |
-| kwargs | Additional keyword arguments for the underlying rust_prost_library
rule. | none |
+| kwargs | Additional keyword arguments for the underlying `rust_prost_library` rule. | none |
diff --git a/docs/rust_repositories.md b/docs/rust_repositories.md
index bc59cdb1c2..729e4ba1e1 100644
--- a/docs/rust_repositories.md
+++ b/docs/rust_repositories.md
@@ -87,109 +87,42 @@ Then, either add the label of the toolchain rule to `register_toolchains` in the
See `@rules_rust//rust:repositories.bzl` for examples of defining the `@rust_cpuX` repository with the actual binaries and libraries.
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | Label | optional | @rules_rust//ffi/cc/allocator_library
|
+| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | Label | optional | `"@rules_rust//ffi/cc/allocator_library"` |
| binary_ext | The extension for binaries created from rustc. | String | required | |
-| cargo | The location of the cargo
binary. Can be a direct source or a filegroup containing one item. | Label | optional | None
|
-| clippy_driver | The location of the clippy-driver
binary. Can be a direct source or a filegroup containing one item. | Label | optional | None
|
-| debug_info | Rustc debug info levels per opt level | Dictionary: String -> String | optional | {"dbg": "2", "fastbuild": "0", "opt": "0"}
|
-| default_edition | The edition to use for rust_* rules that don't specify an edition. If absent, every rule is required to specify its edition
attribute. | String | optional | ""
|
+| cargo | The location of the `cargo` binary. Can be a direct source or a filegroup containing one item. | Label | optional | `None` |
+| clippy_driver | The location of the `clippy-driver` binary. Can be a direct source or a filegroup containing one item. | Label | optional | `None` |
+| debug_info | Rustc debug info levels per opt level | Dictionary: String -> String | optional | `{"dbg": "2", "fastbuild": "0", "opt": "0"}` |
+| default_edition | The edition to use for rust_* rules that don't specify an edition. If absent, every rule is required to specify its `edition` attribute. | String | optional | `""` |
| dylib_ext | The extension for dynamic libraries created from rustc. | String | required | |
-| env | Environment variables to set in actions. | Dictionary: String -> String | optional | {}
|
+| env | Environment variables to set in actions. | Dictionary: String -> String | optional | `{}` |
| exec_triple | The platform triple for the toolchains execution environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations | String | required | |
-| experimental_link_std_dylib | Label to a boolean build setting that controls whether whether to link libstd dynamically. | Label | optional | @rules_rust//rust/settings:experimental_link_std_dylib
|
-| experimental_use_cc_common_link | Label to a boolean build setting that controls whether cc_common.link is used to link rust binaries. | Label | optional | //rust/settings:experimental_use_cc_common_link
|
-| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | []
|
-| extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | []
|
-| extra_rustc_flags_for_crate_types | Extra flags to pass to rustc based on crate type | Dictionary: String -> List of strings | optional | {}
|
-| global_allocator_library | Target that provides allocator functions for when a global allocator is present. | Label | optional | @rules_rust//ffi/cc/global_allocator_library
|
-| llvm_cov | The location of the llvm-cov
binary. Can be a direct source or a filegroup containing one item. If None, rust code is not instrumented for coverage. | Label | optional | None
|
-| llvm_profdata | The location of the llvm-profdata
binary. Can be a direct source or a filegroup containing one item. If llvm_cov
is None, this can be None as well and rust code is not instrumented for coverage. | Label | optional | None
|
-| llvm_tools | LLVM tools that are shipped with the Rust toolchain. | Label | optional | None
|
-| opt_level | Rustc optimization levels. | Dictionary: String -> String | optional | {"dbg": "0", "fastbuild": "0", "opt": "3"}
|
-| per_crate_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | []
|
-| rust_doc | The location of the rustdoc
binary. Can be a direct source or a filegroup containing one item. | Label | required | |
+| experimental_link_std_dylib | Label to a boolean build setting that controls whether whether to link libstd dynamically. | Label | optional | `"@rules_rust//rust/settings:experimental_link_std_dylib"` |
+| experimental_use_cc_common_link | Label to a boolean build setting that controls whether cc_common.link is used to link rust binaries. | Label | optional | `"@rules_rust//rust/settings:experimental_use_cc_common_link"` |
+| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | `[]` |
+| extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | `[]` |
+| extra_rustc_flags_for_crate_types | Extra flags to pass to rustc based on crate type | Dictionary: String -> List of strings | optional | `{}` |
+| global_allocator_library | Target that provides allocator functions for when a global allocator is present. | Label | optional | `"@rules_rust//ffi/cc/global_allocator_library"` |
+| llvm_cov | The location of the `llvm-cov` binary. Can be a direct source or a filegroup containing one item. If None, rust code is not instrumented for coverage. | Label | optional | `None` |
+| llvm_profdata | The location of the `llvm-profdata` binary. Can be a direct source or a filegroup containing one item. If `llvm_cov` is None, this can be None as well and rust code is not instrumented for coverage. | Label | optional | `None` |
+| llvm_tools | LLVM tools that are shipped with the Rust toolchain. | Label | optional | `None` |
+| opt_level | Rustc optimization levels. | Dictionary: String -> String | optional | `{"dbg": "0", "fastbuild": "0", "opt": "3"}` |
+| per_crate_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | `[]` |
+| rust_doc | The location of the `rustdoc` binary. Can be a direct source or a filegroup containing one item. | Label | required | |
| rust_std | The Rust standard library. | Label | required | |
-| rustc | The location of the rustc
binary. Can be a direct source or a filegroup containing one item. | Label | required | |
-| rustc_lib | The libraries used by rustc during compilation. | Label | optional | None
|
-| rustfmt | **Deprecated**: Instead see [rustfmt_toolchain](#rustfmt_toolchain) | Label | optional | None
|
+| rustc | The location of the `rustc` binary. Can be a direct source or a filegroup containing one item. | Label | required | |
+| rustc_lib | The libraries used by rustc during compilation. | Label | optional | `None` |
+| rustfmt | **Deprecated**: Instead see [rustfmt_toolchain](#rustfmt_toolchain) | Label | optional | `None` |
| staticlib_ext | The extension for static libraries created from rustc. | String | required | |
-| stdlib_linkflags | Additional linker flags to use when Rust standard library is linked by a C++ linker (rustc will deal with these automatically). Subject to location expansion with respect to the srcs of the rust_std
attribute. | List of strings | required | |
-| strip_level | Rustc strip levels. For all potential options, see https://doc.rust-lang.org/rustc/codegen-options/index.html#strip | Dictionary: String -> String | optional | {"dbg": "none", "fastbuild": "none", "opt": "debuginfo"}
|
-| target_json | Override the target_triple with a custom target specification. For more details see: https://doc.rust-lang.org/rustc/targets/custom.html | String | optional | ""
|
-| target_triple | The platform triple for the toolchains target environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations | String | optional | ""
|
-
-
-
-
-## rust_toolchain_repository_proxy
-
-
-rust_toolchain_repository_proxy(name , exec_compatible_with , repo_mapping , target_compatible_with ,
- target_settings , toolchain , toolchain_type )
-
-
-Generates a toolchain-bearing repository that declares the toolchains from some other rust_toolchain_repository.
-
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this repository. | Name | required | |
-| exec_compatible_with | A list of constraints for the execution platform for this toolchain. | List of strings | optional | []
|
-| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar"
declares that, for any time this repository depends on @foo
(such as a dependency on @foo//some:target
, it should actually resolve that dependency within globally-declared @bar
(@bar//some:target
). | Dictionary: String -> String | required | |
-| target_compatible_with | A list of constraints for the target platform for this toolchain. | List of strings | optional | []
|
-| target_settings | A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution. | List of strings | optional | []
|
-| toolchain | The name of the toolchain implementation target. | String | required | |
-| toolchain_type | The toolchain type of the toolchain to declare | String | required | |
-
-
-
-
-## rust_toolchain_tools_repository
-
-
-rust_toolchain_tools_repository(name , allocator_library , auth , auth_patterns , dev_components ,
- edition , exec_triple , extra_exec_rustc_flags , extra_rustc_flags ,
- global_allocator_library , iso_date , netrc , opt_level , repo_mapping ,
- rustfmt_version , sha256s , target_triple , urls , version )
-
-
-Composes a single workspace containing the toolchain components for compiling on a given platform to a series of target platforms.
-
-A given instance of this rule should be accompanied by a toolchain_repository_proxy invocation to declare its toolchains to Bazel; the indirection allows separating toolchain selection from toolchain fetching.
-
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this repository. | Name | required | |
-| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | String | optional | "@rules_rust//ffi/cc/allocator_library"
|
-| auth | Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details. | Dictionary: String -> String | optional | {}
|
-| auth_patterns | A list of patterns to match against urls for which the auth object should be used. | List of strings | optional | []
|
-| dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | False
|
-| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its edition
attribute. | String | optional | ""
|
-| exec_triple | The Rust-style target that this compiler runs on | String | required | |
-| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | []
|
-| extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | []
|
-| global_allocator_library | Target that provides allocator functions when a global allocator is used with cc_common.link. | String | optional | "@rules_rust//ffi/cc/global_allocator_library"
|
-| iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | ""
|
-| netrc | .netrc file to use for authentication; mirrors the eponymous attribute from http_archive | String | optional | ""
|
-| opt_level | Rustc optimization levels. For more details see the documentation for rust_toolchain.opt_level
. | Dictionary: String -> String | optional | {}
|
-| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar"
declares that, for any time this repository depends on @foo
(such as a dependency on @foo//some:target
, it should actually resolve that dependency within globally-declared @bar
(@bar//some:target
). | Dictionary: String -> String | required | |
-| rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | ""
|
-| sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_register_toolchains](#rust_register_toolchains) for more details. | Dictionary: String -> String | optional | {}
|
-| target_triple | The Rust-style target that this compiler builds for. | String | required | |
-| urls | 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). | List of strings | optional | ["https://static.rust-lang.org/dist/{}.tar.xz"]
|
-| version | The version of the tool among "nightly", "beta", or an exact version. | String | required | |
+| stdlib_linkflags | Additional linker flags to use when Rust standard library is linked by a C++ linker (rustc will deal with these automatically). Subject to location expansion with respect to the srcs of the `rust_std` attribute. | List of strings | required | |
+| strip_level | Rustc strip levels. For all potential options, see https://doc.rust-lang.org/rustc/codegen-options/index.html#strip | Dictionary: String -> String | optional | `{"dbg": "none", "fastbuild": "none", "opt": "debuginfo"}` |
+| target_json | Override the target_triple with a custom target specification. For more details see: https://doc.rust-lang.org/rustc/targets/custom.html | String | optional | `""` |
+| target_triple | The platform triple for the toolchains target environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations | String | optional | `""` |
@@ -270,20 +203,20 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | `False` |
-| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every target is required to specify its edition
attribute. | `None` |
+| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every target is required to specify its `edition` attribute. | `None` |
| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | `None` |
| global_allocator_library | Target that provides allocator functions when global allocator is used with cc_common.link. | `None` |
-| iso_date | **Deprecated**: Use versions
instead. | `None` |
-| register_toolchains | If true, repositories will be generated to produce and register rust_toolchain
targets. | `True` |
-| rustfmt_version | The version of rustfmt. If none is supplied and only a single version in versions
is given, then this defaults to that version, otherwise will default to the default nightly version. | `None` |
+| iso_date | **Deprecated**: Use `versions` instead. | `None` |
+| register_toolchains | If true, repositories will be generated to produce and register `rust_toolchain` targets. | `True` |
+| rustfmt_version | The version of rustfmt. If none is supplied and only a single version in `versions` is given, then this defaults to that version, otherwise will default to the default nightly version. | `None` |
| rust_analyzer_version | The version of Rustc to pair with rust-analyzer. | `None` |
| sha256s | A dict associating tool subdirectories to sha256 hashes. | `None` |
| extra_target_triples | Additional rust-style targets that rust toolchains should support. | `["wasm32-unknown-unknown", "wasm32-wasi"]` |
| extra_rustc_flags | Dictionary of target triples to list of extra flags to pass to rustc in non-exec configuration. | `None` |
| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration. | `None` |
| urls | 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). | `["https://static.rust-lang.org/dist/{}.tar.xz"]` |
-| version | **Deprecated**: Use versions
instead. | `None` |
-| versions | A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. ["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]
. | `[]` |
+| version | **Deprecated**: Use `versions` instead. | `None` |
+| versions | A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. `["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]`. | `[]` |
@@ -301,7 +234,7 @@ rust_repositories(kwargs )
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
-| kwargs | Keyword arguments for the rust_register_toolchains
macro. | none |
+| kwargs | Keyword arguments for the `rust_register_toolchains` macro. | none |
@@ -327,13 +260,13 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
| exec_triple | The Rust-style target that this compiler runs on | none |
| target_settings | A list of config_settings that must be satisfied by the target configuration in order for this set of toolchains to be selected during toolchain resolution. | `[]` |
| version | The version of the tool among "nightly", "beta', or an exact version. | `None` |
-| versions | A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. ["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]
. | `[]` |
+| versions | A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. `["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]`. | `[]` |
| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | `None` |
| global_allocator_library | Target that provides allocator functions a global allocator is used with cc_common.link. | `None` |
| extra_target_triples | Additional rust-style targets that this set of toolchains should support. If a map, values should be (optional) target_compatible_with lists for that particular target triple. | `{}` |
| iso_date | The date of the tool. | `None` |
| rustfmt_version | The version of rustfmt to be associated with the toolchain. | `None` |
-| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its edition
attribute. | `None` |
+| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute. | `None` |
| dev_components | Whether to download the rustc-dev components. Requires version to be "nightly". | `False` |
| extra_rustc_flags | Dictionary of target triples to list of extra flags to pass to rustc in non-exec configuration. | `None` |
| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration. | `None` |
@@ -343,7 +276,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
| auth | Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details. | `None` |
| netrc | .netrc file to use for authentication; mirrors the eponymous attribute from http_archive | `None` |
| auth_patterns | Override mapping of hostnames to authorization patterns; mirrors the eponymous attribute from http_archive | `None` |
-| register_toolchain | If True, the generated rust_toolchain
target will become a registered toolchain. | `True` |
+| register_toolchain | If True, the generated `rust_toolchain` target will become a registered toolchain. | `True` |
| exec_compatible_with | A list of constraints for the execution platform for this toolchain. | `None` |
| default_target_compatible_with | A list of constraints for the target platform for this toolchain when the exec platform is the same as the target platform. | `None` |
@@ -379,7 +312,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
| global_allocator_library | Target that provides allocator functions when a global allocator is used with cc_common.link. | `None` |
| iso_date | The date of the tool. | `None` |
| rustfmt_version | The version of rustfmt to be associated with the toolchain. | `None` |
-| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its edition
attribute. | `None` |
+| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute. | `None` |
| dev_components | Whether to download the rustc-dev components. Requires version to be "nightly". Defaults to False. | `False` |
| extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration. | `None` |
| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration. | `None` |
@@ -395,3 +328,69 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
str: The name of the registerable toolchain created by this rule.
+
+
+## rust_toolchain_repository_proxy
+
+
+rust_toolchain_repository_proxy(name , exec_compatible_with , repo_mapping , target_compatible_with ,
+ target_settings , toolchain , toolchain_type )
+
+
+Generates a toolchain-bearing repository that declares the toolchains from some other rust_toolchain_repository.
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| name | A unique name for this repository. | Name | required | |
+| exec_compatible_with | A list of constraints for the execution platform for this toolchain. | List of strings | optional | `[]` |
+| repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository. For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`). This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | Dictionary: String -> String | optional | |
+| target_compatible_with | A list of constraints for the target platform for this toolchain. | List of strings | optional | `[]` |
+| target_settings | A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution. | List of strings | optional | `[]` |
+| toolchain | The name of the toolchain implementation target. | String | required | |
+| toolchain_type | The toolchain type of the toolchain to declare | String | required | |
+
+
+
+
+## rust_toolchain_tools_repository
+
+
+rust_toolchain_tools_repository(name , allocator_library , auth , auth_patterns , dev_components ,
+ edition , exec_triple , extra_exec_rustc_flags , extra_rustc_flags ,
+ global_allocator_library , iso_date , netrc , opt_level , repo_mapping ,
+ rustfmt_version , sha256s , target_triple , urls , version )
+
+
+Composes a single workspace containing the toolchain components for compiling on a given platform to a series of target platforms.
+
+A given instance of this rule should be accompanied by a toolchain_repository_proxy invocation to declare its toolchains to Bazel; the indirection allows separating toolchain selection from toolchain fetching.
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| name | A unique name for this repository. | Name | required | |
+| allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | String | optional | `"@rules_rust//ffi/cc/allocator_library"` |
+| auth | Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details. | Dictionary: String -> String | optional | `{}` |
+| auth_patterns | A list of patterns to match against urls for which the auth object should be used. | List of strings | optional | `[]` |
+| dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | `False` |
+| edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute. | String | optional | `""` |
+| exec_triple | The Rust-style target that this compiler runs on | String | required | |
+| extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | `[]` |
+| extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | `[]` |
+| global_allocator_library | Target that provides allocator functions when a global allocator is used with cc_common.link. | String | optional | `"@rules_rust//ffi/cc/global_allocator_library"` |
+| iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | `""` |
+| netrc | .netrc file to use for authentication; mirrors the eponymous attribute from http_archive | String | optional | `""` |
+| opt_level | Rustc optimization levels. For more details see the documentation for `rust_toolchain.opt_level`. | Dictionary: String -> String | optional | `{}` |
+| repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository. For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`). This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | Dictionary: String -> String | optional | |
+| rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | `""` |
+| sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_register_toolchains](#rust_register_toolchains) for more details. | Dictionary: String -> String | optional | `{}` |
+| target_triple | The Rust-style target that this compiler builds for. | String | required | |
+| urls | 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). | List of strings | optional | `["https://static.rust-lang.org/dist/{}.tar.xz"]` |
+| version | The version of the tool among "nightly", "beta", or an exact version. | String | required | |
+
+
diff --git a/docs/rust_wasm_bindgen.md b/docs/rust_wasm_bindgen.md
index 0075888afe..98ed734abb 100644
--- a/docs/rust_wasm_bindgen.md
+++ b/docs/rust_wasm_bindgen.md
@@ -60,16 +60,15 @@ Generates javascript and typescript bindings for a webassembly module using [was
An example of this rule in use can be seen at [@rules_rust//examples/wasm](../examples/wasm)
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| bindgen_flags | Flags to pass directly to the bindgen executable. See https://github.com/rustwasm/wasm-bindgen/ for details. | List of strings | optional | []
|
-| target | The type of output to generate. See https://rustwasm.github.io/wasm-bindgen/reference/deployment.html for details. | String | optional | "bundler"
|
-| wasm_file | The .wasm
file or crate to generate bindings for. | Label | required | |
+| bindgen_flags | Flags to pass directly to the bindgen executable. See https://github.com/rustwasm/wasm-bindgen/ for details. | List of strings | optional | `[]` |
+| target | The type of output to generate. See https://rustwasm.github.io/wasm-bindgen/reference/deployment.html for details. | String | optional | `"bundler"` |
+| wasm_file | The `.wasm` file or crate to generate bindings for. | Label | required | |
@@ -110,14 +109,13 @@ For additional information, see the [Bazel toolchains documentation][toolchains]
[toolchains]: https://docs.bazel.build/versions/master/toolchains.html
-
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
-| bindgen | The label of a wasm-bindgen-cli
executable. | Label | optional | None
|
+| bindgen | The label of a `wasm-bindgen-cli` executable. | Label | optional | `None` |
@@ -135,9 +133,9 @@ Info about wasm-bindgen outputs.
| Name | Description |
| :------------- | :------------- |
-| js | Depset[File]: The Javascript files produced by wasm-bindgen
. |
-| ts | Depset[File]: The Typescript files produced by wasm-bindgen
. |
-| wasm | File: The .wasm
file generated by wasm-bindgen
. |
+| js | Depset[File]: The Javascript files produced by `wasm-bindgen`. |
+| ts | Depset[File]: The Typescript files produced by `wasm-bindgen`. |
+| wasm | File: The `.wasm` file generated by `wasm-bindgen`. |
diff --git a/docs/symbols.bzl b/docs/symbols.bzl
index 8ea979abe7..8bd44bde2c 100644
--- a/docs/symbols.bzl
+++ b/docs/symbols.bzl
@@ -21,7 +21,7 @@ load(
_cargo_env = "cargo_env",
)
load(
- "@rules_rust//crate_universe:docs.bzl",
+ "@rules_rust//crate_universe:docs_workspace.bzl",
_crate = "crate",
_crate_universe_dependencies = "crate_universe_dependencies",
_crates_repository = "crates_repository",