Skip to content

Commit

Permalink
Fix macOS case, and tests in openblas_build
Browse files Browse the repository at this point in the history
  • Loading branch information
termoshtt committed Dec 24, 2022
1 parent b4938ed commit b6ade9a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
29 changes: 19 additions & 10 deletions openblas-build/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,16 +434,28 @@ mod tests {
));
}

fn get_openblas_source() -> PathBuf {
let openblas_src_root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../openblas-src");
let openblas_version = "0.3.21";
let source = openblas_src_root.join(format!("OpenBLAS-{}", openblas_version));
if !source.exists() {
Command::new("tar")
.arg("xf")
.arg(format!("OpenBLAS-{}.tar.gz", openblas_version))
.current_dir(openblas_src_root)
.status()
.expect("tar command not found");
}
source
}

#[ignore]
#[test]
fn build_default() {
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let opt = Configure::default();
let _detail = opt
.build(
root.join("../openblas-src/source"),
root.join("test_build/build_default"),
)
.build(get_openblas_source(), root.join("test_build/build_default"))
.unwrap();
}

Expand All @@ -455,7 +467,7 @@ mod tests {
opt.no_shared = true;
let detail = opt
.build(
root.join("../openblas-src/source"),
get_openblas_source(),
root.join("test_build/build_no_shared"),
)
.unwrap();
Expand All @@ -470,7 +482,7 @@ mod tests {
opt.no_lapacke = true;
let detail = opt
.build(
root.join("../openblas-src/source"),
get_openblas_source(),
root.join("test_build/build_no_lapacke"),
)
.unwrap();
Expand All @@ -486,10 +498,7 @@ mod tests {
let mut opt = Configure::default();
opt.use_openmp = true;
let detail = opt
.build(
root.join("../openblas-src/source"),
root.join("test_build/build_openmp"),
)
.build(get_openblas_source(), root.join("test_build/build_openmp"))
.unwrap();
assert!(detail.shared_lib.unwrap().has_lib("gomp"));
}
Expand Down
15 changes: 11 additions & 4 deletions openblas-src/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::{env, path::*, process::Command};

const OPENBLAS_VERSION: &str = "0.3.21";

fn feature_enabled(feature: &str) -> bool {
env::var(format!("CARGO_FEATURE_{}", feature.to_uppercase())).is_ok()
}
Expand Down Expand Up @@ -158,13 +160,12 @@ fn build() {
);
}

let openblas_version = "0.3.21";
let source =
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("OpenBLAS-{}", openblas_version));
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("OpenBLAS-{}", OPENBLAS_VERSION));
if !source.exists() {
Command::new("tar")
.arg("xf")
.arg(format!("OpenBLAS-{}.tar.gz", openblas_version))
.arg(format!("OpenBLAS-{}.tar.gz", OPENBLAS_VERSION))
.current_dir(env!("CARGO_MANIFEST_DIR"))
.status()
.expect("tar command not found");
Expand Down Expand Up @@ -243,7 +244,13 @@ fn build() {
if source_tmp.exists() {
fs::remove_dir_all(&source_tmp).unwrap();
}
run(Command::new("cp").arg("-R").arg("source").arg(&source_tmp));
run(Command::new("tar")
.arg("xf")
.arg(format!("OpenBLAS-{}.tar.gz", OPENBLAS_VERSION)));
run(Command::new("cp")
.arg("-R")
.arg(format!("OpenBLAS-{}", OPENBLAS_VERSION))
.arg(&source_tmp));
fs::rename(&source_tmp, &source).unwrap();
}
for name in &vec!["CC", "FC", "HOSTCC"] {
Expand Down

0 comments on commit b6ade9a

Please sign in to comment.