Skip to content

Commit b398c70

Browse files
committed
test
1 parent 8142d61 commit b398c70

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

rust/private/rustdoc_test.bzl

+10-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _rust_doc_test_impl(ctx):
3636

3737
# Construct rustdoc test command, which will be written to a shell script
3838
# to be executed to run the test.
39-
flags = _build_rustdoc_flags(dep_info, crate)
39+
flags = _build_rustdoc_flags(dep_info, crate, toolchain)
4040
if toolchain.os != "windows":
4141
rust_doc_test = _build_rustdoc_test_bash_script(ctx, toolchain, flags, crate)
4242
else:
@@ -77,12 +77,13 @@ def _dirname(path_str):
7777
"""
7878
return "/".join(path_str.split("/")[:-1])
7979

80-
def _build_rustdoc_flags(dep_info, crate):
80+
def _build_rustdoc_flags(dep_info, crate, toolchain):
8181
"""Constructs the rustdoc script used to test `crate`.
8282
8383
Args:
8484
dep_info (DepInfo): The DepInfo provider
8585
crate (CrateInfo): The CrateInfo provider
86+
toolchain (rust_toolchain): The rust toolchain
8687
8788
Returns:
8889
list: A list of rustdoc flags (str)
@@ -98,6 +99,13 @@ def _build_rustdoc_flags(dep_info, crate):
9899
link_flags += ["--extern=" + c.name + "=" + c.dep.output.short_path for c in d.direct_crates.to_list()]
99100
link_search_flags += ["-Ldependency={}".format(_dirname(c.output.short_path)) for c in d.transitive_crates.to_list()]
100101

102+
# Gets the paths to the folders containing the standard library (or libcore)
103+
rust_lib_files = depset(transitive = [toolchain.rust_lib.files, toolchain.rustc_lib.files])
104+
rust_lib_paths = depset([file.dirname for file in rust_lib_files.to_list()]).to_list()
105+
106+
# Tell Rustc where to find the standard library
107+
link_search_flags.extend(["-L {}".format(lib) for lib in rust_lib_paths])
108+
101109
# TODO(hlopko): use the more robust logic from rustc.bzl also here, through a reasonable API.
102110
for lib_to_link in dep_info.transitive_noncrates.to_list():
103111
is_static = bool(lib_to_link.static_library or lib_to_link.pic_static_library)

0 commit comments

Comments
 (0)