Skip to content

Commit e7056eb

Browse files
authored
Merge branch 'main' into cargo-build-cflags
2 parents 953cce3 + bbccf77 commit e7056eb

File tree

28 files changed

+263
-99
lines changed

28 files changed

+263
-99
lines changed

.bazelci/presubmit.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,5 +302,9 @@ tasks:
302302
# TODO: fix test targets in `crate_universe_windows_targets`
303303
test_targets: *crate_universe_windows_targets
304304
buildifier:
305-
version: latest
305+
# TODO: Version 5.0.0 introduced a ton of unused variable warnings in cases
306+
# that should have been accounted for by `_` prefixes on the variable. Buildifier
307+
# should ignore `_` prefixed variables when checking if something is unused
308+
# https://github.com/bazelbuild/buildtools/issues/1044
309+
version: 4.2.5
306310
warnings: "all"

cargo/cargo_bootstrap.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ def _cargo_bootstrap_repository_impl(repository_ctx):
188188
rustc_template = repository_ctx.attr.rust_toolchain_rustc_template
189189

190190
tools = get_rust_tools(
191-
repository_ctx = repository_ctx,
192191
cargo_template = cargo_template,
193192
rustc_template = rustc_template,
194193
host_triple = host_triple,

cargo/private/cargo_utils.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,10 @@ def _resolve_repository_template(
151151

152152
return template
153153

154-
def get_rust_tools(repository_ctx, cargo_template, rustc_template, host_triple, version):
154+
def get_rust_tools(cargo_template, rustc_template, host_triple, version):
155155
"""Retrieve `cargo` and `rustc` labels based on the host triple.
156156
157157
Args:
158-
repository_ctx (repository_ctx): The rule's context object
159158
cargo_template (str): A template used to identify the label of the host `cargo` binary.
160159
rustc_template (str): A template used to identify the label of the host `rustc` binary.
161160
host_triple (struct): The host's triple. See `@rules_rust//rust/platform:triple.bzl`.

crate_universe/defs.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def _override(
377377
if not type(dep_val) == "dict":
378378
fail("The {} attribute should be a dictionary".format(dep_key))
379379

380-
for target, deps in dep_val.items():
380+
for deps in dep_val.values():
381381
if not type(deps) == "list" or any([type(x) != "string" for x in deps]):
382382
fail("The {} values should be lists of strings".format(dep_key))
383383

crate_universe/private/util.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def get_cargo_and_rustc(repository_ctx, host_triple):
123123
version_str = repository_ctx.attr.version
124124

125125
# Get info about the current host's tool locations
126-
(host_triple, resolver_triple) = get_host_triple(repository_ctx)
126+
host_triple, _ = get_host_triple(repository_ctx)
127127
system = triple_to_system(host_triple)
128128
extension = system_to_binary_ext(system)
129129
arch = triple_to_arch(host_triple)

crate_universe/src/templates/partials/build_script.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ cargo_build_script(
5151
{%- include "templates/partials/targeted_build_script_data_dependencies.template" -%},
5252
{%- else -%},
5353
{%- endif %}
54+
aliases = {%- include "templates/partials/targeted_aliases.template" %},
5455
tags = [
5556
"cargo-raze",
5657
"manual",

docs/flatten.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,9 +1110,9 @@ Run the test with `bazel build //hello_lib:hello_lib_test`.
11101110

11111111
<pre>
11121112
rust_toolchain(<a href="#rust_toolchain-name">name</a>, <a href="#rust_toolchain-allocator_library">allocator_library</a>, <a href="#rust_toolchain-binary_ext">binary_ext</a>, <a href="#rust_toolchain-cargo">cargo</a>, <a href="#rust_toolchain-clippy_driver">clippy_driver</a>, <a href="#rust_toolchain-debug_info">debug_info</a>,
1113-
<a href="#rust_toolchain-default_edition">default_edition</a>, <a href="#rust_toolchain-dylib_ext">dylib_ext</a>, <a href="#rust_toolchain-exec_triple">exec_triple</a>, <a href="#rust_toolchain-opt_level">opt_level</a>, <a href="#rust_toolchain-os">os</a>, <a href="#rust_toolchain-rust_doc">rust_doc</a>, <a href="#rust_toolchain-rust_lib">rust_lib</a>, <a href="#rust_toolchain-rust_std">rust_std</a>,
1114-
<a href="#rust_toolchain-rustc">rustc</a>, <a href="#rust_toolchain-rustc_lib">rustc_lib</a>, <a href="#rust_toolchain-rustc_srcs">rustc_srcs</a>, <a href="#rust_toolchain-rustfmt">rustfmt</a>, <a href="#rust_toolchain-staticlib_ext">staticlib_ext</a>, <a href="#rust_toolchain-stdlib_linkflags">stdlib_linkflags</a>, <a href="#rust_toolchain-target_json">target_json</a>,
1115-
<a href="#rust_toolchain-target_triple">target_triple</a>)
1113+
<a href="#rust_toolchain-default_edition">default_edition</a>, <a href="#rust_toolchain-dylib_ext">dylib_ext</a>, <a href="#rust_toolchain-exec_triple">exec_triple</a>, <a href="#rust_toolchain-llvm_tools">llvm_tools</a>, <a href="#rust_toolchain-opt_level">opt_level</a>, <a href="#rust_toolchain-os">os</a>, <a href="#rust_toolchain-rust_doc">rust_doc</a>, <a href="#rust_toolchain-rust_lib">rust_lib</a>,
1114+
<a href="#rust_toolchain-rust_std">rust_std</a>, <a href="#rust_toolchain-rustc">rustc</a>, <a href="#rust_toolchain-rustc_lib">rustc_lib</a>, <a href="#rust_toolchain-rustc_srcs">rustc_srcs</a>, <a href="#rust_toolchain-rustfmt">rustfmt</a>, <a href="#rust_toolchain-staticlib_ext">staticlib_ext</a>, <a href="#rust_toolchain-stdlib_linkflags">stdlib_linkflags</a>,
1115+
<a href="#rust_toolchain-target_json">target_json</a>, <a href="#rust_toolchain-target_triple">target_triple</a>)
11161116
</pre>
11171117

11181118
Declares a Rust toolchain for use.
@@ -1170,6 +1170,7 @@ See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX r
11701170
| <a id="rust_toolchain-default_edition"></a>default_edition | The edition to use for rust_* rules that don't specify an edition. | String | optional | "2018" |
11711171
| <a id="rust_toolchain-dylib_ext"></a>dylib_ext | The extension for dynamic libraries created from rustc. | String | required | |
11721172
| <a id="rust_toolchain-exec_triple"></a>exec_triple | The platform triple for the toolchains execution environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations | String | required | |
1173+
| <a id="rust_toolchain-llvm_tools"></a>llvm_tools | LLVM tools that are shipped with the Rust toolchain. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
11731174
| <a id="rust_toolchain-opt_level"></a>opt_level | Rustc optimization levels. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {"dbg": "0", "fastbuild": "0", "opt": "3"} |
11741175
| <a id="rust_toolchain-os"></a>os | The operating system for the current toolchain | String | required | |
11751176
| <a id="rust_toolchain-rust_doc"></a>rust_doc | The location of the <code>rustdoc</code> binary. Can be a direct source or a filegroup containing one item. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |

docs/rust_repositories.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ A dedicated filegroup-like rule for Rust stdlib artifacts.
3535

3636
<pre>
3737
rust_toolchain(<a href="#rust_toolchain-name">name</a>, <a href="#rust_toolchain-allocator_library">allocator_library</a>, <a href="#rust_toolchain-binary_ext">binary_ext</a>, <a href="#rust_toolchain-cargo">cargo</a>, <a href="#rust_toolchain-clippy_driver">clippy_driver</a>, <a href="#rust_toolchain-debug_info">debug_info</a>,
38-
<a href="#rust_toolchain-default_edition">default_edition</a>, <a href="#rust_toolchain-dylib_ext">dylib_ext</a>, <a href="#rust_toolchain-exec_triple">exec_triple</a>, <a href="#rust_toolchain-opt_level">opt_level</a>, <a href="#rust_toolchain-os">os</a>, <a href="#rust_toolchain-rust_doc">rust_doc</a>, <a href="#rust_toolchain-rust_lib">rust_lib</a>, <a href="#rust_toolchain-rust_std">rust_std</a>,
39-
<a href="#rust_toolchain-rustc">rustc</a>, <a href="#rust_toolchain-rustc_lib">rustc_lib</a>, <a href="#rust_toolchain-rustc_srcs">rustc_srcs</a>, <a href="#rust_toolchain-rustfmt">rustfmt</a>, <a href="#rust_toolchain-staticlib_ext">staticlib_ext</a>, <a href="#rust_toolchain-stdlib_linkflags">stdlib_linkflags</a>, <a href="#rust_toolchain-target_json">target_json</a>,
40-
<a href="#rust_toolchain-target_triple">target_triple</a>)
38+
<a href="#rust_toolchain-default_edition">default_edition</a>, <a href="#rust_toolchain-dylib_ext">dylib_ext</a>, <a href="#rust_toolchain-exec_triple">exec_triple</a>, <a href="#rust_toolchain-llvm_tools">llvm_tools</a>, <a href="#rust_toolchain-opt_level">opt_level</a>, <a href="#rust_toolchain-os">os</a>, <a href="#rust_toolchain-rust_doc">rust_doc</a>, <a href="#rust_toolchain-rust_lib">rust_lib</a>,
39+
<a href="#rust_toolchain-rust_std">rust_std</a>, <a href="#rust_toolchain-rustc">rustc</a>, <a href="#rust_toolchain-rustc_lib">rustc_lib</a>, <a href="#rust_toolchain-rustc_srcs">rustc_srcs</a>, <a href="#rust_toolchain-rustfmt">rustfmt</a>, <a href="#rust_toolchain-staticlib_ext">staticlib_ext</a>, <a href="#rust_toolchain-stdlib_linkflags">stdlib_linkflags</a>,
40+
<a href="#rust_toolchain-target_json">target_json</a>, <a href="#rust_toolchain-target_triple">target_triple</a>)
4141
</pre>
4242

4343
Declares a Rust toolchain for use.
@@ -95,6 +95,7 @@ See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX r
9595
| <a id="rust_toolchain-default_edition"></a>default_edition | The edition to use for rust_* rules that don't specify an edition. | String | optional | "2018" |
9696
| <a id="rust_toolchain-dylib_ext"></a>dylib_ext | The extension for dynamic libraries created from rustc. | String | required | |
9797
| <a id="rust_toolchain-exec_triple"></a>exec_triple | The platform triple for the toolchains execution environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations | String | required | |
98+
| <a id="rust_toolchain-llvm_tools"></a>llvm_tools | LLVM tools that are shipped with the Rust toolchain. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
9899
| <a id="rust_toolchain-opt_level"></a>opt_level | Rustc optimization levels. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {"dbg": "0", "fastbuild": "0", "opt": "3"} |
99100
| <a id="rust_toolchain-os"></a>os | The operating system for the current toolchain | String | required | |
100101
| <a id="rust_toolchain-rust_doc"></a>rust_doc | The location of the <code>rustdoc</code> binary. Can be a direct source or a filegroup containing one item. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |

examples/crate_universe/basic/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ rust_binary(
77
edition = "2018",
88
deps = [
99
crate("lazy_static"),
10+
crate("value-bag"),
1011
],
1112
)
1213

examples/crate_universe/basic/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use lazy_static::lazy_static;
22
use std::collections::HashMap;
3+
use value_bag::ValueBag;
34

45
lazy_static! {
56
static ref HASHMAP: HashMap<&'static str, &'static str> = {
@@ -12,6 +13,10 @@ lazy_static! {
1213
}
1314

1415
fn main() {
16+
let bag = ValueBag::capture_display(&42);
17+
let num = bag.to_u64().unwrap();
18+
19+
assert_eq!(num, 42);
1520
assert_eq!(HASHMAP["Daniel"], "Wagner-Hall");
1621
println!("It worked!");
1722
}

examples/crate_universe/basic/workspace.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ def deps():
1010
name = "lazy_static",
1111
semver = "=1.4",
1212
),
13+
crate.spec(
14+
name = "value-bag",
15+
semver = "=1.0.0-alpha.7",
16+
),
1317
],
1418
supported_targets = [
1519
"x86_64-apple-darwin",

proto/proto.bzl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ def _rust_proto_compile(protos, descriptor_sets, imports, crate_name, ctx, is_gr
212212
output_hash,
213213
))
214214

215-
toolchain = find_toolchain(ctx)
216-
217215
# Gather all dependencies for compilation
218216
compile_action_deps = depset(
219217
transform_deps(

rust/platform/triple_mappings.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def cpu_arch_to_constraints(cpu_arch):
172172

173173
return ["@platforms//cpu:{}".format(plat_suffix)]
174174

175-
def vendor_to_constraints(vendor):
175+
def vendor_to_constraints(_vendor):
176176
# TODO(acmcarther): Review:
177177
#
178178
# My current understanding is that vendors can't have a material impact on

rust/private/clippy.bzl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ def _clippy_aspect_impl(target, ctx):
6161

6262
toolchain = find_toolchain(ctx)
6363
cc_toolchain, feature_configuration = find_cc_toolchain(ctx)
64-
crate_type = crate_info.type
6564

6665
dep_info, build_info, linkstamps = collect_deps(
67-
label = ctx.label,
6866
deps = crate_info.deps,
6967
proc_macro_deps = crate_info.proc_macro_deps,
7068
aliases = crate_info.aliases,

rust/private/dummy_cc_toolchain/dummy_cc_toolchain.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# buildifier: disable=module-docstring
2-
def _dummy_cc_toolchain_impl(ctx):
2+
def _dummy_cc_toolchain_impl(_ctx):
33
# The `all_files` attribute is referenced by rustc_compile_action().
44
return [platform_common.ToolchainInfo(all_files = depset([]))]
55

rust/private/rust.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ load(
2727

2828
# TODO(marco): Separate each rule into its own file.
2929

30-
def _assert_no_deprecated_attributes(ctx):
30+
def _assert_no_deprecated_attributes(_ctx):
3131
"""Forces a failure if any deprecated attributes were specified
3232
3333
Args:
34-
ctx (ctx): The current rule's context object
34+
_ctx (ctx): The current rule's context object
3535
"""
3636
pass
3737

rust/private/rust_analyzer.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ rust_analyzer_detect_sysroot = rule(
221221
"""),
222222
)
223223

