Skip to content

Commit 5651ba9

Browse files
authored
Merge pull request #95 from blas-lapack-rs/compress-source-dir
Use tar.gz image of OpenBLAS
2 parents eae9b86 + b6ade9a commit 5651ba9

File tree

6 files changed

+39
-16
lines changed

6 files changed

+39
-16
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "source"]
2-
path = openblas-src/source
3-
url = https://github.com/xianyi/OpenBLAS.git

openblas-build/src/build.rs

+19-10
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();
@@ -486,10 +498,7 @@ mod tests {
486498
let mut opt = Configure::default();
487499
opt.use_openmp = true;
488500
let detail = opt
489-
.build(
490-
root.join("../openblas-src/source"),
491-
root.join("test_build/build_openmp"),
492-
)
501+
.build(get_openblas_source(), root.join("test_build/build_openmp"))
493502
.unwrap();
494503
assert!(detail.shared_lib.unwrap().has_lib("gomp"));
495504
}

openblas-src/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
OpenBLAS-*/

openblas-src/OpenBLAS-0.3.21.tar.gz

22.6 MB
Binary file not shown.

openblas-src/build.rs

+19-2
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,7 +160,16 @@ fn build() {
158160
);
159161
}
160162

161-
let source = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("source");
163+
let source =
164+
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("OpenBLAS-{}", OPENBLAS_VERSION));
165+
if !source.exists() {
166+
Command::new("tar")
167+
.arg("xf")
168+
.arg(format!("OpenBLAS-{}.tar.gz", OPENBLAS_VERSION))
169+
.current_dir(env!("CARGO_MANIFEST_DIR"))
170+
.status()
171+
.expect("tar command not found");
172+
}
162173
let deliv = cfg.build(&source, &output).unwrap();
163174

164175
println!("cargo:rustc-link-search={}", output.display());
@@ -233,7 +244,13 @@ fn build() {
233244
if source_tmp.exists() {
234245
fs::remove_dir_all(&source_tmp).unwrap();
235246
}
236-
run(Command::new("cp").arg("-R").arg("source").arg(&source_tmp));
247+
run(Command::new("tar")
248+
.arg("xf")
249+
.arg(format!("OpenBLAS-{}.tar.gz", OPENBLAS_VERSION)));
250+
run(Command::new("cp")
251+
.arg("-R")
252+
.arg(format!("OpenBLAS-{}", OPENBLAS_VERSION))
253+
.arg(&source_tmp));
237254
fs::rename(&source_tmp, &source).unwrap();
238255
}
239256
for name in &vec!["CC", "FC", "HOSTCC"] {

openblas-src/source

-1
This file was deleted.

0 commit comments

Comments
 (0)