Skip to content
Myr

Require cargo promised environment variables to be present

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 15646f4 · Browse files · 1 file+14 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+14 added−3 removed

  • other:+14 added−3 removed

1 file+14 added−3 removed

modified:build.rs+14 added-3 removed
1#![allow(clippy::option_if_let_else)]23use std::env;4use std::ffi::OsString;5use std::path::Path;5use std::process::{Command, ExitStatus, Stdio};6use std::process::{self, Command, ExitStatus, Stdio};7use std::str;89#[cfg(all(feature = "backtrace", not(feature = "std")))]10compile_error! {
55 unmodified lines
66 // Let's just not use nightly features here.67 return None;68 }6969 let rustc = env::var_os("RUSTC")?;70 let out_dir = env::var_os("OUT_DIR")?;70 let rustc = cargo_env_var("RUSTC");71 let out_dir = cargo_env_var("OUT_DIR");72 let probefile = Path::new("build").join("probe.rs");7374 // Make sure to pick up Cargo rustc configuration.75 let mut cmd = if let Some(wrapper) = env::var_os("RUSTC_WRAPPER") {
39 unmodified lines
115 return None;116 }117 pieces.next()?.parse().ok()118}119120fn cargo_env_var(key: &str) -> OsString {121 env::var_os(key).unwrap_or_else(|| {122 eprintln!(123 "Environment variable ${} is not set during execution of build script",124 key,125 );126 process::exit(1);127 })128}