Skip to content

Commit d3a83ca

Browse files
committed
detect default TARGET in simd-test-macro
1 parent 61824fe commit d3a83ca

File tree

1 file changed

+11
-1
lines changed
  • crates/simd-test-macro/src

1 file changed

+11
-1
lines changed

crates/simd-test-macro/src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,17 @@ pub fn simd_test(
5656
let name: TokenStream = name.as_str().parse()
5757
.expect(&format!("failed to parse name: {}", name.clone().as_str()));
5858

59-
let target = env::var("TARGET").expect("TARGET environment variable not set");
59+
let default_target = if cfg!(target_os = "windows") {
60+
Some("x86_64-pc-windows-msvc")
61+
} else if cfg!(target_os = "linux") {
62+
Some("x86_64-unknown-linux-gnu")
63+
} else if cfg!(target_os = "macos") {
64+
Some("x86_64-apple-darwin")
65+
} else {
66+
None
67+
};
68+
69+
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());
6070
let mut force_test = false;
6171
let macro_test = match target.split('-').next()
6272
.expect(&format!("target triple contained no \"-\": {}", target)) {

0 commit comments

Comments
 (0)