From b96e37ecf435d032435ad66f547a6599a16467d2 Mon Sep 17 00:00:00 2001 From: DolceTriade Date: Sun, 26 Nov 2023 02:43:48 +0530 Subject: [PATCH] crate_universe: Allow passing extra args down to crate_universe_bootstrap (#2279) this is useful for rules_nixpkgs which allows us to specify an external rust toolchain controlled by Nix. Currently, we are required to carry a patch to modify rules_rust: https://github.com/tweag/rules_nixpkgs/tree/master/examples/toolchains/rust Now we can add something like this to our WORKSPACE to use a custom cargo and rustc: ``` crate_universe_dependencies( bootstrap = True, rust_toolchain_cargo_template = "@nix_rust//:bin/{tool}", rust_toolchain_rustc_template = "@nix_rust//:bin/{tool}", ) ``` --------- Co-authored-by: UebelAndre --- crate_universe/repositories.bzl | 5 +++-- docs/crate_universe.md | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crate_universe/repositories.bzl b/crate_universe/repositories.bzl index c06e06d979..642435fb31 100644 --- a/crate_universe/repositories.bzl +++ b/crate_universe/repositories.bzl @@ -7,17 +7,18 @@ load("//crate_universe/3rdparty/crates:crates.bzl", _vendor_crate_repositories = load("//crate_universe/private:vendor_utils.bzl", "crates_vendor_deps") load("//crate_universe/tools/cross_installer:cross_installer_deps.bzl", "cross_installer_deps") -def crate_universe_dependencies(rust_version = rust_common.default_version, bootstrap = False): +def crate_universe_dependencies(rust_version = rust_common.default_version, bootstrap = False, **kwargs): """Define dependencies of the `cargo-bazel` Rust target Args: rust_version (str, optional): The version of rust to use when generating dependencies. bootstrap (bool, optional): If true, a `cargo_bootstrap_repository` target will be generated. + **kwargs: Arguments to pass through to cargo_bazel_bootstrap. """ third_party_deps() if bootstrap: - cargo_bazel_bootstrap(rust_version = rust_version) + cargo_bazel_bootstrap(rust_version = rust_version, **kwargs) _vendor_crate_repositories() diff --git a/docs/crate_universe.md b/docs/crate_universe.md index cbb3ea83ed..e1c699d016 100644 --- a/docs/crate_universe.md +++ b/docs/crate_universe.md @@ -720,7 +720,7 @@ A macro for defining repositories for all generated crates ## crate_universe_dependencies
-crate_universe_dependencies(rust_version, bootstrap)
+crate_universe_dependencies(rust_version, bootstrap, kwargs)
 
Define dependencies of the `cargo-bazel` Rust target @@ -732,6 +732,7 @@ Define dependencies of the `cargo-bazel` Rust target | :------------- | :------------- | :------------- | | rust_version | The version of rust to use when generating dependencies. | `"1.74.0"` | | bootstrap | If true, a cargo_bootstrap_repository target will be generated. | `False` | +| kwargs | Arguments to pass through to cargo_bazel_bootstrap. | none |