diff --git a/.github/release_notes.template b/.github/release_notes.template index 747d2b2f34..1809d58ad2 100644 --- a/.github/release_notes.template +++ b/.github/release_notes.template @@ -1,5 +1,13 @@ # {version} +## Bzlmod + +```python +bazel_dep(name = "rules_rust", version = "{version}") +``` + +## WORKSPACE + ```python load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( diff --git a/crate_universe/BUILD.bazel b/crate_universe/BUILD.bazel index 99d0176b8a..f32cbcc6dd 100644 --- a/crate_universe/BUILD.bazel +++ b/crate_universe/BUILD.bazel @@ -12,7 +12,8 @@ exports_files( "Cargo.toml", "Cargo.lock", "defs.bzl", - "docs.bzl", + "docs_bzlmod.bzl", + "docs_workspace.bzl", ], visibility = ["//visibility:public"], ) diff --git a/crate_universe/docs_bzlmod.bzl b/crate_universe/docs_bzlmod.bzl new file mode 100644 index 0000000000..9b6cf1a042 --- /dev/null +++ b/crate_universe/docs_bzlmod.bzl @@ -0,0 +1,21 @@ +"""# 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 +""" + +load( + "//crate_universe:extension.bzl", + _crate = "crate", +) + +crate = _crate diff --git a/crate_universe/docs.bzl b/crate_universe/docs_workspace.bzl similarity index 98% rename from crate_universe/docs.bzl rename to crate_universe/docs_workspace.bzl index 9fdeef702f..933ba1b650 100644 --- a/crate_universe/docs.bzl +++ b/crate_universe/docs_workspace.bzl @@ -2,6 +2,10 @@ Crate Universe is a set of Bazel rule for generating Rust targets using Cargo. +This doc describes using crate_universe from a WORKSPACE file. + +If you're using bzlmod, please see [the bzlmod equivalent of this doc](crate_universe_bzlmod.html). + ## Setup After loading `rules_rust` in your workspace, set the following to begin using `crate_universe`: diff --git a/crate_universe/private/module_extensions/BUILD.bazel b/crate_universe/private/module_extensions/BUILD.bazel index e69de29bb2..e4e24878d7 100644 --- a/crate_universe/private/module_extensions/BUILD.bazel +++ b/crate_universe/private/module_extensions/BUILD.bazel @@ -0,0 +1,13 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +filegroup( + name = "bzl_srcs", + srcs = glob(["*.bzl"]), + visibility = ["//visibility:public"], +) + +bzl_library( + name = "bzl_lib", + srcs = [":bzl_srcs"], + visibility = ["//visibility:public"], +) diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 78251c3a83..76c40e913c 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -1,5 +1,5 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") +load("@stardoc//stardoc:stardoc.bzl", "stardoc") load("//:page.bzl", "gen_header", "page") package(default_visibility = ["//visibility:private"]) @@ -11,8 +11,10 @@ bzl_library( "@com_google_protobuf//:bzl_srcs", ], deps = [ + "@bazel_features//:features", "@bazel_skylib//lib:paths", "@bazel_skylib//lib:selects", + "@bazel_skylib//lib:structs", "@bazel_skylib//rules:common_settings", "@rules_proto//proto:defs", "@rules_proto//proto:repositories", @@ -27,6 +29,7 @@ bzl_library( "@rules_rust//bindgen:bzl_lib", "@rules_rust//cargo:bzl_lib", "@rules_rust//crate_universe:bzl_lib", + "@rules_rust//crate_universe/private/module_extensions:bzl_lib", "@rules_rust//proto:bzl_lib", "@rules_rust//rust:bzl_lib", "@rules_rust//wasm_bindgen:bzl_lib", @@ -197,9 +200,16 @@ stardoc( ) stardoc( - name = "crate_universe", + name = "crate_universe_workspace", out = "crate_universe.md", - input = "@rules_rust//crate_universe:docs.bzl", + input = "@rules_rust//crate_universe:docs_workspace.bzl", + deps = [":all_docs"], +) + +stardoc( + name = "crate_universe_bzlmod", + out = "crate_universe_bzlmod.md", + input = "@rules_rust//crate_universe:docs_bzlmod.bzl", deps = [":all_docs"], ) diff --git a/docs/MODULE.bazel b/docs/MODULE.bazel index 00bb18361f..767b5cf167 100644 --- a/docs/MODULE.bazel +++ b/docs/MODULE.bazel @@ -1,6 +1,12 @@ -############################################################################### -# Bazel now uses Bzlmod by default to manage external dependencies. -# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. -# -# For more details, please check https://github.com/bazelbuild/bazel/issues/18958 -############################################################################### +bazel_dep( + name = "bazel_skylib", + version = "1.7.1", +) +bazel_dep( + name = "stardoc", + version = "0.6.2", +) +bazel_dep( + name = "bazel_features", + version = "1.11.0", +) diff --git a/docs/WORKSPACE.bazel b/docs/WORKSPACE.bazel index 9fb8387564..1056327b93 100644 --- a/docs/WORKSPACE.bazel +++ b/docs/WORKSPACE.bazel @@ -36,22 +36,3 @@ load( rust_wasm_bindgen_dependencies() rust_wasm_bindgen_register_toolchains() - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "io_bazel_stardoc", - patches = [ - # Pull in https://github.com/bazelbuild/stardoc/pull/143 - "//:stardoc-attr-default-wrappers.patch", - ], - sha256 = "dfbc364aaec143df5e6c52faf1f1166775a5b4408243f445f44b661cfdc3134f", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.5.6/stardoc-0.5.6.tar.gz", - "https://github.com/bazelbuild/stardoc/releases/download/0.5.6/stardoc-0.5.6.tar.gz", - ], -) - -load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") - -stardoc_repositories() diff --git a/docs/cargo.md b/docs/cargo.md index 2d5346843b..34ee8d1b30 100644 --- a/docs/cargo.md +++ b/docs/cargo.md @@ -6,44 +6,12 @@ * [cargo_dep_env](#cargo_dep_env) * [cargo_env](#cargo_env) - - -## 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. @@ -54,8 +22,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` | @@ -132,7 +100,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` | @@ -147,15 +115,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 | @@ -205,3 +173,35 @@ cargo_bootstrap_repository( str: A json encoded string of the environment variables + + +## 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"` | + + diff --git a/docs/crate_universe.md b/docs/crate_universe.md index fa3c02f4ab..8a02457964 100644 --- a/docs/crate_universe.md +++ b/docs/crate_universe.md @@ -4,6 +4,10 @@ Crate Universe is a set of Bazel rule for generating Rust targets using Cargo. +This doc describes using crate_universe from a WORKSPACE file. + +If you're using bzlmod, please see [the bzlmod equivalent of this doc](crate_universe_bzlmod.html). + ## Setup After loading `rules_rust` in your workspace, set the following to begin using `crate_universe`: @@ -290,140 +294,6 @@ There is an example of this in the "complicated dependencies" section of https:/ [ra]: https://rust-analyzer.github.io/ [cc-rs]: https://github.com/rust-lang/cc-rs - - - -## 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 | 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'), {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"] | - - ## crates_vendor @@ -483,7 +353,7 @@ directory next to where the target is defined. To run it, simply call: bazel run //3rdparty:crates_vendor ``` -<a id="#crates_vendor_repinning_updating_dependencies"></a> + ### Repinning / Updating Dependencies @@ -505,31 +375,29 @@ call against the generated workspace. The following table describes how to contr | `package_name` | `cargo upgrade --package package_name` | | `package_name@1.2.3` | `cargo upgrade --package package_name --precise 1.2.3` | - - **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | -| annotations | Extra settings to apply to crates. See [crate.annotation](#crateannotation). | Dictionary: String -> List of strings | optional | {} | -| bazel | The path to a bazel binary used to locate the output_base for the current workspace. | Label | optional | None | -| buildifier | The path to a [buildifier](https://github.com/bazelbuild/buildtools/blob/5.0.1/buildifier/README.md) binary used to format generated BUILD files. | Label | optional | //crate_universe/private/vendor:buildifier | -| cargo_bazel | The cargo-bazel binary to use for vendoring. If this attribute is not set, then a CARGO_BAZEL_GENERATOR_PATH action env will be used. | Label | optional | @cargo_bazel_bootstrap//:binary | -| 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 | -| generate_target_compatible_with | DEPRECATED: Moved to render_config. | Boolean | optional | True | -| manifests | A list of Cargo manifests (Cargo.toml files). | List of labels | optional | [] | -| mode | Flags determining how crates should be vendored. local is where crate source and BUILD files are written to the repository. remote is where only BUILD files are written and repository rules used to fetch source code. | String | optional | "remote" | -| packages | A set of crates (packages) specifications to depend on. See [crate.spec](#crate.spec). | Dictionary: String -> String | optional | {} | -| 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 | "" | -| repository_name | The name of the repository to generate for remote vendor modes. If unset, the label name will be used | String | optional | "" | -| 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"] | -| vendor_path | The path to a directory to write files into. Absolute paths will be treated as relative to the workspace root | String | optional | "crates" | +| annotations | Extra settings to apply to crates. See [crate.annotation](#crateannotation). | Dictionary: String -> List of strings | optional | `{}` | +| bazel | The path to a bazel binary used to locate the output_base for the current workspace. | Label | optional | `None` | +| buildifier | The path to a [buildifier](https://github.com/bazelbuild/buildtools/blob/5.0.1/buildifier/README.md) binary used to format generated BUILD files. | Label | optional | `"@rules_rust//crate_universe/private/vendor:buildifier"` | +| cargo_bazel | The cargo-bazel binary to use for vendoring. If this attribute is not set, then a `CARGO_BAZEL_GENERATOR_PATH` action env will be used. | Label | optional | `"@@cargo_bazel_bootstrap//:binary"` | +| 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` | +| generate_target_compatible_with | DEPRECATED: Moved to `render_config`. | Boolean | optional | `True` | +| manifests | A list of Cargo manifests (`Cargo.toml` files). | List of labels | optional | `[]` | +| mode | Flags determining how crates should be vendored. `local` is where crate source and BUILD files are written to the repository. `remote` is where only BUILD files are written and repository rules used to fetch source code. | String | optional | `"remote"` | +| packages | A set of crates (packages) specifications to depend on. See [crate.spec](#crate.spec). | Dictionary: String -> String | optional | `{}` | +| 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 | `""` | +| repository_name | The name of the repository to generate for `remote` vendor modes. If unset, the label name will be used | String | optional | `""` | +| 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"]` | +| vendor_path | The path to a directory to write files into. Absolute paths will be treated as relative to the workspace root | String | optional | `"crates"` | @@ -557,7 +425,7 @@ Setting any one flag will otherwise determine the contents of the returned dict. | proc_macro_dev | If True, dev proc_macro dependencies are included in the output list. | `False` | | build | If True, build dependencies are included in the output list. | `False` | | build_proc_macro | If True, build proc_macro dependencies are included in the output list. | `False` | -| package_name | The package name of the set of dependencies to look up. Defaults to native.package_name() when unset. | `None` | +| package_name | The package name of the set of dependencies to look up. Defaults to `native.package_name()` when unset. | `None` | **RETURNS** @@ -590,49 +458,13 @@ otherwise impact the contents of the returned list. | proc_macro_dev | If True, dev proc_macro dependencies are included in the output list. | `False` | | build | If True, build dependencies are included in the output list. | `False` | | build_proc_macro | If True, build proc_macro dependencies are included in the output list. | `False` | -| package_name | The package name of the set of dependencies to look up. Defaults to native.package_name() when unset. | `None` | +| package_name | The package name of the set of dependencies to look up. Defaults to `native.package_name()` when unset. | `None` | **RETURNS** list: A list of labels to generated rust targets (str) - - -## crate.spec - -
-crate.spec(package, version, artifact, lib, default_features, features, git, branch, tag, rev)
-
- -A constructor for a crate dependency. - -See [specifying dependencies][sd] in the Cargo book for more details. - -[sd]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| package | The explicit name of the package (used when attempting to alias a crate). | `None` | -| version | The exact version of the crate. Cannot be used with git. | `None` | -| artifact | Set to "bin" to pull in a binary crate as an artifact dependency. Requires a nightly Cargo. | `None` | -| 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. | `None` | -| default_features | Maps to the default-features flag. | `True` | -| features | A list of features to use for the crate | `[]` | -| git | The Git url to use for the crate. Cannot be used with version. | `None` | -| 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. | `None` | -| 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. | `None` | -| rev | The git revision of the remote crate. Tied with the git param. Only one of branch, tag or rev may be specified. | `None` | - -**RETURNS** - -string: A json encoded string of all inputs - - ## crate.annotation @@ -655,88 +487,124 @@ A collection of extra attributes and settings for a particular crate | Name | Description | Default Value | | :------------- | :------------- | :------------- | -| version | The version or semver-conditions to match with a crate. The wildcard * matches any version, including prerelease versions. | `"*"` | +| version | The version or semver-conditions to match with a crate. The wildcard `*` matches any version, including prerelease versions. | `"*"` | | additive_build_file | A file containing extra contents to write to the bottom of generated BUILD files. | `None` | | additive_build_file_content | Extra contents to write to the bottom of generated BUILD files. | `None` | -| alias_rule | Alias rule to use instead of native.alias(). Overrides [render_config](#render_config)'s 'default_alias_rule'. | `None` | -| build_script_data | A list of labels to add to a crate's cargo_build_script::data attribute. | `None` | -| build_script_tools | A list of labels to add to a crate's cargo_build_script::tools attribute. | `None` | -| build_script_data_glob | A list of glob patterns to add to a crate's cargo_build_script::data attribute. | `None` | -| build_script_deps | A list of labels to add to a crate's cargo_build_script::deps attribute. | `None` | -| build_script_env | Additional environment variables to set on a crate's cargo_build_script::env attribute. | `None` | -| build_script_proc_macro_deps | A list of labels to add to a crate's cargo_build_script::proc_macro_deps attribute. | `None` | +| alias_rule | Alias rule to use instead of `native.alias()`. Overrides [render_config](#render_config)'s 'default_alias_rule'. | `None` | +| build_script_data | A list of labels to add to a crate's `cargo_build_script::data` attribute. | `None` | +| build_script_tools | A list of labels to add to a crate's `cargo_build_script::tools` attribute. | `None` | +| build_script_data_glob | A list of glob patterns to add to a crate's `cargo_build_script::data` attribute. | `None` | +| build_script_deps | A list of labels to add to a crate's `cargo_build_script::deps` attribute. | `None` | +| build_script_env | Additional environment variables to set on a crate's `cargo_build_script::env` attribute. | `None` | +| build_script_proc_macro_deps | A list of labels to add to a crate's `cargo_build_script::proc_macro_deps` attribute. | `None` | | build_script_rundir | An override for the build script's rundir attribute. | `None` | -| build_script_rustc_env | Additional environment variables to set on a crate's cargo_build_script::env attribute. | `None` | -| build_script_toolchains | A list of labels to set on a crates's cargo_build_script::toolchains attribute. | `None` | -| compile_data | A list of labels to add to a crate's rust_library::compile_data attribute. | `None` | -| compile_data_glob | A list of glob patterns to add to a crate's rust_library::compile_data attribute. | `None` | -| crate_features | A list of strings to add to a crate's rust_library::crate_features attribute. | `None` | -| data | A list of labels to add to a crate's rust_library::data attribute. | `None` | -| data_glob | A list of glob patterns to add to a crate's rust_library::data attribute. | `None` | -| deps | A list of labels to add to a crate's rust_library::deps attribute. | `None` | +| build_script_rustc_env | Additional environment variables to set on a crate's `cargo_build_script::env` attribute. | `None` | +| build_script_toolchains | A list of labels to set on a crates's `cargo_build_script::toolchains` attribute. | `None` | +| compile_data | A list of labels to add to a crate's `rust_library::compile_data` attribute. | `None` | +| compile_data_glob | A list of glob patterns to add to a crate's `rust_library::compile_data` attribute. | `None` | +| crate_features | A list of strings to add to a crate's `rust_library::crate_features` attribute. | `None` | +| data | A list of labels to add to a crate's `rust_library::data` attribute. | `None` | +| data_glob | A list of glob patterns to add to a crate's `rust_library::data` attribute. | `None` | +| deps | A list of labels to add to a crate's `rust_library::deps` attribute. | `None` | | extra_aliased_targets | A list of targets to add to the generated aliases in the root crate_universe repository. | `None` | -| gen_binaries | As a list, the subset of the crate's bins that should get rust_binary targets produced. Or True to generate all, False to generate none. | `None` | +| gen_binaries | As a list, the subset of the crate's bins that should get `rust_binary` targets produced. Or `True` to generate all, `False` to generate none. | `None` | | disable_pipelining | If True, disables pipelining for library targets for this crate. | `False` | -| gen_build_script | An authorative flag to determine whether or not to produce cargo_build_script targets for the current crate. | `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) | `None` | -| 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) | `None` | -| 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) | `None` | -| proc_macro_deps | A list of labels to add to a crate's rust_library::proc_macro_deps attribute. | `None` | -| rustc_env | Additional variables to set on a crate's rust_library::rustc_env attribute. | `None` | -| rustc_env_files | A list of labels to set on a crate's rust_library::rustc_env_files attribute. | `None` | -| rustc_flags | A list of strings to set on a crate's rust_library::rustc_flags attribute. | `None` | +| gen_build_script | An authorative flag to determine whether or not to produce `cargo_build_script` targets for the current crate. | `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) | `None` | +| 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) | `None` | +| 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) | `None` | +| proc_macro_deps | A list of labels to add to a crate's `rust_library::proc_macro_deps` attribute. | `None` | +| rustc_env | Additional variables to set on a crate's `rust_library::rustc_env` attribute. | `None` | +| rustc_env_files | A list of labels to set on a crate's `rust_library::rustc_env_files` attribute. | `None` | +| rustc_flags | A list of strings to set on a crate's `rust_library::rustc_flags` attribute. | `None` | | 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. | `None` | -| override_targets | A dictionary of alternate tagets to use when something depends on this crate to allow the parent repo to provide its own version of this dependency. Keys can be proc_marco, build_script, lib, bin. | `None` | +| override_targets | A dictionary of alternate tagets to use when something depends on this crate to allow the parent repo to provide its own version of this dependency. Keys can be `proc_marco`, `build_script`, `lib`, `bin`. | `None` | **RETURNS** string: A json encoded string containing the specified version and separately all other inputs. - + -## crate.workspace_member +## crate.select
-crate.workspace_member(version, sha256)
+crate.select(common, selects)
 
