Skip to content

Commit

Permalink
Fix default cargo test experience (rust-lang#397)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexcrichton authored Mar 22, 2018
1 parent 56937d2 commit 20f9bfc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
8 changes: 8 additions & 0 deletions crates/coresimd/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use std::env;

fn main() {
println!(
"cargo:rustc-env=TARGET={}",
env::var("TARGET").unwrap()
);
}
15 changes: 2 additions & 13 deletions crates/simd-test-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 \"-\": {}",
Expand Down

0 comments on commit 20f9bfc

Please sign in to comment.