Skip to content

Use tar.gz image of OpenBLAS #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "source"]
path = openblas-src/source
url = https://github.com/xianyi/OpenBLAS.git
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
1 change: 1 addition & 0 deletions openblas-src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OpenBLAS-*/
Binary file added openblas-src/OpenBLAS-0.3.21.tar.gz
Binary file not shown.
21 changes: 19 additions & 2 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,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());
Expand Down Expand Up @@ -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"] {
Expand Down
1 change: 0 additions & 1 deletion openblas-src/source
Submodule source deleted from b89fb7