Skip to content

Commit c7f7a43

Browse files
committed
Use OID
1 parent 6faea92 commit c7f7a43

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

build.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,25 @@ use std::process::Command;
2828

2929
const MKL_ARCHIVE: &'static str = "mkl.tar.xz";
3030

31-
fn get_branch_name<P: AsRef<Path>>(crate_dir: P) -> String {
31+
fn get_oid<P: AsRef<Path>>(crate_dir: P) -> String {
3232
let repo = git2::Repository::open(crate_dir).unwrap();
3333
let head = repo.head().unwrap();
34-
head.shorthand().unwrap().to_string()
34+
head.target().unwrap().to_string()
3535
}
3636

3737
fn main() {
3838
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
3939
let crate_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
40-
let branch_name = get_branch_name(&crate_dir);
41-
if !out_dir.join(MKL_ARCHIVE).exists() {
42-
Command::new("wget")
43-
.arg(format!("https://github.com/termoshtt/rust-intel-mkl/raw/{}/mkl_lib/mkl.tar.xz",
44-
branch_name))
45-
.current_dir(&out_dir)
46-
.status()
47-
.expect("Failed to start download (maybe 'wget' is missing?)");
48-
}
40+
let oid = get_oid(&crate_dir);
41+
let uri = format!("https://github.com/termoshtt/rust-intel-mkl/raw/{}/mkl_lib/{}",
42+
oid,
43+
MKL_ARCHIVE);
44+
println!("Download URI = {}", uri);
45+
Command::new("wget")
46+
.args(&["-q", &uri, "-O", MKL_ARCHIVE])
47+
.current_dir(&out_dir)
48+
.status()
49+
.expect("Failed to start download (maybe 'wget' is missing?)");
4950
Command::new("tar")
5051
.args(&["Jxvf", MKL_ARCHIVE])
5152
.current_dir(&out_dir)

0 commit comments

Comments
 (0)