diff --git a/AUTHORS b/AUTHORS index 9da09a6e37..15cde4ff97 100644 --- a/AUTHORS +++ b/AUTHORS @@ -8,6 +8,7 @@ Google Inc. Spotify AB +VMware Inc. Damien Martin-Guillerez David Chen Florian Weikert diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 491738bfed..d281eeb467 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -20,3 +20,4 @@ Philipp Wollermann Ulf Adams Justine Alexandra Roberts Tunney John Edmonds +Ivan Kalchev diff --git a/crate_universe/defs.bzl b/crate_universe/defs.bzl index ea9b5f27a2..43907c430b 100644 --- a/crate_universe/defs.bzl +++ b/crate_universe/defs.bzl @@ -157,7 +157,7 @@ __WARNING__: This rule experimental and subject to change without warning. Environment Variables: - `REPIN`: Re-pin the lockfile if set (useful for repinning deps from multiple rulesets). - `RULES_RUST_REPIN`: Re-pin the lockfile if set (useful for only repinning Rust deps). -- `RULES_RUST_CRATE_UNIVERSE_RESOLVER_URL_OVERRIDE`: Override URL to use to download resolver binary +- `RULES_RUST_CRATE_UNIVERSE_RESOLVER_URL_OVERRIDE`: Override URL to use to download resolver binary - for local paths use a `file://` URL. - `RULES_RUST_CRATE_UNIVERSE_RESOLVER_URL_OVERRIDE_SHA256`: An optional sha256 value for the binary at the override url location. """, @@ -226,6 +226,13 @@ Dict of registry_name: index_url. ), default = "rust_{system}_{arch}", ), + "rust_toolchain_repository_tool_path": attr.string_dict( + doc = "The relative path of the tools in the repository", + default = { + "cargo": ":bin/cargo", + "rustc": ":bin/rustc", + }, + ), "sha256s": attr.string_dict( doc = "The sha256 checksum of the desired rust artifacts", ), diff --git a/crate_universe/private/util.bzl b/crate_universe/private/util.bzl index ca6411637c..35de602162 100644 --- a/crate_universe/private/util.bzl +++ b/crate_universe/private/util.bzl @@ -134,8 +134,17 @@ def get_cargo_and_rustc(repository_ctx, host_triple): rust_toolchain_repository = rust_toolchain_repository.replace("{triple}", host_triple) rust_toolchain_repository = rust_toolchain_repository.replace("{arch}", arch) - cargo_path = repository_ctx.path(Label("@{}{}".format(rust_toolchain_repository, "//:bin/cargo" + extension))) - rustc_path = repository_ctx.path(Label("@{}{}".format(rust_toolchain_repository, "//:bin/rustc" + extension))) + tool_path = repository_ctx.attr.rust_toolchain_repository_tool_path + cargo_path = repository_ctx.path(Label("@{}//{}{}".format( + rust_toolchain_repository, + tool_path["cargo"], + extension, + ))) + rustc_path = repository_ctx.path(Label("@{}//{}{}".format( + rust_toolchain_repository, + tool_path["rustc"], + extension, + ))) return struct( cargo = cargo_path, diff --git a/docs/crate_universe.md b/docs/crate_universe.md index 6197399642..acc21c1d77 100644 --- a/docs/crate_universe.md +++ b/docs/crate_universe.md @@ -127,7 +127,8 @@ See [some more examples](../examples/crate_universe) and the documentation below crate_universe(name, additional_registries, cargo_toml_files, default_registry_download_url_template, iso_date, lockfile, overrides, packages, repo_mapping, resolver, resolver_download_url_template, resolver_sha256s, - rust_toolchain_repository_template, sha256s, supported_targets, version) + rust_toolchain_repository_template, rust_toolchain_repository_tool_path, sha256s, + supported_targets, version) A rule for downloading Rust dependencies (crates). @@ -137,7 +138,7 @@ __WARNING__: This rule experimental and subject to change without warning. Environment Variables: - `REPIN`: Re-pin the lockfile if set (useful for repinning deps from multiple rulesets). - `RULES_RUST_REPIN`: Re-pin the lockfile if set (useful for only repinning Rust deps). -- `RULES_RUST_CRATE_UNIVERSE_RESOLVER_URL_OVERRIDE`: Override URL to use to download resolver binary +- `RULES_RUST_CRATE_UNIVERSE_RESOLVER_URL_OVERRIDE`: Override URL to use to download resolver binary - for local paths use a `file://` URL. - `RULES_RUST_CRATE_UNIVERSE_RESOLVER_URL_OVERRIDE_SHA256`: An optional sha256 value for the binary at the override url location. @@ -160,6 +161,7 @@ Environment Variables: | resolver_download_url_template | URL template from which to download the resolver binary. {host_triple} and {extension} will be filled in according to the host platform. | String | optional | "{host_triple}{extension}" | | resolver_sha256s | Dictionary of host_triple -> sha256 for resolver binary. | Dictionary: String -> String | optional | {"aarch64-apple-darwin": "{aarch64-apple-darwin--sha256}", "aarch64-unknown-linux-gnu": "{aarch64-unknown-linux-gnu--sha256}", "x86_64-apple-darwin": "{x86_64-apple-darwin--sha256}", "x86_64-pc-windows-gnu": "{x86_64-pc-windows-gnu--sha256}", "x86_64-unknown-linux-gnu": "{x86_64-unknown-linux-gnu--sha256}"} | | rust_toolchain_repository_template | The template to use for finding the host rust_toolchain repository. {version} (eg. '1.53.0'), {triple} (eg. 'x86_64-unknown-linux-gnu'), {system} (eg. 'darwin'), and {arch} (eg. 'aarch64') will be replaced in the string if present. | String | optional | "rust_{system}_{arch}" | +| rust_toolchain_repository_tool_path | The relative path of the tools in the repository | Dictionary: String -> String | optional | {"cargo": ":bin/cargo", "rustc": ":bin/rustc"} | | sha256s | The sha256 checksum of the desired rust artifacts | Dictionary: String -> String | optional | {} | | supported_targets | A list of supported [platform triples](https://doc.rust-lang.org/nightly/rustc/platform-support.html) to consider when resoliving dependencies. | List of strings | optional | ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu"] | | version | The version of cargo the resolver should use | String | optional | "1.56.1" | diff --git a/docs/flatten.md b/docs/flatten.md index 1885e345ef..52ff531fca 100644 --- a/docs/flatten.md +++ b/docs/flatten.md @@ -104,7 +104,8 @@ A rule for bootstrapping a Rust binary using [Cargo](https://doc.rust-lang.org/c crate_universe(name, additional_registries, cargo_toml_files, default_registry_download_url_template, iso_date, lockfile, overrides, packages, repo_mapping, resolver, resolver_download_url_template, resolver_sha256s, - rust_toolchain_repository_template, sha256s, supported_targets, version) + rust_toolchain_repository_template, rust_toolchain_repository_tool_path, sha256s, + supported_targets, version) A rule for downloading Rust dependencies (crates). @@ -114,7 +115,7 @@ __WARNING__: This rule experimental and subject to change without warning. Environment Variables: - `REPIN`: Re-pin the lockfile if set (useful for repinning deps from multiple rulesets). - `RULES_RUST_REPIN`: Re-pin the lockfile if set (useful for only repinning Rust deps). -- `RULES_RUST_CRATE_UNIVERSE_RESOLVER_URL_OVERRIDE`: Override URL to use to download resolver binary +- `RULES_RUST_CRATE_UNIVERSE_RESOLVER_URL_OVERRIDE`: Override URL to use to download resolver binary - for local paths use a `file://` URL. - `RULES_RUST_CRATE_UNIVERSE_RESOLVER_URL_OVERRIDE_SHA256`: An optional sha256 value for the binary at the override url location. @@ -137,6 +138,7 @@ Environment Variables: | resolver_download_url_template | URL template from which to download the resolver binary. {host_triple} and {extension} will be filled in according to the host platform. | String | optional | "{host_triple}{extension}" | | resolver_sha256s | Dictionary of host_triple -> sha256 for resolver binary. | Dictionary: String -> String | optional | {"aarch64-apple-darwin": "{aarch64-apple-darwin--sha256}", "aarch64-unknown-linux-gnu": "{aarch64-unknown-linux-gnu--sha256}", "x86_64-apple-darwin": "{x86_64-apple-darwin--sha256}", "x86_64-pc-windows-gnu": "{x86_64-pc-windows-gnu--sha256}", "x86_64-unknown-linux-gnu": "{x86_64-unknown-linux-gnu--sha256}"} | | rust_toolchain_repository_template | The template to use for finding the host rust_toolchain repository. {version} (eg. '1.53.0'), {triple} (eg. 'x86_64-unknown-linux-gnu'), {system} (eg. 'darwin'), and {arch} (eg. 'aarch64') will be replaced in the string if present. | String | optional | "rust_{system}_{arch}" | +| rust_toolchain_repository_tool_path | The relative path of the tools in the repository | Dictionary: String -> String | optional | {"cargo": ":bin/cargo", "rustc": ":bin/rustc"} | | sha256s | The sha256 checksum of the desired rust artifacts | Dictionary: String -> String | optional | {} | | supported_targets | A list of supported [platform triples](https://doc.rust-lang.org/nightly/rustc/platform-support.html) to consider when resoliving dependencies. | List of strings | optional | ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu"] | | version | The version of cargo the resolver should use | String | optional | "1.56.1" |