Skip to content

Commit adb7877

Browse files
authored
Use host Cargo label in host tools repo (#127)
1 parent 684a262 commit adb7877

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
def _host_tools_repository_impl(rctx):
2-
defs_bzl_content = """\
3-
RS_HOST_CARGO_LABEL = Label("@{host_cargo_repo}//:bin/cargo{binary_suffix}")
4-
""".format(
5-
host_cargo_repo = rctx.attr.host_cargo_repo,
6-
binary_suffix = rctx.attr.binary_suffix,
7-
)
8-
9-
rctx.file("defs.bzl", defs_bzl_content)
2+
rctx.file("defs.bzl", 'RS_HOST_CARGO_LABEL = Label("%s")' % rctx.attr.host_cargo)
103
rctx.file("BUILD.bazel", 'exports_files(["defs.bzl"])')
114

125
return rctx.repo_metadata(reproducible = True)
136

147
host_tools_repository = repository_rule(
158
implementation = _host_tools_repository_impl,
169
attrs = {
17-
"host_cargo_repo": attr.string(mandatory = True),
18-
"binary_suffix": attr.string(mandatory = True),
10+
"host_cargo": attr.label(allow_single_file = True, mandatory = True),
1911
},
2012
)

rs/toolchains/module_extension.bzl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,16 @@ def _toolchains_impl(mctx):
292292
sha256 = _sha_for("rust-analyzer", base_version, iso_date, exec_triple),
293293
)
294294

295+
if host_cargo_repo == None:
296+
fail("Could not find host Cargo repository for {}-{}".format(host_os, host_arch))
297+
host_cargo = "@{}//:bin/cargo{}".format(
298+
host_cargo_repo,
299+
".exe" if host_os == "windows" else "",
300+
)
301+
295302
host_tools_repository(
296303
name = "rs_rust_host_tools",
297-
host_cargo_repo = host_cargo_repo,
298-
binary_suffix = ".exe" if host_os == "windows" else "",
304+
host_cargo = host_cargo,
299305
)
300306

301307
# `rs_rust_host_tools` is an implementation detail of rules_rs itself.

0 commit comments

Comments
 (0)