Skip to content

Commit ad24943

Browse files
authored
Provide RUSTDOC env var to build scripts (#3656)
`built`[expects this to be present at build script runtime](https://github.com/lukaslueg/built/blob/0d82cd1b959275dd5b05ee717634913a18192d1f/src/environment.rs#L379)
1 parent 713ab24 commit ad24943

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

cargo/private/cargo_build_script.bzl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def _cargo_build_script_impl(ctx):
369369

370370
cc_toolchain = find_cpp_toolchain(ctx)
371371

372-
env = dict({})
372+
env = {}
373373

374374
if ctx.attr.use_default_shell_env == -1:
375375
use_default_shell_env = ctx.attr._default_use_default_shell_env[BuildSettingInfo].value
@@ -384,9 +384,7 @@ def _cargo_build_script_impl(ctx):
384384
env.update(ctx.configuration.default_shell_env)
385385

386386
if toolchain.cargo:
387-
env.update({
388-
"CARGO": "${{pwd}}/{}".format(toolchain.cargo.path),
389-
})
387+
env["CARGO"] = "${pwd}/%s" % toolchain.cargo.path
390388

391389
env.update({
392390
"CARGO_CRATE_NAME": name_to_crate_name(pkg_name),
@@ -396,6 +394,7 @@ def _cargo_build_script_impl(ctx):
396394
"NUM_JOBS": "1",
397395
"OPT_LEVEL": compilation_mode_opt_level,
398396
"RUSTC": toolchain.rustc.path,
397+
"RUSTDOC": toolchain.rust_doc.path,
399398
"TARGET": toolchain.target_flag_value,
400399
# OUT_DIR is set by the runner itself, rather than on the action.
401400
})

test/cargo_build_script/tools_exec/build.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ fn main() {
4848
for env_var in &["CARGO", "CC", "CXX", "LD", "RUSTC"] {
4949
let path = std::env::var(env_var)
5050
.unwrap_or_else(|err| panic!("Error getting {}: {}", env_var, err));
51-
std::process::Command::new(path).status().unwrap();
51+
std::process::Command::new(&path).status()
52+
.unwrap_or_else(|err| panic!("Error executing {}: {}", path, err));
5253
}
5354

5455
// Assert that some env variables are set.
55-
for env_var in &["CFLAGS", "CXXFLAGS", "LDFLAGS"] {
56+
for env_var in &["CFLAGS", "CXXFLAGS", "LDFLAGS", "RUSTDOC"] {
5657
assert!(std::env::var(env_var).is_ok());
5758
}
5859

0 commit comments

Comments
 (0)