Include all toolchain files in the current toolchain (#2336)

rustc assumes it can read things like librustc_driver, and if you don't
include it, it gets sad.
This commit is contained in:
Daniel Wagner-Hall 2023-12-18 15:29:32 +00:00 committed by GitHub
parent 9e146e5dc5
commit 5ceebc08a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 10 deletions

View File

@ -81,20 +81,11 @@ toolchain_files = rule(
def _current_rust_toolchain_impl(ctx):
toolchain = ctx.toolchains[str(Label("@rules_rust//rust:toolchain_type"))]
files = [
toolchain.rustc,
toolchain.rust_doc,
toolchain.cargo,
]
if toolchain.rustfmt:
files.append(toolchain.rustfmt)
return [
toolchain,
toolchain.make_variables,
DefaultInfo(
files = depset(files),
files = toolchain.all_files,
),
]

View File

@ -1,3 +1,19 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load(":toolchain_test.bzl", "toolchain_test_suite")
toolchain_test_suite(name = "toolchain_test_suite")
genrule(
name = "inspect",
outs = ["rustc-cfg"],
# rustc assumes it can read things like librustc_driver in order to run this command.
# This is a test to ensure we supply all of the files rustc needs as part of the current_rust_toolchain.
cmd = "$(RUSTC) --print=cfg > $@",
toolchains = ["@rules_rust//rust/toolchain:current_rust_toolchain"],
tools = ["@rules_rust//rust/toolchain:current_rust_toolchain"],
)
build_test(
name = "inspect_build_test",
targets = [":inspect"],
)