Skip to content

Commit c478895

Browse files
committed
Fix macOS case, and tests in openblas_build
1 parent b4938ed commit c478895

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

openblas-build/src/build.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -434,16 +434,28 @@ mod tests {
434434
));
435435
}
436436

437+
fn get_openblas_source() -> PathBuf {
438+
let openblas_src_root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../openblas-src");
439+
let openblas_version = "0.3.21";
440+
let source = openblas_src_root.join(format!("OpenBLAS-{}", openblas_version));
441+
if !source.exists() {
442+
Command::new("tar")
443+
.arg("xf")
444+
.arg(format!("OpenBLAS-{}.tar.gz", openblas_version))
445+
.current_dir(openblas_src_root)
446+
.status()
447+
.expect("tar command not found");
448+
}
449+
source
450+
}
451+
437452
#[ignore]
438453
#[test]
439454
fn build_default() {
440455
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
441456
let opt = Configure::default();
442457
let _detail = opt
443-
.build(
444-
root.join("../openblas-src/source"),
445-
root.join("test_build/build_default"),
446-
)
458+
.build(get_openblas_source(), root.join("test_build/build_default"))
447459
.unwrap();
448460
}
449461

@@ -455,7 +467,7 @@ mod tests {
455467
opt.no_shared = true;
456468
let detail = opt
457469
.build(
458-
root.join("../openblas-src/source"),
470+
get_openblas_source(),
459471
root.join("test_build/build_no_shared"),
460472
)
461473
.unwrap();
@@ -470,7 +482,7 @@ mod tests {
470482
opt.no_lapacke = true;
471483
let detail = opt
472484
.build(
473-
root.join("../openblas-src/source"),
485+
get_openblas_source(),
474486
root.join("test_build/build_no_lapacke"),
475487
)
476488
.unwrap();

openblas-src/build.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::{env, path::*, process::Command};
22

3+
const OPENBLAS_VERSION: &str = "0.3.21";
4+
35
fn feature_enabled(feature: &str) -> bool {
46
env::var(format!("CARGO_FEATURE_{}", feature.to_uppercase())).is_ok()
57
}
@@ -158,13 +160,12 @@ fn build() {
158160
);
159161
}
160162

161-
let openblas_version = "0.3.21";
162163
let source =
163-
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("OpenBLAS-{}", openblas_version));
164+
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("OpenBLAS-{}", OPENBLAS_VERSION));
164165
if !source.exists() {
165166
Command::new("tar")
166167
.arg("xf")
167-
.arg(format!("OpenBLAS-{}.tar.gz", openblas_version))
168+
.arg(format!("OpenBLAS-{}.tar.gz", OPENBLAS_VERSION))
168169
.current_dir(env!("CARGO_MANIFEST_DIR"))
169170
.status()
170171
.expect("tar command not found");
@@ -243,7 +244,10 @@ fn build() {
243244
if source_tmp.exists() {
244245
fs::remove_dir_all(&source_tmp).unwrap();
245246
}
246-
run(Command::new("cp").arg("-R").arg("source").arg(&source_tmp));
247+
run(Command::new("cp")
248+
.arg("-R")
249+
.arg(format!("OpenBLAS-{}", OPENBLAS_VERSION))
250+
.arg(&source_tmp));
247251
fs::rename(&source_tmp, &source).unwrap();
248252
}
249253
for name in &vec!["CC", "FC", "HOSTCC"] {

0 commit comments

Comments
 (0)