Skip to content

Commit 7744262

Browse files
committed
Refactor the build script
1 parent d9394cb commit 7744262

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

build.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
fn main() {
2-
let features = ["accelerate", "blis", "intel-mkl", "netlib", "openblas", "r"];
3-
let mut count = 0;
4-
for feature in &features {
5-
if std::env::var(format!(
6-
"CARGO_FEATURE_{}",
7-
feature.to_uppercase().replace('-', "_")
8-
))
9-
.is_ok()
10-
{
11-
count += 1;
12-
}
13-
}
1+
const FEATURES: &[&str] = &["accelerate", "blis", "intel-mkl", "netlib", "openblas", "r"];
142

15-
if count > 1 {
16-
panic!("Only one BLAS implementation feature may be enabled at a time.");
3+
fn main() {
4+
if FEATURES
5+
.iter()
6+
.map(|name| name.to_uppercase().replace('-', "_"))
7+
.map(|name| format!("CARGO_FEATURE_{name}"))
8+
.filter(|name| std::env::var(name).is_ok())
9+
.count()
10+
> 1
11+
{
12+
panic!("At most one BLAS implementation may be enabled at a time.");
1713
}
1814
}

0 commit comments

Comments
 (0)