diff --git a/.gitmodules b/.gitmodules index 0654f55..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "source"] - path = openblas-src/source - url = https://github.com/xianyi/OpenBLAS.git diff --git a/openblas-build/src/build.rs b/openblas-build/src/build.rs index 4c13178..22fdf08 100644 --- a/openblas-build/src/build.rs +++ b/openblas-build/src/build.rs @@ -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(); } @@ -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(); @@ -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(); @@ -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")); } diff --git a/openblas-src/.gitignore b/openblas-src/.gitignore new file mode 100644 index 0000000..8c88798 --- /dev/null +++ b/openblas-src/.gitignore @@ -0,0 +1 @@ +OpenBLAS-*/ diff --git a/openblas-src/OpenBLAS-0.3.21.tar.gz b/openblas-src/OpenBLAS-0.3.21.tar.gz new file mode 100644 index 0000000..63ac0be Binary files /dev/null and b/openblas-src/OpenBLAS-0.3.21.tar.gz differ diff --git a/openblas-src/build.rs b/openblas-src/build.rs index bdb456e..adcd2d5 100644 --- a/openblas-src/build.rs +++ b/openblas-src/build.rs @@ -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() } @@ -158,7 +160,16 @@ fn build() { ); } - let source = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("source"); + let source = + 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)) + .current_dir(env!("CARGO_MANIFEST_DIR")) + .status() + .expect("tar command not found"); + } let deliv = cfg.build(&source, &output).unwrap(); println!("cargo:rustc-link-search={}", output.display()); @@ -233,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"] { diff --git a/openblas-src/source b/openblas-src/source deleted file mode 160000 index b89fb70..0000000 --- a/openblas-src/source +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b89fb708caa5a5a32de8f4306c4ff132e0228e9a