Skip to content

Commit

Permalink
Merge pull request #413 from NCGThompson/check-rustup-home-flag
Browse files Browse the repository at this point in the history
Honor `$RUSTUP_HOME`
  • Loading branch information
antoyo authored Jan 19, 2024
2 parents 1a8e0c3 + dcb531f commit e4e9365
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,10 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
}

fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
let toolchain = get_toolchain()?;

let toolchain = format!("+{channel}-{host}",
channel = get_toolchain()?, // May also include date
host = args.config_info.host_triple
);
let rust_dir = Some(Path::new("rust"));
// If the repository was already cloned, command will fail, so doesn't matter.
let _ = run_command_with_output_and_env(
Expand Down Expand Up @@ -524,6 +526,18 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
Ok(cargo)
}
})?;
let rustc = String::from_utf8(
run_command_with_env(&[&"rustup", &toolchain, &"which", &"rustc"], rust_dir, Some(env))?.stdout,
)
.map_err(|error| format!("Failed to retrieve rustc path: {:?}", error))
.and_then(|rustc| {
let rustc = rustc.trim().to_owned();
if rustc.is_empty() {
Err(format!("`rustc` path is empty"))
} else {
Ok(rustc)
}
})?;
let llvm_filecheck = match run_command_with_env(
&[
&"bash",
Expand Down Expand Up @@ -556,18 +570,16 @@ verbose-tests = true
[build]
cargo = "{cargo}"
local-rebuild = true
rustc = "{home}/.rustup/toolchains/{toolchain}-{host_triple}/bin/rustc"
rustc = "{rustc}"
[target.x86_64-unknown-linux-gnu]
llvm-filecheck = "{llvm_filecheck}"
[llvm]
download-ci-llvm = false
"#,
cargo = cargo.trim(),
home = env.get("HOME").unwrap(),
toolchain = toolchain,
host_triple = args.config_info.host_triple,
cargo = cargo,
rustc = rustc,
llvm_filecheck = llvm_filecheck.trim(),
),
)
Expand Down

0 comments on commit e4e9365

Please sign in to comment.