Updated toolchain repository rules to represent one toolchain per repo (#1442)
* Updated toolchain repository rules to represent one toolchain per repo
* Regenerate documentation
diff --git a/cargo/cargo_bootstrap.bzl b/cargo/cargo_bootstrap.bzl
index 3e04190..509ea47 100644
--- a/cargo/cargo_bootstrap.bzl
+++ b/cargo/cargo_bootstrap.bzl
@@ -273,7 +273,7 @@
"`{triple}` (eg. 'x86_64-unknown-linux-gnu'), `{arch}` (eg. 'aarch64'), `{vendor}` (eg. 'unknown'), " +
"`{system}` (eg. 'darwin'), and `{tool}` (eg. 'rustc.exe') will be replaced in the string if present."
),
- default = "@rust_{system}_{arch}//:bin/{tool}",
+ default = "@rust_{system}_{arch}__{triple}_tools//:bin/{tool}",
),
"rust_toolchain_repository_template": attr.string(
doc = "**Deprecated**: Please use `rust_toolchain_cargo_template` and `rust_toolchain_rustc_template`",
@@ -284,7 +284,7 @@
"`{triple}` (eg. 'x86_64-unknown-linux-gnu'), `{arch}` (eg. 'aarch64'), `{vendor}` (eg. 'unknown'), " +
"`{system}` (eg. 'darwin'), and `{tool}` (eg. 'rustc.exe') will be replaced in the string if present."
),
- default = "@rust_{system}_{arch}//:bin/{tool}",
+ default = "@rust_{system}_{arch}__{triple}_tools//:bin/{tool}",
),
"srcs": attr.label_list(
doc = "Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made",
diff --git a/crate_universe/private/crates_repository.bzl b/crate_universe/private/crates_repository.bzl
index d923dc9..a440329 100644
--- a/crate_universe/private/crates_repository.bzl
+++ b/crate_universe/private/crates_repository.bzl
@@ -262,7 +262,7 @@
"`{system}` (eg. 'darwin'), `{cfg}` (eg. 'exec'), and `{tool}` (eg. 'rustc.exe') will be replaced in " +
"the string if present."
),
- default = "@rust_{system}_{arch}//:bin/{tool}",
+ default = "@rust_{system}_{arch}__{triple}_tools//:bin/{tool}",
),
"rust_toolchain_rustc_template": attr.string(
doc = (
@@ -271,7 +271,7 @@
"`{system}` (eg. 'darwin'), `{cfg}` (eg. 'exec'), and `{tool}` (eg. 'cargo.exe') will be replaced in " +
"the string if present."
),
- default = "@rust_{system}_{arch}//:bin/{tool}",
+ default = "@rust_{system}_{arch}__{triple}_tools//:bin/{tool}",
),
"rust_version": attr.string(
doc = "The version of Rust the currently registered toolchain is using. Eg. `1.56.0`, or `nightly-2021-09-08`",
diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel
index 5e2a6bc..3b3c30b 100644
--- a/docs/BUILD.bazel
+++ b/docs/BUILD.bazel
@@ -128,6 +128,7 @@
"rust_stdlib_filegroup",
"rust_toolchain_repository_proxy",
"rust_toolchain_repository",
+ "rust_toolchain_tools_repository",
"rust_toolchain",
],
),
diff --git a/docs/cargo.md b/docs/cargo.md
index a269824..a9de456 100644
--- a/docs/cargo.md
+++ b/docs/cargo.md
@@ -32,9 +32,9 @@
| <a id="cargo_bootstrap_repository-env_label"></a>env_label | A mapping of platform triple to a set of environment variables. This attribute differs from <code>env</code> 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 <code>*</code> applies to all platforms. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
| <a id="cargo_bootstrap_repository-iso_date"></a>iso_date | The iso_date of cargo binary the resolver should use. Note: This can only be set if <code>version</code> is <code>beta</code> or <code>nightly</code> | String | optional | "" |
| <a id="cargo_bootstrap_repository-repo_mapping"></a>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 <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | required | |
-| <a id="cargo_bootstrap_repository-rust_toolchain_cargo_template"></a>rust_toolchain_cargo_template | The template to use for finding the host <code>cargo</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}//:bin/{tool}" |
+| <a id="cargo_bootstrap_repository-rust_toolchain_cargo_template"></a>rust_toolchain_cargo_template | The template to use for finding the host <code>cargo</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}__{triple}_tools//:bin/{tool}" |
| <a id="cargo_bootstrap_repository-rust_toolchain_repository_template"></a>rust_toolchain_repository_template | **Deprecated**: Please use <code>rust_toolchain_cargo_template</code> and <code>rust_toolchain_rustc_template</code> | String | optional | "" |
-| <a id="cargo_bootstrap_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}//:bin/{tool}" |
+| <a id="cargo_bootstrap_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}__{triple}_tools//:bin/{tool}" |
| <a id="cargo_bootstrap_repository-srcs"></a>srcs | Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="cargo_bootstrap_repository-timeout"></a>timeout | Maximum duration of the Cargo build command in seconds | Integer | optional | 600 |
| <a id="cargo_bootstrap_repository-version"></a>version | The version of cargo the resolver should use | String | optional | "1.62.0" |
diff --git a/docs/crate_universe.md b/docs/crate_universe.md
index f69f30e..21fb232 100644
--- a/docs/crate_universe.md
+++ b/docs/crate_universe.md
@@ -292,8 +292,8 @@
| <a id="crates_repository-quiet"></a>quiet | If stdout and stderr should not be printed to the terminal. | Boolean | optional | True |
| <a id="crates_repository-render_config"></a>render_config | The configuration flags to use for rendering. Use <code>//crate_universe:defs.bzl\%render_config</code> to generate the value for this field. If unset, the defaults defined there will be used. | String | optional | "" |
| <a id="crates_repository-repo_mapping"></a>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 <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | required | |
-| <a id="crates_repository-rust_toolchain_cargo_template"></a>rust_toolchain_cargo_template | The template to use for finding the host <code>cargo</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{cfg}</code> (eg. 'exec'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}//:bin/{tool}" |
-| <a id="crates_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{cfg}</code> (eg. 'exec'), and <code>{tool}</code> (eg. 'cargo.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}//:bin/{tool}" |
+| <a id="crates_repository-rust_toolchain_cargo_template"></a>rust_toolchain_cargo_template | The template to use for finding the host <code>cargo</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{cfg}</code> (eg. 'exec'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}__{triple}_tools//:bin/{tool}" |
+| <a id="crates_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{cfg}</code> (eg. 'exec'), and <code>{tool}</code> (eg. 'cargo.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}__{triple}_tools//:bin/{tool}" |
| <a id="crates_repository-rust_version"></a>rust_version | The version of Rust the currently registered toolchain is using. Eg. <code>1.56.0</code>, or <code>nightly-2021-09-08</code> | String | optional | "1.62.0" |
| <a id="crates_repository-splicing_config"></a>splicing_config | The configuration flags to use for splicing Cargo maniests. Use <code>//crate_universe:defs.bzl\%rsplicing_config</code> to generate the value for this field. If unset, the defaults defined there will be used. | String | optional | "" |
| <a id="crates_repository-supported_platform_triples"></a>supported_platform_triples | A set of all platform triples to consider when generating dependencies. | List of strings | optional | ["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", "aarch64-apple-darwin", "aarch64-apple-ios", "aarch64-apple-ios-sim", "aarch64-linux-android", "aarch64-unknown-linux-gnu", "arm-unknown-linux-gnueabi", "armv7-unknown-linux-gnueabi", "armv7-linux-androideabi", "i686-linux-android", "i686-unknown-freebsd", "powerpc-unknown-linux-gnu", "s390x-unknown-linux-gnu", "wasm32-unknown-unknown", "wasm32-wasi", "x86_64-apple-ios", "x86_64-linux-android", "x86_64-unknown-freebsd", "riscv32imc-unknown-none-elf"] |
diff --git a/docs/flatten.md b/docs/flatten.md
index 12c4d41..b88dc56 100644
--- a/docs/flatten.md
+++ b/docs/flatten.md
@@ -41,6 +41,7 @@
* [rust_toolchain](#rust_toolchain)
* [rust_toolchain_repository](#rust_toolchain_repository)
* [rust_toolchain_repository_proxy](#rust_toolchain_repository_proxy)
+* [rust_toolchain_tools_repository](#rust_toolchain_tools_repository)
* [rust_wasm_bindgen](#rust_wasm_bindgen)
* [rust_wasm_bindgen_dependencies](#rust_wasm_bindgen_dependencies)
* [rust_wasm_bindgen_register_toolchains](#rust_wasm_bindgen_register_toolchains)
@@ -94,9 +95,9 @@
| <a id="cargo_bootstrap_repository-env_label"></a>env_label | A mapping of platform triple to a set of environment variables. This attribute differs from <code>env</code> 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 <code>*</code> applies to all platforms. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
| <a id="cargo_bootstrap_repository-iso_date"></a>iso_date | The iso_date of cargo binary the resolver should use. Note: This can only be set if <code>version</code> is <code>beta</code> or <code>nightly</code> | String | optional | "" |
| <a id="cargo_bootstrap_repository-repo_mapping"></a>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 <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | required | |
-| <a id="cargo_bootstrap_repository-rust_toolchain_cargo_template"></a>rust_toolchain_cargo_template | The template to use for finding the host <code>cargo</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}//:bin/{tool}" |
+| <a id="cargo_bootstrap_repository-rust_toolchain_cargo_template"></a>rust_toolchain_cargo_template | The template to use for finding the host <code>cargo</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}__{triple}_tools//:bin/{tool}" |
| <a id="cargo_bootstrap_repository-rust_toolchain_repository_template"></a>rust_toolchain_repository_template | **Deprecated**: Please use <code>rust_toolchain_cargo_template</code> and <code>rust_toolchain_rustc_template</code> | String | optional | "" |
-| <a id="cargo_bootstrap_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}//:bin/{tool}" |
+| <a id="cargo_bootstrap_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | "@rust_{system}_{arch}__{triple}_tools//:bin/{tool}" |
| <a id="cargo_bootstrap_repository-srcs"></a>srcs | Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="cargo_bootstrap_repository-timeout"></a>timeout | Maximum duration of the Cargo build command in seconds | Integer | optional | 600 |
| <a id="cargo_bootstrap_repository-version"></a>version | The version of cargo the resolver should use | String | optional | "1.62.0" |
@@ -1141,14 +1142,39 @@
| <a id="rust_toolchain-target_triple"></a>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 | "" |
-<a id="#rust_toolchain_repository"></a>
+<a id="#rust_toolchain_repository_proxy"></a>
-## rust_toolchain_repository
+## rust_toolchain_repository_proxy
<pre>
-rust_toolchain_repository(<a href="#rust_toolchain_repository-name">name</a>, <a href="#rust_toolchain_repository-auth">auth</a>, <a href="#rust_toolchain_repository-dev_components">dev_components</a>, <a href="#rust_toolchain_repository-edition">edition</a>, <a href="#rust_toolchain_repository-exec_triple">exec_triple</a>, <a href="#rust_toolchain_repository-extra_target_triples">extra_target_triples</a>,
- <a href="#rust_toolchain_repository-include_rustc_srcs">include_rustc_srcs</a>, <a href="#rust_toolchain_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_repository-repo_mapping">repo_mapping</a>, <a href="#rust_toolchain_repository-rustfmt_version">rustfmt_version</a>, <a href="#rust_toolchain_repository-sha256s">sha256s</a>,
- <a href="#rust_toolchain_repository-toolchain_name_prefix">toolchain_name_prefix</a>, <a href="#rust_toolchain_repository-urls">urls</a>, <a href="#rust_toolchain_repository-version">version</a>)
+rust_toolchain_repository_proxy(<a href="#rust_toolchain_repository_proxy-name">name</a>, <a href="#rust_toolchain_repository_proxy-exec_compatible_with">exec_compatible_with</a>, <a href="#rust_toolchain_repository_proxy-exec_triple">exec_triple</a>, <a href="#rust_toolchain_repository_proxy-parent_workspace_name">parent_workspace_name</a>,
+ <a href="#rust_toolchain_repository_proxy-repo_mapping">repo_mapping</a>, <a href="#rust_toolchain_repository_proxy-target_compatible_with">target_compatible_with</a>, <a href="#rust_toolchain_repository_proxy-target_triple">target_triple</a>)
+</pre>
+
+Generates a toolchain-bearing repository that declares the toolchains from some other rust_toolchain_repository.
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="rust_toolchain_repository_proxy-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
+| <a id="rust_toolchain_repository_proxy-exec_compatible_with"></a>exec_compatible_with | TODO | List of strings | optional | [] |
+| <a id="rust_toolchain_repository_proxy-exec_triple"></a>exec_triple | The Rust-style target triple for the compilation platform | String | required | |
+| <a id="rust_toolchain_repository_proxy-parent_workspace_name"></a>parent_workspace_name | The name of the other rust_toolchain_repository | String | required | |
+| <a id="rust_toolchain_repository_proxy-repo_mapping"></a>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 <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | required | |
+| <a id="rust_toolchain_repository_proxy-target_compatible_with"></a>target_compatible_with | TODO | List of strings | optional | [] |
+| <a id="rust_toolchain_repository_proxy-target_triple"></a>target_triple | The Rust-style target that this compiler builds for | String | required | |
+
+
+<a id="#rust_toolchain_tools_repository"></a>
+
+## rust_toolchain_tools_repository
+
+<pre>
+rust_toolchain_tools_repository(<a href="#rust_toolchain_tools_repository-name">name</a>, <a href="#rust_toolchain_tools_repository-auth">auth</a>, <a href="#rust_toolchain_tools_repository-dev_components">dev_components</a>, <a href="#rust_toolchain_tools_repository-edition">edition</a>, <a href="#rust_toolchain_tools_repository-exec_triple">exec_triple</a>,
+ <a href="#rust_toolchain_tools_repository-include_rustc_srcs">include_rustc_srcs</a>, <a href="#rust_toolchain_tools_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_tools_repository-repo_mapping">repo_mapping</a>, <a href="#rust_toolchain_tools_repository-rustfmt_version">rustfmt_version</a>, <a href="#rust_toolchain_tools_repository-sha256s">sha256s</a>,
+ <a href="#rust_toolchain_tools_repository-target_triple">target_triple</a>, <a href="#rust_toolchain_tools_repository-urls">urls</a>, <a href="#rust_toolchain_tools_repository-version">version</a>)
</pre>
Composes a single workspace containing the toolchain components for compiling on a given platform to a series of target platforms.
@@ -1160,44 +1186,19 @@
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="rust_toolchain_repository-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
-| <a id="rust_toolchain_repository-auth"></a>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. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="rust_toolchain_repository-dev_components"></a>dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | False |
-| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | String | optional | "" |
-| <a id="rust_toolchain_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | String | required | |
-| <a id="rust_toolchain_repository-extra_target_triples"></a>extra_target_triples | Additional rust-style targets that this set of toolchains should support. | List of strings | optional | [] |
-| <a id="rust_toolchain_repository-include_rustc_srcs"></a>include_rustc_srcs | Whether to download and unpack the rustc source files. These are very large, and slow to unpack, but are required to support rust analyzer. An environment variable <code>RULES_RUST_TOOLCHAIN_INCLUDE_RUSTC_SRCS</code> can also be used to control this attribute. This variable will take precedence over the hard coded attribute. Setting it to <code>true</code> to activates this attribute where all other values deactivate it. | Boolean | optional | False |
-| <a id="rust_toolchain_repository-iso_date"></a>iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | "" |
-| <a id="rust_toolchain_repository-repo_mapping"></a>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 <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | required | |
-| <a id="rust_toolchain_repository-rustfmt_version"></a>rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | "" |
-| <a id="rust_toolchain_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="rust_toolchain_repository-toolchain_name_prefix"></a>toolchain_name_prefix | The per-target prefix expected for the rust_toolchain declarations in the parent workspace. | String | optional | "" |
-| <a id="rust_toolchain_repository-urls"></a>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.gz"] |
-| <a id="rust_toolchain_repository-version"></a>version | The version of the tool among "nightly", "beta", or an exact version. | String | required | |
-
-
-<a id="#rust_toolchain_repository_proxy"></a>
-
-## rust_toolchain_repository_proxy
-
-<pre>
-rust_toolchain_repository_proxy(<a href="#rust_toolchain_repository_proxy-name">name</a>, <a href="#rust_toolchain_repository_proxy-exec_triple">exec_triple</a>, <a href="#rust_toolchain_repository_proxy-extra_target_triples">extra_target_triples</a>, <a href="#rust_toolchain_repository_proxy-parent_workspace_name">parent_workspace_name</a>,
- <a href="#rust_toolchain_repository_proxy-repo_mapping">repo_mapping</a>, <a href="#rust_toolchain_repository_proxy-toolchain_name_prefix">toolchain_name_prefix</a>)
-</pre>
-
-Generates a toolchain-bearing repository that declares the toolchains from some other rust_toolchain_repository.
-
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="rust_toolchain_repository_proxy-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
-| <a id="rust_toolchain_repository_proxy-exec_triple"></a>exec_triple | The Rust-style target triple for the compilation platform | String | required | |
-| <a id="rust_toolchain_repository_proxy-extra_target_triples"></a>extra_target_triples | The Rust-style triples for extra compilation targets | List of strings | optional | [] |
-| <a id="rust_toolchain_repository_proxy-parent_workspace_name"></a>parent_workspace_name | The name of the other rust_toolchain_repository | String | required | |
-| <a id="rust_toolchain_repository_proxy-repo_mapping"></a>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 <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | required | |
-| <a id="rust_toolchain_repository_proxy-toolchain_name_prefix"></a>toolchain_name_prefix | The per-target prefix expected for the rust_toolchain declarations in the parent workspace. | String | optional | "" |
+| <a id="rust_toolchain_tools_repository-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
+| <a id="rust_toolchain_tools_repository-auth"></a>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. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="rust_toolchain_tools_repository-dev_components"></a>dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | False |
+| <a id="rust_toolchain_tools_repository-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | String | optional | "" |
+| <a id="rust_toolchain_tools_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | String | required | |
+| <a id="rust_toolchain_tools_repository-include_rustc_srcs"></a>include_rustc_srcs | Whether to download and unpack the rustc source files. These are very large, and slow to unpack, but are required to support rust analyzer. An environment variable <code>RULES_RUST_TOOLCHAIN_INCLUDE_RUSTC_SRCS</code> can also be used to control this attribute. This variable will take precedence over the hard coded attribute. Setting it to <code>true</code> to activates this attribute where all other values deactivate it. | Boolean | optional | False |
+| <a id="rust_toolchain_tools_repository-iso_date"></a>iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | "" |
+| <a id="rust_toolchain_tools_repository-repo_mapping"></a>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 <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | required | |
+| <a id="rust_toolchain_tools_repository-rustfmt_version"></a>rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | "" |
+| <a id="rust_toolchain_tools_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="rust_toolchain_tools_repository-target_triple"></a>target_triple | The Rust-style target that this compiler builds for | String | required | |
+| <a id="rust_toolchain_tools_repository-urls"></a>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.gz"] |
+| <a id="rust_toolchain_tools_repository-version"></a>version | The version of the tool among "nightly", "beta", or an exact version. | String | required | |
<a id="#rust_wasm_bindgen"></a>
@@ -1786,6 +1787,46 @@
| <a id="rust_test_suite-kwargs"></a>kwargs | Additional keyword arguments for the underyling [rust_test](#rust_test) targets. The <code>tags</code> argument is also passed to the generated <code>test_suite</code> target. | none |
+<a id="#rust_toolchain_repository"></a>
+
+## rust_toolchain_repository
+
+<pre>
+rust_toolchain_repository(<a href="#rust_toolchain_repository-name">name</a>, <a href="#rust_toolchain_repository-version">version</a>, <a href="#rust_toolchain_repository-exec_triple">exec_triple</a>, <a href="#rust_toolchain_repository-target_triple">target_triple</a>, <a href="#rust_toolchain_repository-exec_compatible_with">exec_compatible_with</a>,
+ <a href="#rust_toolchain_repository-target_compatible_with">target_compatible_with</a>, <a href="#rust_toolchain_repository-include_rustc_srcs">include_rustc_srcs</a>, <a href="#rust_toolchain_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_repository-rustfmt_version">rustfmt_version</a>,
+ <a href="#rust_toolchain_repository-edition">edition</a>, <a href="#rust_toolchain_repository-dev_components">dev_components</a>, <a href="#rust_toolchain_repository-sha256s">sha256s</a>, <a href="#rust_toolchain_repository-urls">urls</a>, <a href="#rust_toolchain_repository-auth">auth</a>)
+</pre>
+
+Assembles a remote repository for the given toolchain params, produces a proxy repository to contain the toolchain declaration, and registers the toolchains.
+
+N.B. A "proxy repository" is needed to allow for registering the toolchain (with constraints) without actually downloading the toolchain.
+
+
+**PARAMETERS**
+
+
+| Name | Description | Default Value |
+| :------------- | :------------- | :------------- |
+| <a id="rust_toolchain_repository-name"></a>name | The name of the generated repository | none |
+| <a id="rust_toolchain_repository-version"></a>version | The version of the tool among "nightly", "beta', or an exact version. | none |
+| <a id="rust_toolchain_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on. | none |
+| <a id="rust_toolchain_repository-target_triple"></a>target_triple | The Rust-style target to build for. | none |
+| <a id="rust_toolchain_repository-exec_compatible_with"></a>exec_compatible_with | A list of constraints for the execution platform for this toolchain. | <code>None</code> |
+| <a id="rust_toolchain_repository-target_compatible_with"></a>target_compatible_with | A list of constraints for the target platform for this toolchain. | <code>None</code> |
+| <a id="rust_toolchain_repository-include_rustc_srcs"></a>include_rustc_srcs | Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. | <code>False</code> |
+| <a id="rust_toolchain_repository-iso_date"></a>iso_date | The date of the tool. Defaults to None. | <code>None</code> |
+| <a id="rust_toolchain_repository-rustfmt_version"></a>rustfmt_version | The version of rustfmt to be associated with the toolchain. Defaults to None. | <code>None</code> |
+| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | <code>None</code> |
+| <a id="rust_toolchain_repository-dev_components"></a>dev_components | Whether to download the rustc-dev components. Requires version to be "nightly". Defaults to False. | <code>False</code> |
+| <a id="rust_toolchain_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. | <code>None</code> |
+| <a id="rust_toolchain_repository-urls"></a>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). Defaults to ['https://static.rust-lang.org/dist/{}.tar.gz'] | <code>["https://static.rust-lang.org/dist/{}.tar.gz"]</code> |
+| <a id="rust_toolchain_repository-auth"></a>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. | <code>None</code> |
+
+**RETURNS**
+
+str: The name of the registerable toolchain created by this rule.
+
+
<a id="#rust_wasm_bindgen_dependencies"></a>
## rust_wasm_bindgen_dependencies
diff --git a/docs/rust_repositories.md b/docs/rust_repositories.md
index c040488..96c127f 100644
--- a/docs/rust_repositories.md
+++ b/docs/rust_repositories.md
@@ -8,6 +8,7 @@
* [rust_stdlib_filegroup](#rust_stdlib_filegroup)
* [rust_toolchain_repository_proxy](#rust_toolchain_repository_proxy)
* [rust_toolchain_repository](#rust_toolchain_repository)
+* [rust_toolchain_tools_repository](#rust_toolchain_tools_repository)
* [rust_toolchain](#rust_toolchain)
<a id="#rust_stdlib_filegroup"></a>
@@ -114,14 +115,39 @@
| <a id="rust_toolchain-target_triple"></a>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 | "" |
-<a id="#rust_toolchain_repository"></a>
+<a id="#rust_toolchain_repository_proxy"></a>
-## rust_toolchain_repository
+## rust_toolchain_repository_proxy
<pre>
-rust_toolchain_repository(<a href="#rust_toolchain_repository-name">name</a>, <a href="#rust_toolchain_repository-auth">auth</a>, <a href="#rust_toolchain_repository-dev_components">dev_components</a>, <a href="#rust_toolchain_repository-edition">edition</a>, <a href="#rust_toolchain_repository-exec_triple">exec_triple</a>, <a href="#rust_toolchain_repository-extra_target_triples">extra_target_triples</a>,
- <a href="#rust_toolchain_repository-include_rustc_srcs">include_rustc_srcs</a>, <a href="#rust_toolchain_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_repository-repo_mapping">repo_mapping</a>, <a href="#rust_toolchain_repository-rustfmt_version">rustfmt_version</a>, <a href="#rust_toolchain_repository-sha256s">sha256s</a>,
- <a href="#rust_toolchain_repository-toolchain_name_prefix">toolchain_name_prefix</a>, <a href="#rust_toolchain_repository-urls">urls</a>, <a href="#rust_toolchain_repository-version">version</a>)
+rust_toolchain_repository_proxy(<a href="#rust_toolchain_repository_proxy-name">name</a>, <a href="#rust_toolchain_repository_proxy-exec_compatible_with">exec_compatible_with</a>, <a href="#rust_toolchain_repository_proxy-exec_triple">exec_triple</a>, <a href="#rust_toolchain_repository_proxy-parent_workspace_name">parent_workspace_name</a>,
+ <a href="#rust_toolchain_repository_proxy-repo_mapping">repo_mapping</a>, <a href="#rust_toolchain_repository_proxy-target_compatible_with">target_compatible_with</a>, <a href="#rust_toolchain_repository_proxy-target_triple">target_triple</a>)
+</pre>
+
+Generates a toolchain-bearing repository that declares the toolchains from some other rust_toolchain_repository.
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="rust_toolchain_repository_proxy-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
+| <a id="rust_toolchain_repository_proxy-exec_compatible_with"></a>exec_compatible_with | TODO | List of strings | optional | [] |
+| <a id="rust_toolchain_repository_proxy-exec_triple"></a>exec_triple | The Rust-style target triple for the compilation platform | String | required | |
+| <a id="rust_toolchain_repository_proxy-parent_workspace_name"></a>parent_workspace_name | The name of the other rust_toolchain_repository | String | required | |
+| <a id="rust_toolchain_repository_proxy-repo_mapping"></a>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 <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | required | |
+| <a id="rust_toolchain_repository_proxy-target_compatible_with"></a>target_compatible_with | TODO | List of strings | optional | [] |
+| <a id="rust_toolchain_repository_proxy-target_triple"></a>target_triple | The Rust-style target that this compiler builds for | String | required | |
+
+
+<a id="#rust_toolchain_tools_repository"></a>
+
+## rust_toolchain_tools_repository
+
+<pre>
+rust_toolchain_tools_repository(<a href="#rust_toolchain_tools_repository-name">name</a>, <a href="#rust_toolchain_tools_repository-auth">auth</a>, <a href="#rust_toolchain_tools_repository-dev_components">dev_components</a>, <a href="#rust_toolchain_tools_repository-edition">edition</a>, <a href="#rust_toolchain_tools_repository-exec_triple">exec_triple</a>,
+ <a href="#rust_toolchain_tools_repository-include_rustc_srcs">include_rustc_srcs</a>, <a href="#rust_toolchain_tools_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_tools_repository-repo_mapping">repo_mapping</a>, <a href="#rust_toolchain_tools_repository-rustfmt_version">rustfmt_version</a>, <a href="#rust_toolchain_tools_repository-sha256s">sha256s</a>,
+ <a href="#rust_toolchain_tools_repository-target_triple">target_triple</a>, <a href="#rust_toolchain_tools_repository-urls">urls</a>, <a href="#rust_toolchain_tools_repository-version">version</a>)
</pre>
Composes a single workspace containing the toolchain components for compiling on a given platform to a series of target platforms.
@@ -133,44 +159,19 @@
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="rust_toolchain_repository-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
-| <a id="rust_toolchain_repository-auth"></a>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. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="rust_toolchain_repository-dev_components"></a>dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | False |
-| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | String | optional | "" |
-| <a id="rust_toolchain_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | String | required | |
-| <a id="rust_toolchain_repository-extra_target_triples"></a>extra_target_triples | Additional rust-style targets that this set of toolchains should support. | List of strings | optional | [] |
-| <a id="rust_toolchain_repository-include_rustc_srcs"></a>include_rustc_srcs | Whether to download and unpack the rustc source files. These are very large, and slow to unpack, but are required to support rust analyzer. An environment variable <code>RULES_RUST_TOOLCHAIN_INCLUDE_RUSTC_SRCS</code> can also be used to control this attribute. This variable will take precedence over the hard coded attribute. Setting it to <code>true</code> to activates this attribute where all other values deactivate it. | Boolean | optional | False |
-| <a id="rust_toolchain_repository-iso_date"></a>iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | "" |
-| <a id="rust_toolchain_repository-repo_mapping"></a>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 <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | required | |
-| <a id="rust_toolchain_repository-rustfmt_version"></a>rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | "" |
-| <a id="rust_toolchain_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="rust_toolchain_repository-toolchain_name_prefix"></a>toolchain_name_prefix | The per-target prefix expected for the rust_toolchain declarations in the parent workspace. | String | optional | "" |
-| <a id="rust_toolchain_repository-urls"></a>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.gz"] |
-| <a id="rust_toolchain_repository-version"></a>version | The version of the tool among "nightly", "beta", or an exact version. | String | required | |
-
-
-<a id="#rust_toolchain_repository_proxy"></a>
-
-## rust_toolchain_repository_proxy
-
-<pre>
-rust_toolchain_repository_proxy(<a href="#rust_toolchain_repository_proxy-name">name</a>, <a href="#rust_toolchain_repository_proxy-exec_triple">exec_triple</a>, <a href="#rust_toolchain_repository_proxy-extra_target_triples">extra_target_triples</a>, <a href="#rust_toolchain_repository_proxy-parent_workspace_name">parent_workspace_name</a>,
- <a href="#rust_toolchain_repository_proxy-repo_mapping">repo_mapping</a>, <a href="#rust_toolchain_repository_proxy-toolchain_name_prefix">toolchain_name_prefix</a>)
-</pre>
-
-Generates a toolchain-bearing repository that declares the toolchains from some other rust_toolchain_repository.
-
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="rust_toolchain_repository_proxy-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
-| <a id="rust_toolchain_repository_proxy-exec_triple"></a>exec_triple | The Rust-style target triple for the compilation platform | String | required | |
-| <a id="rust_toolchain_repository_proxy-extra_target_triples"></a>extra_target_triples | The Rust-style triples for extra compilation targets | List of strings | optional | [] |
-| <a id="rust_toolchain_repository_proxy-parent_workspace_name"></a>parent_workspace_name | The name of the other rust_toolchain_repository | String | required | |
-| <a id="rust_toolchain_repository_proxy-repo_mapping"></a>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 <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | required | |
-| <a id="rust_toolchain_repository_proxy-toolchain_name_prefix"></a>toolchain_name_prefix | The per-target prefix expected for the rust_toolchain declarations in the parent workspace. | String | optional | "" |
+| <a id="rust_toolchain_tools_repository-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
+| <a id="rust_toolchain_tools_repository-auth"></a>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. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="rust_toolchain_tools_repository-dev_components"></a>dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | False |
+| <a id="rust_toolchain_tools_repository-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | String | optional | "" |
+| <a id="rust_toolchain_tools_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | String | required | |
+| <a id="rust_toolchain_tools_repository-include_rustc_srcs"></a>include_rustc_srcs | Whether to download and unpack the rustc source files. These are very large, and slow to unpack, but are required to support rust analyzer. An environment variable <code>RULES_RUST_TOOLCHAIN_INCLUDE_RUSTC_SRCS</code> can also be used to control this attribute. This variable will take precedence over the hard coded attribute. Setting it to <code>true</code> to activates this attribute where all other values deactivate it. | Boolean | optional | False |
+| <a id="rust_toolchain_tools_repository-iso_date"></a>iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | "" |
+| <a id="rust_toolchain_tools_repository-repo_mapping"></a>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 <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | required | |
+| <a id="rust_toolchain_tools_repository-rustfmt_version"></a>rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | "" |
+| <a id="rust_toolchain_tools_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="rust_toolchain_tools_repository-target_triple"></a>target_triple | The Rust-style target that this compiler builds for | String | required | |
+| <a id="rust_toolchain_tools_repository-urls"></a>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.gz"] |
+| <a id="rust_toolchain_tools_repository-version"></a>version | The version of the tool among "nightly", "beta", or an exact version. | String | required | |
<a id="#rules_rust_dependencies"></a>
@@ -280,3 +281,43 @@
| <a id="rust_repository_set-register_toolchain"></a>register_toolchain | If True, the generated <code>rust_toolchain</code> target will become a registered toolchain. | <code>True</code> |
+<a id="#rust_toolchain_repository"></a>
+
+## rust_toolchain_repository
+
+<pre>
+rust_toolchain_repository(<a href="#rust_toolchain_repository-name">name</a>, <a href="#rust_toolchain_repository-version">version</a>, <a href="#rust_toolchain_repository-exec_triple">exec_triple</a>, <a href="#rust_toolchain_repository-target_triple">target_triple</a>, <a href="#rust_toolchain_repository-exec_compatible_with">exec_compatible_with</a>,
+ <a href="#rust_toolchain_repository-target_compatible_with">target_compatible_with</a>, <a href="#rust_toolchain_repository-include_rustc_srcs">include_rustc_srcs</a>, <a href="#rust_toolchain_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_repository-rustfmt_version">rustfmt_version</a>,
+ <a href="#rust_toolchain_repository-edition">edition</a>, <a href="#rust_toolchain_repository-dev_components">dev_components</a>, <a href="#rust_toolchain_repository-sha256s">sha256s</a>, <a href="#rust_toolchain_repository-urls">urls</a>, <a href="#rust_toolchain_repository-auth">auth</a>)
+</pre>
+
+Assembles a remote repository for the given toolchain params, produces a proxy repository to contain the toolchain declaration, and registers the toolchains.
+
+N.B. A "proxy repository" is needed to allow for registering the toolchain (with constraints) without actually downloading the toolchain.
+
+
+**PARAMETERS**
+
+
+| Name | Description | Default Value |
+| :------------- | :------------- | :------------- |
+| <a id="rust_toolchain_repository-name"></a>name | The name of the generated repository | none |
+| <a id="rust_toolchain_repository-version"></a>version | The version of the tool among "nightly", "beta', or an exact version. | none |
+| <a id="rust_toolchain_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on. | none |
+| <a id="rust_toolchain_repository-target_triple"></a>target_triple | The Rust-style target to build for. | none |
+| <a id="rust_toolchain_repository-exec_compatible_with"></a>exec_compatible_with | A list of constraints for the execution platform for this toolchain. | <code>None</code> |
+| <a id="rust_toolchain_repository-target_compatible_with"></a>target_compatible_with | A list of constraints for the target platform for this toolchain. | <code>None</code> |
+| <a id="rust_toolchain_repository-include_rustc_srcs"></a>include_rustc_srcs | Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. | <code>False</code> |
+| <a id="rust_toolchain_repository-iso_date"></a>iso_date | The date of the tool. Defaults to None. | <code>None</code> |
+| <a id="rust_toolchain_repository-rustfmt_version"></a>rustfmt_version | The version of rustfmt to be associated with the toolchain. Defaults to None. | <code>None</code> |
+| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | <code>None</code> |
+| <a id="rust_toolchain_repository-dev_components"></a>dev_components | Whether to download the rustc-dev components. Requires version to be "nightly". Defaults to False. | <code>False</code> |
+| <a id="rust_toolchain_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. | <code>None</code> |
+| <a id="rust_toolchain_repository-urls"></a>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). Defaults to ['https://static.rust-lang.org/dist/{}.tar.gz'] | <code>["https://static.rust-lang.org/dist/{}.tar.gz"]</code> |
+| <a id="rust_toolchain_repository-auth"></a>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. | <code>None</code> |
+
+**RETURNS**
+
+str: The name of the registerable toolchain created by this rule.
+
+
diff --git a/docs/symbols.bzl b/docs/symbols.bzl
index 42be88c..1a3239d 100644
--- a/docs/symbols.bzl
+++ b/docs/symbols.bzl
@@ -72,6 +72,7 @@
_rust_repository_set = "rust_repository_set",
_rust_toolchain_repository = "rust_toolchain_repository",
_rust_toolchain_repository_proxy = "rust_toolchain_repository_proxy",
+ _rust_toolchain_tools_repository = "rust_toolchain_tools_repository",
)
load(
"@rules_rust//rust:toolchain.bzl",
@@ -142,6 +143,7 @@
rust_repository_set = _rust_repository_set
rust_toolchain_repository = _rust_toolchain_repository
rust_toolchain_repository_proxy = _rust_toolchain_repository_proxy
+rust_toolchain_tools_repository = _rust_toolchain_tools_repository
rust_clippy = _rust_clippy
rust_clippy_aspect = _rust_clippy_aspect
diff --git a/rust/private/repository_utils.bzl b/rust/private/repository_utils.bzl
index 7fa2317..5b4da53 100644
--- a/rust/private/repository_utils.bzl
+++ b/rust/private/repository_utils.bzl
@@ -7,7 +7,6 @@
"system_to_dylib_ext",
"system_to_staticlib_ext",
"system_to_stdlib_linkflags",
- "triple_to_constraint_set",
"triple_to_system",
)
@@ -15,8 +14,6 @@
DEFAULT_STATIC_RUST_URL_TEMPLATES = ["https://static.rust-lang.org/dist/{}.tar.gz"]
_build_file_for_compiler_template = """\
-load("@rules_rust//rust:toolchain.bzl", "rust_toolchain")
-
filegroup(
name = "rustc",
srcs = ["bin/rustc{binary_ext}"],
@@ -63,8 +60,6 @@
)
_build_file_for_cargo_template = """\
-load("@rules_rust//rust:toolchain.bzl", "rust_toolchain")
-
filegroup(
name = "cargo",
srcs = ["bin/cargo{binary_ext}"],
@@ -86,8 +81,6 @@
)
_build_file_for_rustfmt_template = """\
-load("@rules_rust//rust:toolchain.bzl", "rust_toolchain")
-
filegroup(
name = "rustfmt_bin",
srcs = ["bin/rustfmt{binary_ext}"],
@@ -116,8 +109,6 @@
)
_build_file_for_clippy_template = """\
-load("@rules_rust//rust:toolchain.bzl", "rust_toolchain")
-
filegroup(
name = "clippy_driver_bin",
srcs = ["bin/clippy-driver{binary_ext}"],
@@ -210,8 +201,10 @@
)
_build_file_for_rust_toolchain_template = """\
+load("@rules_rust//rust:toolchain.bzl", "rust_toolchain")
+
rust_toolchain(
- name = "{toolchain_name}_impl",
+ name = "{toolchain_name}",
rust_doc = "@{workspace_name}//:rustdoc",
rust_std = "@{workspace_name}//:rust_std-{target_triple}",
rustc = "@{workspace_name}//:rustc",
@@ -301,16 +294,20 @@
name = "{name}",
exec_compatible_with = {exec_constraint_sets_serialized},
target_compatible_with = {target_constraint_sets_serialized},
- toolchain = "@{parent_workspace_name}//:{name}_impl",
+ toolchain = "@{parent_workspace_name}//:rust_toolchain",
toolchain_type = "@rules_rust//rust:toolchain",
)
"""
-def BUILD_for_toolchain(name, parent_workspace_name, exec_triple, target_triple):
+def BUILD_for_toolchain(
+ name,
+ parent_workspace_name,
+ target_compatible_with,
+ exec_compatible_with):
return _build_file_for_toolchain_template.format(
name = name,
- exec_constraint_sets_serialized = serialized_constraint_set_from_triple(exec_triple),
- target_constraint_sets_serialized = serialized_constraint_set_from_triple(target_triple),
+ exec_constraint_sets_serialized = exec_compatible_with,
+ target_constraint_sets_serialized = target_compatible_with,
parent_workspace_name = parent_workspace_name,
)
@@ -351,14 +348,56 @@
ctx,
iso_date = ctx.attr.iso_date,
target_triple = target_triple,
- tool_name = "rust",
- tool_subdirectories = ["rustc", "clippy-preview", "cargo"],
+ tool_name = "rustc",
+ tool_subdirectories = ["rustc"],
version = ctx.attr.version,
)
- compiler_build_file = BUILD_for_compiler(target_triple) + BUILD_for_clippy(target_triple) + BUILD_for_cargo(target_triple)
+ return BUILD_for_compiler(target_triple)
- return compiler_build_file
+def load_clippy(ctx):
+ """Loads Clippy and yields corresponding BUILD for it
+
+ Args:
+ ctx (repository_ctx): A repository_ctx.
+
+ Returns:
+ str: The BUILD file contents for Clippy
+ """
+
+ target_triple = ctx.attr.exec_triple
+ load_arbitrary_tool(
+ ctx,
+ iso_date = ctx.attr.iso_date,
+ target_triple = target_triple,
+ tool_name = "clippy",
+ tool_subdirectories = ["clippy-preview"],
+ version = ctx.attr.version,
+ )
+
+ return BUILD_for_clippy(target_triple)
+
+def load_cargo(ctx):
+ """Loads Cargo and yields corresponding BUILD for it
+
+ Args:
+ ctx (repository_ctx): A repository_ctx.
+
+ Returns:
+ str: The BUILD file contents for Cargo
+ """
+
+ target_triple = ctx.attr.exec_triple
+ load_arbitrary_tool(
+ ctx,
+ iso_date = ctx.attr.iso_date,
+ target_triple = target_triple,
+ tool_name = "cargo",
+ tool_subdirectories = ["cargo"],
+ version = ctx.attr.version,
+ )
+
+ return BUILD_for_cargo(target_triple)
def should_include_rustc_srcs(repository_ctx):
"""Determing whether or not to include rustc sources in the toolchain.
@@ -409,16 +448,15 @@
)""",
)
-def load_rust_stdlib(ctx, target_triple, include_llvm_tools):
+def load_rust_stdlib(ctx, target_triple):
"""Loads a rust standard library and yields corresponding BUILD for it
Args:
ctx (repository_ctx): A repository_ctx.
target_triple (str): The rust-style target triple of the tool
- include_llvm_tools (bool): Whether to include LLVM tools in the toolchain
Returns:
- str: The BUILD file contents for this stdlib, and a toolchain decl to match
+ str: The BUILD file contents for this stdlib
"""
load_arbitrary_tool(
@@ -430,29 +468,7 @@
version = ctx.attr.version,
)
- toolchain_prefix = ctx.attr.toolchain_name_prefix or DEFAULT_TOOLCHAIN_NAME_PREFIX
- stdlib_build_file = BUILD_for_stdlib(target_triple)
-
- stdlib_linkflags = None
- if "BAZEL_RUST_STDLIB_LINKFLAGS" in ctx.os.environ:
- stdlib_linkflags = ctx.os.environ["BAZEL_RUST_STDLIB_LINKFLAGS"].split(":")
-
- toolchain_build_file = BUILD_for_rust_toolchain(
- name = "{toolchain_prefix}_{target_triple}".format(
- toolchain_prefix = toolchain_prefix,
- target_triple = target_triple,
- ),
- exec_triple = ctx.attr.exec_triple,
- include_rustc_srcs = should_include_rustc_srcs(ctx),
- target_triple = target_triple,
- stdlib_linkflags = stdlib_linkflags,
- workspace_name = ctx.attr.name,
- default_edition = ctx.attr.edition,
- include_rustfmt = not (not ctx.attr.rustfmt_version),
- include_llvm_tools = include_llvm_tools,
- )
-
- return stdlib_build_file + toolchain_build_file
+ return BUILD_for_stdlib(target_triple)
def load_rustc_dev_nightly(ctx, target_triple):
"""Loads the nightly rustc dev component
@@ -508,21 +524,6 @@
if version in ("beta", "nightly") and not iso_date:
fail("{param_prefix}iso_date must be specified if version is 'beta' or 'nightly'".format(param_prefix = param_prefix))
-def serialized_constraint_set_from_triple(target_triple):
- """Returns a string representing a set of constraints
-
- Args:
- target_triple (str): The target triple of the constraint set
-
- Returns:
- str: Formatted string representing the serialized constraint
- """
- constraint_set = triple_to_constraint_set(target_triple)
- constraint_set_strs = []
- for constraint in constraint_set:
- constraint_set_strs.append("\"{}\"".format(constraint))
- return "[{}]".format(", ".join(constraint_set_strs))
-
def produce_tool_suburl(tool_name, target_triple, version, iso_date = None):
"""Produces a fully qualified Rust tool name for URL
@@ -596,23 +597,24 @@
urls.append(new_url)
tool_path = produce_tool_path(tool_name, target_triple, version)
-
archive_path = tool_path + _get_tool_extension(ctx)
- ctx.download(
- urls,
- output = archive_path,
- sha256 = getattr(ctx.attr, "sha256s", dict()).get(archive_path) or
- FILE_KEY_TO_SHA.get(archive_path) or
- sha256,
- auth = _make_auth_dict(ctx, urls),
- )
+ sha256 = getattr(ctx.attr, "sha256s", dict()).get(archive_path) or FILE_KEY_TO_SHA.get(archive_path) or sha256
+
for subdirectory in tool_subdirectories:
- ctx.extract(
- archive_path,
- output = "",
+ # As long as the sha256 value is consistent accross calls here the
+ # cost of downloading an artifact is negated as by Bazel's caching.
+ result = ctx.download_and_extract(
+ urls,
+ sha256 = sha256,
+ auth = _make_auth_dict(ctx, urls),
stripPrefix = "{}/{}".format(tool_path, subdirectory),
)
+ # In the event no sha256 was provided, set it to the value of the first
+ # downloaded item so subsequent downloads use a cached artifact.
+ if not sha256:
+ sha256 = result.sha256
+
def _make_auth_dict(ctx, urls):
auth = getattr(ctx.attr, "auth", {})
if not auth:
diff --git a/rust/repositories.bzl b/rust/repositories.bzl
index 2880db4..9b8d582 100644
--- a/rust/repositories.bzl
+++ b/rust/repositories.bzl
@@ -1,13 +1,19 @@
# buildifier: disable=module-docstring
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
+load(
+ "//rust/platform:triple_mappings.bzl",
+ "triple_to_constraint_set",
+)
load("//rust/private:common.bzl", "rust_common")
load(
"//rust/private:repository_utils.bzl",
+ "BUILD_for_rust_toolchain",
"BUILD_for_toolchain",
"DEFAULT_STATIC_RUST_URL_TEMPLATES",
- "DEFAULT_TOOLCHAIN_NAME_PREFIX",
"check_version_valid",
+ "load_cargo",
+ "load_clippy",
"load_llvm_tools",
"load_rust_compiler",
"load_rust_src",
@@ -158,8 +164,8 @@
rust_register_toolchains(**kwargs)
-def _rust_toolchain_repository_impl(ctx):
- """The implementation of the rust toolchain repository rule."""
+def _rust_toolchain_tools_repository_impl(ctx):
+ """The implementation of the rust toolchain tools repository rule."""
check_version_valid(ctx.attr.version, ctx.attr.iso_date)
@@ -167,7 +173,11 @@
if should_include_rustc_srcs(ctx):
load_rust_src(ctx)
- build_components = [load_rust_compiler(ctx)]
+ build_components = [
+ load_rust_compiler(ctx),
+ load_clippy(ctx),
+ load_cargo(ctx),
+ ]
if ctx.attr.rustfmt_version:
build_components.append(load_rustfmt(ctx))
@@ -177,33 +187,32 @@
if include_llvm_tools:
build_components.append(load_llvm_tools(ctx, ctx.attr.exec_triple))
- for target_triple in [ctx.attr.exec_triple] + ctx.attr.extra_target_triples:
- build_components.append(load_rust_stdlib(ctx, target_triple, include_llvm_tools))
+ build_components.append(load_rust_stdlib(ctx, ctx.attr.target_triple))
- # extra_target_triples contains targets such as wasm, which don't have rustc_dev components
- if ctx.attr.dev_components and target_triple not in ctx.attr.extra_target_triples:
- load_rustc_dev_nightly(ctx, target_triple)
+ stdlib_linkflags = None
+ if "BAZEL_RUST_STDLIB_LINKFLAGS" in ctx.os.environ:
+ stdlib_linkflags = ctx.os.environ["BAZEL_RUST_STDLIB_LINKFLAGS"].split(":")
+
+ build_components.append(BUILD_for_rust_toolchain(
+ name = "rust_toolchain",
+ exec_triple = ctx.attr.exec_triple,
+ include_rustc_srcs = should_include_rustc_srcs(ctx),
+ target_triple = ctx.attr.target_triple,
+ stdlib_linkflags = stdlib_linkflags,
+ workspace_name = ctx.attr.name,
+ default_edition = ctx.attr.edition,
+ include_rustfmt = not (not ctx.attr.rustfmt_version),
+ include_llvm_tools = include_llvm_tools,
+ ))
+
+ # Not all target triples are expected to have dev components
+ if ctx.attr.dev_components:
+ load_rustc_dev_nightly(ctx, ctx.attr.target_triple)
ctx.file("WORKSPACE.bazel", "")
ctx.file("BUILD.bazel", "\n".join(build_components))
-def _rust_toolchain_repository_proxy_impl(ctx):
- build_components = []
- for target_triple in [ctx.attr.exec_triple] + ctx.attr.extra_target_triples:
- build_components.append(BUILD_for_toolchain(
- name = "{toolchain_prefix}_{target_triple}".format(
- toolchain_prefix = ctx.attr.toolchain_name_prefix,
- target_triple = target_triple,
- ),
- exec_triple = ctx.attr.exec_triple,
- parent_workspace_name = ctx.attr.parent_workspace_name,
- target_triple = target_triple,
- ))
-
- ctx.file("WORKSPACE.bazel", "")
- ctx.file("BUILD.bazel", "\n".join(build_components))
-
-rust_toolchain_repository = repository_rule(
+rust_toolchain_tools_repository = repository_rule(
doc = (
"Composes a single workspace containing the toolchain components for compiling on a given " +
"platform to a series of target platforms.\n" +
@@ -233,9 +242,6 @@
doc = "The Rust-style target that this compiler runs on",
mandatory = True,
),
- "extra_target_triples": attr.string_list(
- doc = "Additional rust-style targets that this set of toolchains should support.",
- ),
"include_rustc_srcs": attr.bool(
doc = (
"Whether to download and unpack the rustc source files. These are very large, and " +
@@ -255,8 +261,9 @@
"sha256s": attr.string_dict(
doc = "A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details.",
),
- "toolchain_name_prefix": attr.string(
- doc = "The per-target prefix expected for the rust_toolchain declarations in the parent workspace.",
+ "target_triple": attr.string(
+ doc = "The Rust-style target that this compiler builds for",
+ mandatory = True,
),
"urls": attr.string_list(
doc = "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).",
@@ -267,34 +274,153 @@
mandatory = True,
),
},
- implementation = _rust_toolchain_repository_impl,
+ implementation = _rust_toolchain_tools_repository_impl,
environ = ["RULES_RUST_TOOLCHAIN_INCLUDE_RUSTC_SRCS"],
)
+def _rust_toolchain_repository_proxy_impl(repository_ctx):
+ repository_ctx.file("WORKSPACE.bazel", """workspace(name = "{}")""".format(
+ repository_ctx.name,
+ ))
+
+ repository_ctx.file("BUILD.bazel", BUILD_for_toolchain(
+ name = "rust_toolchain",
+ parent_workspace_name = repository_ctx.attr.parent_workspace_name,
+ target_compatible_with = json.encode(repository_ctx.attr.target_compatible_with),
+ exec_compatible_with = json.encode(repository_ctx.attr.exec_compatible_with),
+ ))
+
rust_toolchain_repository_proxy = repository_rule(
doc = (
"Generates a toolchain-bearing repository that declares the toolchains from some other " +
"rust_toolchain_repository."
),
attrs = {
+ "exec_compatible_with": attr.string_list(
+ doc = "TODO",
+ ),
"exec_triple": attr.string(
doc = "The Rust-style target triple for the compilation platform",
mandatory = True,
),
- "extra_target_triples": attr.string_list(
- doc = "The Rust-style triples for extra compilation targets",
- ),
"parent_workspace_name": attr.string(
doc = "The name of the other rust_toolchain_repository",
mandatory = True,
),
- "toolchain_name_prefix": attr.string(
- doc = "The per-target prefix expected for the rust_toolchain declarations in the parent workspace.",
+ "target_compatible_with": attr.string_list(
+ doc = "TODO",
+ ),
+ "target_triple": attr.string(
+ doc = "The Rust-style target that this compiler builds for",
+ mandatory = True,
),
},
implementation = _rust_toolchain_repository_proxy_impl,
)
+def rust_toolchain_repository(
+ name,
+ version,
+ exec_triple,
+ target_triple,
+ exec_compatible_with = None,
+ target_compatible_with = None,
+ include_rustc_srcs = False,
+ iso_date = None,
+ rustfmt_version = None,
+ edition = None,
+ dev_components = False,
+ sha256s = None,
+ urls = DEFAULT_STATIC_RUST_URL_TEMPLATES,
+ auth = None):
+ """Assembles a remote repository for the given toolchain params, produces a proxy repository \
+ to contain the toolchain declaration, and registers the toolchains.
+
+ N.B. A "proxy repository" is needed to allow for registering the toolchain (with constraints) \
+ without actually downloading the toolchain.
+
+ Args:
+ name (str): The name of the generated repository
+ version (str): The version of the tool among "nightly", "beta', or an exact version.
+ exec_triple (str): The Rust-style target that this compiler runs on.
+ target_triple (str): The Rust-style target to build for.
+ exec_compatible_with (list, optional): A list of constraints for the execution platform for this toolchain.
+ target_compatible_with (list, optional): A list of constraints for the target platform for this toolchain.
+ include_rustc_srcs (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False.
+ iso_date (str, optional): The date of the tool. Defaults to None.
+ rustfmt_version (str, optional): The version of rustfmt to be associated with the
+ toolchain. Defaults to None.
+ edition (str, optional): The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute.
+ dev_components (bool, optional): Whether to download the rustc-dev components.
+ Requires version to be "nightly". Defaults to False.
+ sha256s (str, optional): A dict associating tool subdirectories to sha256 hashes. See
+ [rust_repositories](#rust_repositories) for more details.
+ urls (list, optional): 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). Defaults to ['https://static.rust-lang.org/dist/{}.tar.gz']
+ auth (dict): 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.
+
+ Returns:
+ str: The name of the registerable toolchain created by this rule.
+ """
+
+ if exec_compatible_with == None:
+ exec_compatible_with = triple_to_constraint_set(exec_triple)
+
+ if target_compatible_with == None:
+ target_compatible_with = triple_to_constraint_set(target_triple)
+
+ rust_toolchain_tools_repository(
+ name = name + "_tools",
+ exec_triple = exec_triple,
+ include_rustc_srcs = include_rustc_srcs,
+ target_triple = target_triple,
+ iso_date = iso_date,
+ version = version,
+ rustfmt_version = rustfmt_version,
+ edition = edition,
+ dev_components = dev_components,
+ sha256s = sha256s,
+ urls = urls,
+ auth = auth,
+ )
+
+ rust_toolchain_repository_proxy(
+ name = name,
+ exec_triple = exec_triple,
+ target_triple = target_triple,
+ parent_workspace_name = name + "_tools",
+ exec_compatible_with = exec_compatible_with,
+ target_compatible_with = target_compatible_with,
+ )
+
+ return "@{name}//:rust_toolchain".format(
+ name = name,
+ )
+
+def _rust_toolchain_set_repository_impl(repository_ctx):
+ repository_ctx.file("WORKSPACE.bazel", """workspace(name = "{}")""".format(
+ repository_ctx.name,
+ ))
+
+ repository_ctx.file("BUILD.bazel", """exports_files(["defs.bzl"])""")
+ repository_ctx.file("defs.bzl", "ALL_TOOLCHAINS = {}\n".format(
+ json.encode_indent(repository_ctx.attr.toolchains, indent = " " * 4),
+ ))
+
+rust_toolchain_set_repository = repository_rule(
+ doc = (
+ "Generates a toolchain-bearing repository that declares the toolchains from some other " +
+ "rust_toolchain_repository."
+ ),
+ attrs = {
+ "toolchains": attr.string_list(
+ doc = "The list of all toolchains created by the current `rust_toolchain_set`",
+ mandatory = True,
+ ),
+ },
+ implementation = _rust_toolchain_set_repository_impl,
+)
+
def rust_repository_set(
name,
version,
@@ -336,38 +462,30 @@
register_toolchain (bool): If True, the generated `rust_toolchain` target will become a registered toolchain.
"""
- rust_toolchain_repository(
- name = name,
- exec_triple = exec_triple,
- include_rustc_srcs = include_rustc_srcs,
- extra_target_triples = extra_target_triples,
- iso_date = iso_date,
- toolchain_name_prefix = DEFAULT_TOOLCHAIN_NAME_PREFIX,
- version = version,
- rustfmt_version = rustfmt_version,
- edition = edition,
- dev_components = dev_components,
- sha256s = sha256s,
- urls = urls,
- auth = auth,
- )
-
- rust_toolchain_repository_proxy(
- name = name + "_toolchains",
- exec_triple = exec_triple,
- extra_target_triples = extra_target_triples,
- parent_workspace_name = name,
- toolchain_name_prefix = DEFAULT_TOOLCHAIN_NAME_PREFIX,
- )
-
all_toolchain_names = []
for target_triple in [exec_triple] + extra_target_triples:
- all_toolchain_names.append("@{name}_toolchains//:{toolchain_name_prefix}_{triple}".format(
- name = name,
- toolchain_name_prefix = DEFAULT_TOOLCHAIN_NAME_PREFIX,
- triple = target_triple,
+ toolchain_name = "{}__{}".format(name, target_triple)
+ all_toolchain_names.append(rust_toolchain_repository(
+ name = toolchain_name,
+ exec_triple = exec_triple,
+ include_rustc_srcs = include_rustc_srcs,
+ target_triple = target_triple,
+ iso_date = iso_date,
+ version = version,
+ rustfmt_version = rustfmt_version,
+ edition = edition,
+ dev_components = dev_components,
+ sha256s = sha256s,
+ urls = urls,
+ auth = auth,
))
+ # This repository exists to allow `rust_repository_set` to work with the `maybe` wrapper.
+ rust_toolchain_set_repository(
+ name = name,
+ toolchains = all_toolchain_names,
+ )
+
# Register toolchains
if register_toolchain:
native.register_toolchains(*all_toolchain_names)