Skip to content

Commit f9cd632

Browse files
committed
Avoid direct references to volatile files
1 parent 5a0ded8 commit f9cd632

3 files changed

Lines changed: 15667 additions & 819 deletions

File tree

crate_universe/extensions.bzl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,8 @@ def _get_generator(module_ctx):
801801
generator_sha256 = module_ctx.os.environ.get(CARGO_BAZEL_GENERATOR_SHA256)
802802
generator_url = module_ctx.os.environ.get(CARGO_BAZEL_GENERATOR_URL)
803803
elif len(CARGO_BAZEL_URLS) == 0:
804-
return module_ctx.path(Label("@cargo_bazel_bootstrap//:cargo-bazel"))
804+
return module_ctx.path(Label("@cargo_bazel_bootstrap//:BUILD.bazel")).dirname.get_child("cargo-bazel")
805+
805806
else:
806807
generator_sha256 = CARGO_BAZEL_SHA256S.get(host_triple.str)
807808
generator_url = CARGO_BAZEL_URLS.get(host_triple.str)
@@ -839,8 +840,14 @@ def _get_host_cargo_rustc(module_ctx, host_triple, host_tools_repo):
839840
"""
840841
binary_ext = system_to_binary_ext(host_triple.system)
841842

842-
cargo_path = str(module_ctx.path(Label("@{}//:bin/cargo{}".format(host_tools_repo, binary_ext))))
843-
rustc_path = str(module_ctx.path(Label("@{}//:bin/rustc{}".format(host_tools_repo, binary_ext))))
843+
# Note that `BUILD.bazel` is not used as it also contains host specific data.
844+
root = module_ctx.path(Label("@{rust_host_tools}//:WORKSPACE.bazel".format(
845+
rust_host_tools = host_tools_repo,
846+
)))
847+
848+
cargo_path = root.dirname.get_child("bin/cargo{}".format(binary_ext))
849+
rustc_path = root.dirname.get_child("bin/rustc{}".format(binary_ext))
850+
844851
return cargo_path, rustc_path
845852

846853
def _crate_impl(module_ctx):

0 commit comments

Comments
 (0)