-Define information for extra workspace members +A Starlark Select for `crate.annotation()`. **PARAMETERS** | Name | Description | Default Value | | :------------- | :------------- | :------------- | -| version | The semver of the crate to download. Must be an exact version. | none | -| sha256 | The sha256 checksum of the .crate file. | `None` | +| common | A value that applies to all configurations. | none | +| selects | A dict of `target_triple` to values. | none | + +**RETURNS** + +struct: A struct representing the Starlark Select. + + + + +## crate.spec + +
+crate.spec(package, version, artifact, lib, default_features, features, git, branch, tag, rev)
+
+ +A constructor for a crate dependency. + +See [specifying dependencies][sd] in the Cargo book for more details. + +[sd]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| package | The explicit name of the package (used when attempting to alias a crate). | `None` | +| version | The exact version of the crate. Cannot be used with `git`. | `None` | +| artifact | Set to "bin" to pull in a binary crate as an artifact dependency. Requires a nightly Cargo. | `None` | +| 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. | `None` | +| default_features | Maps to the `default-features` flag. | `True` | +| features | A list of features to use for the crate | `[]` | +| git | The Git url to use for the crate. Cannot be used with `version`. | `None` | +| 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. | `None` | +| 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. | `None` | +| rev | The git revision of the remote crate. Tied with the `git` param. Only one of branch, tag or rev may be specified. | `None` | **RETURNS** string: A json encoded string of all inputs - + -## crate.select +## crate.workspace_member
-crate.select(common, selects)
+crate.workspace_member(version, sha256)
 
