diff --git a/cargo/cargo_bootstrap.bzl b/cargo/cargo_bootstrap.bzl index 92c6f2b811..f55ba1f4c1 100644 --- a/cargo/cargo_bootstrap.bzl +++ b/cargo/cargo_bootstrap.bzl @@ -55,12 +55,17 @@ def cargo_bootstrap( if build_mode == "release": args.append("--release") + env = {} + + if repository_ctx.attr.include_perl_on_windows and "win" in repository_ctx.os.name: + env["PERL"] = str(repository_ctx.path(Label("@perl_windows//:perl/bin/perl.exe"))) + + env["RUSTC"] = str(rustc_bin) + repository_ctx.report_progress("Cargo Bootstrapping {}".format(binary)) result = repository_ctx.execute( args, - environment = { - "RUSTC": str(rustc_bin), - }, + environment = env, quiet = quiet, ) @@ -166,6 +171,9 @@ cargo_bootstrap_repository = repository_rule( allow_single_file = ["Cargo.toml"], mandatory = True, ), + "include_perl_on_windows": attr.bool( + doc = "If true, set $PERL to point to a working perl binary when running on Windows", + ), "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`", ), diff --git a/crate_universe/bootstrap.bzl b/crate_universe/bootstrap.bzl index 1777ea4ce7..7925b848df 100644 --- a/crate_universe/bootstrap.bzl +++ b/crate_universe/bootstrap.bzl @@ -1,9 +1,12 @@ """A module for declaraing a repository for bootstrapping crate_universe""" +load("@examples//third_party/openssl:openssl_repositories.bzl", "openssl_repositories") load("//cargo:defs.bzl", "cargo_bootstrap_repository") load("//rust:defs.bzl", "rust_common") def crate_universe_bootstrap(): + openssl_repositories() + cargo_bootstrap_repository( name = "rules_rust_crate_universe_bootstrap", cargo_lockfile = Label("//crate_universe:Cargo.lock"), @@ -11,4 +14,5 @@ def crate_universe_bootstrap(): srcs = [Label("//crate_universe:resolver_srcs")], version = rust_common.default_version, binary = "crate_universe_resolver", + include_perl_on_windows = True, )