Fix default cargo test experience (#397)

Turns out Cargo doesn't automatically set `TARGET` for rustc invocations so
carry it forward manually from the build script over to the rustc invocation.
This commit is contained in:
Alex Crichton 2018-03-22 17:40:44 -05:00 committed by GitHub
parent fa924e754d
commit aafe6ebb75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 13 deletions

View file

@ -0,0 +1,8 @@
use std::env;
fn main() {
println!(
"cargo:rustc-env=TARGET={}",
env::var("TARGET").unwrap()
);
}

View file

@ -60,19 +60,8 @@ pub fn simd_test(
name.clone().as_str()
));
let default_target = if cfg!(target_os = "windows") {
Some("x86_64-pc-windows-msvc")
} else if cfg!(target_os = "linux") {
Some("x86_64-unknown-linux-gnu")
} else if cfg!(target_os = "macos") {
Some("x86_64-apple-darwin")
} else {
None
};
let target = env::var("TARGET").unwrap_or_else(|_| {
default_target.expect("TARGET environment variable not set and no default target known for the current target.").to_string()
});
let target = env::var("TARGET")
.expect("TARGET environment variable should be set for rustc");
let mut force_test = false;
let macro_test = match target.split('-').next().expect(&format!(
"target triple contained no \"-\": {}",