Skip to content

Commit

Permalink
Report which required build-time environment variable is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Sep 25, 2016
1 parent 2d1d4d1 commit cc8727e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/bootstrap/bin/rustc.rs
Expand Up @@ -55,10 +55,10 @@ fn main() {
} else {
("RUSTC_REAL", "RUSTC_LIBDIR")
};
let stage = env::var("RUSTC_STAGE").unwrap();
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");

let rustc = env::var_os(rustc).unwrap();
let libdir = env::var_os(libdir).unwrap();
let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
let mut dylib_path = bootstrap::util::dylib_path();
dylib_path.insert(0, PathBuf::from(libdir));

Expand All @@ -71,7 +71,7 @@ fn main() {
if let Some(target) = target {
// The stage0 compiler has a special sysroot distinct from what we
// actually downloaded, so we just always pass the `--sysroot` option.
cmd.arg("--sysroot").arg(env::var_os("RUSTC_SYSROOT").unwrap());
cmd.arg("--sysroot").arg(env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set"));

// When we build Rust dylibs they're all intended for intermediate
// usage, so make sure we pass the -Cprefer-dynamic flag instead of
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/bin/rustdoc.rs
Expand Up @@ -20,15 +20,16 @@ use std::path::PathBuf;

fn main() {
let args = env::args_os().skip(1).collect::<Vec<_>>();
let rustdoc = env::var_os("RUSTDOC_REAL").unwrap();
let libdir = env::var_os("RUSTC_LIBDIR").unwrap();
let rustdoc = env::var_os("RUSTDOC_REAL").expect("RUSTDOC_REAL was not set");
let libdir = env::var_os("RUSTC_LIBDIR").expect("RUSTC_LIBDIR was not set");
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");

let mut dylib_path = bootstrap::util::dylib_path();
dylib_path.insert(0, PathBuf::from(libdir));

let mut cmd = Command::new(rustdoc);
cmd.args(&args)
.arg("--cfg").arg(format!("stage{}", env::var("RUSTC_STAGE").unwrap()))
.arg("--cfg").arg(format!("stage{}", stage))
.arg("--cfg").arg("dox")
.env(bootstrap::util::dylib_path_var(),
env::join_paths(&dylib_path).unwrap());
Expand All @@ -37,4 +38,3 @@ fn main() {
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
})
}

6 changes: 3 additions & 3 deletions src/liballoc_jemalloc/build.rs
Expand Up @@ -22,8 +22,8 @@ fn main() {
println!("cargo:rustc-cfg=cargobuild");
println!("cargo:rerun-if-changed=build.rs");

let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();
let target = env::var("TARGET").expect("TARGET was not set");
let host = env::var("HOST").expect("HOST was not set");
let build_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let src_dir = env::current_dir().unwrap();

Expand Down Expand Up @@ -140,7 +140,7 @@ fn main() {
.current_dir(&build_dir)
.arg("build_lib_static")
.arg("-j")
.arg(env::var("NUM_JOBS").unwrap()));
.arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));

if target.contains("windows") {
println!("cargo:rustc-link-lib=static=jemalloc");
Expand Down
2 changes: 1 addition & 1 deletion src/libcompiler_builtins/build.rs
Expand Up @@ -72,7 +72,7 @@ impl Sources {
}

fn main() {
let target = env::var("TARGET").unwrap();
let target = env::var("TARGET").expect("TARGET was not set");
let cfg = &mut gcc::Config::new();

if target.contains("msvc") {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_llvm/build.rs
Expand Up @@ -20,7 +20,7 @@ use build_helper::output;
fn main() {
println!("cargo:rustc-cfg=cargobuild");

let target = env::var("TARGET").unwrap();
let target = env::var("TARGET").expect("TARGET was not set");
let llvm_config = env::var_os("LLVM_CONFIG")
.map(PathBuf::from)
.unwrap_or_else(|| {
Expand Down Expand Up @@ -62,8 +62,8 @@ fn main() {
// can't trust all the output of llvm-config becaues it might be targeted
// for the host rather than the target. As a result a bunch of blocks below
// are gated on `if !is_crossed`
let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();
let target = env::var("TARGET").expect("TARGET was not set");
let host = env::var("HOST").expect("HOST was not set");
let is_crossed = target != host;

let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz"];
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/build.rs
Expand Up @@ -23,8 +23,8 @@ fn main() {
println!("cargo:rustc-cfg=cargobuild");
println!("cargo:rerun-if-changed=build.rs");

let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();
let target = env::var("TARGET").expect("TARGET was not set");
let host = env::var("HOST").expect("HOST was not set");
if cfg!(feature = "backtrace") && !target.contains("apple") && !target.contains("msvc") &&
!target.contains("emscripten") {
build_libbacktrace(&host, &target);
Expand Down Expand Up @@ -103,5 +103,5 @@ fn build_libbacktrace(host: &str, target: &str) {
run(Command::new("make")
.current_dir(&build_dir)
.arg(format!("INCDIR={}", src_dir.display()))
.arg("-j").arg(env::var("NUM_JOBS").unwrap()));
.arg("-j").arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));
}
2 changes: 1 addition & 1 deletion src/libunwind/build.rs
Expand Up @@ -13,7 +13,7 @@ use std::env;
fn main() {
println!("cargo:rustc-cfg=cargobuild");

let target = env::var("TARGET").unwrap();
let target = env::var("TARGET").expect("TARGET was not set");

if target.contains("linux") {
if target.contains("musl") && !target.contains("mips") {
Expand Down

0 comments on commit cc8727e

Please sign in to comment.