224-
def _rust_analyzer_impl(ctx):
224+
def _rust_analyzer_impl(_ctx):
225225
pass
226226

227227
rust_analyzer = rule(

rust/private/rustc.bzl

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,13 @@ def _are_linkstamps_supported(feature_configuration, has_grep_includes):
118118
has_grep_includes)
119119

120120
def collect_deps(
121-
label,
122121
deps,
123122
proc_macro_deps,
124123
aliases,
125124
are_linkstamps_supported = False):
126125
"""Walks through dependencies and collects the transitive dependencies.
127126
128127
Args:
129-
label (str): Label of the current target.
130128
deps (list): The deps from ctx.attr.deps.
131129
proc_macro_deps (list): The proc_macro deps from ctx.attr.proc_macro_deps.
132130
aliases (dict): A dict mapping aliased targets to their actual Crate information.
@@ -142,7 +140,6 @@ def collect_deps(
142140
direct_crates = []
143141
transitive_crates = []
144142
transitive_noncrates = []
145-
transitive_noncrate_libs = []
146143
transitive_build_infos = []
147144
build_info = None
148145
linkstamps = []
@@ -192,7 +189,6 @@ def collect_deps(
192189
"targets.")
193190

194191
transitive_crates_depset = depset(transitive = transitive_crates)
195-
transitive_libs = depset([])
196192

197193
return (
198194
rust_common.dep_info(
@@ -301,20 +297,12 @@ def get_linker_and_args(ctx, attr, cc_toolchain, feature_configuration, rpaths):
301297
return ld, link_args, link_env
302298

303299
def _process_build_scripts(
304-
ctx,
305-
file,
306-
crate_info,
307300
build_info,
308-
dep_info,
309301
compile_inputs):
310302
"""Gathers the outputs from a target's `cargo_build_script` action.
311303
312304
Args:
313-
ctx (ctx): The rule's context object
314-
file (File): A struct containing files defined in label type attributes marked as `allow_single_file`.
315-
crate_info (CrateInfo): The Crate information of the crate to process build scripts for.
316305
build_info (BuildInfo): The target Build's dependency info.
317-
dep_info (Depinfo): The target Crate's dependency info.
318306
compile_inputs (depset): A set of all files that will participate in the build.
319307
320308
Returns:
@@ -324,7 +312,7 @@ def _process_build_scripts(
324312
- (File): An optional path to a generated environment file from a `cargo_build_script` target
325313
- (list): All direct and transitive build flags from the current build info.
326314
"""
327-
extra_inputs, out_dir, build_env_file, build_flags_files = _create_extra_input_args(ctx, file, build_info, dep_info)
315+
extra_inputs, out_dir, build_env_file, build_flags_files = _create_extra_input_args(build_info)
328316
if extra_inputs:
329317
compile_inputs = depset(extra_inputs, transitive = [compile_inputs])
330318
return compile_inputs, out_dir, build_env_file, build_flags_files
@@ -392,19 +380,16 @@ def collect_inputs(
392380

393381
nolinkstamp_compile_inputs = depset(
394382
getattr(files, "data", []) +
395-
[toolchain.rustc] +
396-
toolchain.crosstool_files +
397383
([build_info.rustc_env, build_info.flags] if build_info else []) +
398384
([toolchain.target_json] if toolchain.target_json else []) +
399385
([] if linker_script == None else [linker_script]),
400386
transitive = [
401-
toolchain.rustc_lib,
402-
toolchain.rust_std,
403387
linker_depset,
404388
crate_info.srcs,
405389
dep_info.transitive_crate_outputs,
406390
depset(additional_transitive_inputs),
407391
crate_info.compile_data,
392+
toolchain.all_files,
408393
],
409394
)
410395

@@ -447,7 +432,7 @@ def collect_inputs(
447432
)
448433

449434
build_env_files = getattr(files, "rustc_env_files", [])
450-
compile_inputs, out_dir, build_env_file, build_flags_files = _process_build_scripts(ctx, file, crate_info, build_info, dep_info, compile_inputs)
435+
compile_inputs, out_dir, build_env_file, build_flags_files = _process_build_scripts(build_info, compile_inputs)
451436
if build_env_file:
452437
build_env_files = [f for f in build_env_files] + [build_env_file]
453438
compile_inputs = depset(build_env_files, transitive = [compile_inputs])
@@ -666,7 +651,7 @@ def construct_arguments(
666651
data_paths,
667652
))
668653

669-
# Set the SYSROOT to the directory of the rust_std files passed to the toolchain
654+
# Ensure the sysroot is set for the target platform
670655
env["SYSROOT"] = toolchain.sysroot
671656

672657
# extra_rustc_flags apply to the target configuration, not the exec configuration.
@@ -694,7 +679,6 @@ def rustc_compile_action(
694679
crate_info,
695680
output_hash = None,
696681
rust_flags = [],
697-
environ = {},
698682
force_all_deps_direct = False):
699683
"""Create and run a rustc compile action based on the current rule's attributes
700684
@@ -705,7 +689,6 @@ def rustc_compile_action(
705689
crate_info (CrateInfo): The CrateInfo provider for the current target.
706690
output_hash (str, optional): The hashed path of the crate root. Defaults to None.
707691
rust_flags (list, optional): Additional flags to pass to rustc. Defaults to [].
708-
environ (dict, optional): A set of makefile expandable environment variables for the action
709692
force_all_deps_direct (bool, optional): Whether to pass the transitive rlibs with --extern
710693
to the commandline as opposed to -L.
711694
@@ -718,7 +701,6 @@ def rustc_compile_action(
718701
cc_toolchain, feature_configuration = find_cc_toolchain(ctx)
719702

720703
dep_info, build_info, linkstamps = collect_deps(
721-
label = ctx.label,
722704
deps = crate_info.deps,
723705
proc_macro_deps = crate_info.proc_macro_deps,
724706
aliases = crate_info.aliases,
@@ -943,14 +925,11 @@ def add_edition_flags(args, crate):
943925
if crate.edition != "2015":
944926
args.add("--edition={}".format(crate.edition))
945927

946-
def _create_extra_input_args(ctx, file, build_info, dep_info):
928+
def _create_extra_input_args(build_info):
947929
"""Gather additional input arguments from transitive dependencies
948930
949931
Args:
950-
ctx (ctx): The rule's context object
951-
file (struct): A struct containing files defined in label type attributes marked as `allow_single_file`.
952932
build_info (BuildInfo): The BuildInfo provider from the target Crate's set of inputs.
953-
dep_info (DepInfo): The Depinfo provider form the target Crate's set of inputs.
954933
955934
Returns:
956935
tuple: A tuple of the following items:

rust/private/rustdoc.bzl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def rustdoc_compile_action(
7474
cc_toolchain, feature_configuration = find_cc_toolchain(ctx)
7575

7676
dep_info, build_info, linkstamps = collect_deps(
77-
label = ctx.label,
7877
deps = crate_info.deps,
7978
proc_macro_deps = crate_info.proc_macro_deps,
8079
aliases = crate_info.aliases,
@@ -120,6 +119,17 @@ def rustdoc_compile_action(
120119
force_link = True,
121120
)
122121

122+
# Because rustdoc tests compile tests outside of the sandbox, the sysroot
123+
# must be updated to the `short_path` equivilant as it will now be
124+
# a part of runfiles.
125+
if is_test:
126+
if "SYSROOT" in env:
127+
env.update({"SYSROOT": "${{pwd}}/{}".format(toolchain.sysroot_short_path)})
128+
129+
# `rustdoc` does not support the SYSROOT environment variable. To account
130+
# for this, the flag must be explicitly passed to the `rustdoc` binary.
131+
args.rustc_flags.add("--sysroot=${{pwd}}/{}".format(toolchain.sysroot_short_path))
132+
123133
return struct(
124134
executable = ctx.executable._process_wrapper,
125135
inputs = depset([crate_info.output], transitive = [compile_inputs]),
@@ -161,7 +171,6 @@ def _rust_doc_impl(ctx):
161171

162172
crate = ctx.attr.crate
163173
crate_info = crate[rust_common.crate_info]
164-
dep_info = crate[rust_common.dep_info]
165174

166175
output_dir = ctx.actions.declare_directory("{}.rustdoc".format(ctx.label.name))
167176

0 commit comments

Comments
 (0)