Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit c750c66

Browse files
committed
Read env vars at runtime, not compile time
1 parent a704d31 commit c750c66

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/build.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -369,22 +369,23 @@ impl BuildQueue {
369369
}
370370
if self.config.sysroot.is_empty() {
371371
args.push("--sysroot".to_owned());
372-
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
373-
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
374-
let sys_root = if let (Some(home), Some(toolchain)) = (home, toolchain) {
372+
let home = env::var("RUSTUP_HOME").or(env::var("MULTIRUST_HOME"));
373+
let toolchain = env::var("RUSTUP_TOOLCHAIN").or(env::var("MULTIRUST_TOOLCHAIN"));
374+
let sys_root = if let (Ok(home), Ok(toolchain)) = (home, toolchain) {
375375
format!("{}/toolchains/{}", home, toolchain)
376376
} else {
377-
option_env!("SYSROOT")
377+
env::var("SYSROOT")
378378
.map(|s| s.to_owned())
379-
.or_else(|| Command::new("rustc")
380-
.arg("--print")
381-
.arg("sysroot")
382-
.output()
383379
.ok()
384-
.and_then(|out| String::from_utf8(out.stdout).ok())
385-
.map(|s| s.trim().to_owned()))
386-
.expect("need to specify SYSROOT env var, \
387-
or use rustup or multirust")
380+
.or_else(|| Command::new("rustc")
381+
.arg("--print")
382+
.arg("sysroot")
383+
.output()
384+
.ok()
385+
.and_then(|out| String::from_utf8(out.stdout).ok())
386+
.map(|s| s.trim().to_owned()))
387+
.expect("need to specify SYSROOT env var, \
388+
or use rustup or multirust")
388389
};
389390
args.push(sys_root.to_owned());
390391
}

0 commit comments

Comments
 (0)