diff --git a/cargo/private/cargo_bootstrap.bzl b/cargo/private/cargo_bootstrap.bzl index 10a0cfaf5d..beaac8acda 100644 --- a/cargo/private/cargo_bootstrap.bzl +++ b/cargo/private/cargo_bootstrap.bzl @@ -177,12 +177,13 @@ def _cargo_bootstrap_repository_impl(repository_ctx): # Pretend to Bazel that this rule's input files have been used, so that it will re-run the rule if they change. _detect_changes(repository_ctx) - if repository_ctx.attr.version in ("beta", "nightly"): - channel = repository_ctx.attr.version - version = repository_ctx.attr.iso_date + # Expects something like `1.56.0`, or `nightly/2021-09-08`. + version, _, iso_date = repository_ctx.attr.version.partition("/") + if iso_date: + channel = version + version = iso_date else: channel = "stable" - version = repository_ctx.attr.version host_triple = get_host_triple(repository_ctx) cargo_template = repository_ctx.attr.rust_toolchain_cargo_template @@ -260,9 +261,6 @@ cargo_bootstrap_repository = repository_rule( "Additionally, the platform triple `*` applies to all platforms." ), ), - "iso_date": attr.string( - doc = "The iso_date of cargo binary the resolver should use. Note: This can only be set if `version` is `beta` or `nightly`", - ), "rust_toolchain_cargo_template": attr.string( doc = ( "The template to use for finding the host `cargo` binary. `{version}` (eg. '1.53.0'), " + @@ -290,12 +288,9 @@ cargo_bootstrap_repository = repository_rule( default = 600, ), "version": attr.string( - doc = "The version of cargo the resolver should use", + doc = "The version of Rust the currently registered toolchain is using. Eg. `1.56.0`, or `nightly/2021-09-08`", default = rust_common.default_version, ), - "_cc_toolchain": attr.label( - default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"), - ), }, ) diff --git a/docs/cargo.md b/docs/cargo.md index 90e410fa79..89050d145a 100644 --- a/docs/cargo.md +++ b/docs/cargo.md @@ -12,8 +12,8 @@
 cargo_bootstrap_repository(name, binary, build_mode, cargo_lockfile, cargo_toml, env, env_label,
-                           iso_date, repo_mapping, rust_toolchain_cargo_template,
-                           rust_toolchain_rustc_template, srcs, timeout, version)
+                           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/) @@ -30,13 +30,12 @@ A rule for bootstrapping a Rust binary using [Cargo](https://doc.rust-lang.org/c | 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 | {} | -| iso_date | The iso_date of cargo binary the resolver should use. Note: This can only be set if version is beta or nightly | 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 cargo the resolver should use | String | optional | "1.77.2" | +| version | The version of Rust the currently registered toolchain is using. Eg. 1.56.0, or nightly/2021-09-08 | String | optional | "1.77.2" | diff --git a/docs/flatten.md b/docs/flatten.md index 6a8d7a5057..c567f2af31 100644 --- a/docs/flatten.md +++ b/docs/flatten.md @@ -86,8 +86,8 @@ Control whether to print clippy output or store it to a file, using the configur
 cargo_bootstrap_repository(name, binary, build_mode, cargo_lockfile, cargo_toml, env, env_label,
-                           iso_date, repo_mapping, rust_toolchain_cargo_template,
-                           rust_toolchain_rustc_template, srcs, timeout, version)
+                           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/) @@ -104,13 +104,12 @@ A rule for bootstrapping a Rust binary using [Cargo](https://doc.rust-lang.org/c | 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 | {} | -| iso_date | The iso_date of cargo binary the resolver should use. Note: This can only be set if version is beta or nightly | 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 cargo the resolver should use | String | optional | "1.77.2" | +| version | The version of Rust the currently registered toolchain is using. Eg. 1.56.0, or nightly/2021-09-08 | String | optional | "1.77.2" |