-A Starlark Select for `crate.annotation()`. +Define information for extra workspace members **PARAMETERS** | Name | Description | Default Value | | :------------- | :------------- | :------------- | -| common | A value that applies to all configurations. | none | -| selects | A dict of target_triple to values. | none | +| version | The semver of the crate to download. Must be an exact version. | none | +| sha256 | The sha256 checksum of the `.crate` file. | `None` | **RETURNS** -struct: A struct representing the Starlark Select. +string: A json encoded string of all inputs @@ -755,7 +623,7 @@ Finds the fully qualified label of the requested crates for the package where th | Name | Description | Default Value | | :------------- | :------------- | :------------- | | deps | The desired list of crate targets. | none | -| package_name | The package name of the set of dependencies to look up. Defaults to native.package_name(). | `None` | +| package_name | The package name of the set of dependencies to look up. Defaults to `native.package_name()`. | `None` | **RETURNS** @@ -794,7 +662,7 @@ Define dependencies of the `cargo-bazel` Rust target | Name | Description | Default Value | | :------------- | :------------- | :------------- | | rust_version | The version of rust to use when generating dependencies. | `"1.79.0"` | -| bootstrap | If true, a cargo_bootstrap_repository target will be generated. | `False` | +| bootstrap | If true, a `cargo_bootstrap_repository` target will be generated. | `False` | | kwargs | Arguments to pass through to cargo_bazel_bootstrap. | none | **RETURNS** @@ -834,14 +702,14 @@ can be found below where the supported keys for each template can be found in th | Name | Description | Default Value | | :------------- | :------------- | :------------- | -| build_file_template | The base template to use for BUILD file names. The available format keys are [{name}, {version}]. | `"//:BUILD.{name}-{version}.bazel"` | -| crate_label_template | The base template to use for crate labels. The available format keys are [{repository}, {name}, {version}, {target}]. | `"@{repository}__{name}-{version}//:{target}"` | -| crate_repository_template | The base template to use for Crate label repository names. The available format keys are [{repository}, {name}, {version}]. | `"{repository}__{name}-{version}"` | -| crates_module_template | The pattern to use for the defs.bzl and BUILD.bazel file names used for the crates module. The available format keys are [{file}]. | `"//:{file}"` | -| default_alias_rule | Alias rule to use when generating aliases for all crates. Acceptable values are 'alias', 'dbg'/'fastbuild'/'opt' (transitions each crate's compilation_mode) or a string representing a rule in the form '<label to .bzl>:<rule>' 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_triplebeing 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}"` | +| build_file_template | The base template to use for BUILD file names. The available format keys are [`{name}`, {version}`]. | `"//:BUILD.{name}-{version}.bazel"` | +| crate_label_template | The base template to use for crate labels. The available format keys are [`{repository}`, `{name}`, `{version}`, `{target}`]. | `"@{repository}__{name}-{version}//:{target}"` | +| crate_repository_template | The base template to use for Crate label repository names. The available format keys are [`{repository}`, `{name}`, `{version}`]. | `"{repository}__{name}-{version}"` | +| crates_module_template | The pattern to use for the `defs.bzl` and `BUILD.bazel` file names used for the crates module. The available format keys are [`{file}`]. | `"//:{file}"` | +| default_alias_rule | Alias rule to use when generating aliases for all crates. Acceptable values are 'alias', 'dbg'/'fastbuild'/'opt' (transitions each crate's `compilation_mode`) or a string representing a rule in the form '