@@ -10,28 +10,40 @@ use std::{
10
10
11
11
const S3_ADDR : & ' static str = "https://s3-ap-northeast-1.amazonaws.com/rust-intel-mkl" ;
12
12
13
- #[ cfg( target_os = "linux" ) ]
13
+ #[ cfg( all ( target_os = "linux" , target_arch = "x86_64" ) ) ]
14
14
mod mkl {
15
- pub const ARCHIVE_NAME : & ' static str = "mkl_linux64" ;
16
- pub const ARCHIVE : & ' static str = "mkl_linux.tar.xz" ;
15
+ pub const ARCHIVE : & ' static str = "mkl_linux64" ;
17
16
pub const EXT : & ' static str = "so" ;
18
17
pub const PREFIX : & ' static str = "lib" ;
18
+ pub const VERSION_YEAR : u32 = 2019 ;
19
+ pub const VERSION_UPDATE : u32 = 5 ;
19
20
}
20
21
21
- #[ cfg( target_os = "macos" ) ]
22
+ #[ cfg( all ( target_os = "macos" , target_arch = "x86_64" ) ) ]
22
23
mod mkl {
23
- pub const ARCHIVE_NAME : & ' static str = "mkl_osx" ;
24
- pub const ARCHIVE : & ' static str = "mkl_osx.tar.xz" ;
24
+ pub const ARCHIVE : & ' static str = "mkl_macos64" ;
25
25
pub const EXT : & ' static str = "dylib" ;
26
26
pub const PREFIX : & ' static str = "lib" ;
27
+ pub const VERSION_YEAR : u32 = 2019 ;
28
+ pub const VERSION_UPDATE : u32 = 3 ;
27
29
}
28
30
29
- #[ cfg( target_os = "windows" ) ]
31
+ #[ cfg( all ( target_os = "windows" , target_arch = "x86_64" ) ) ]
30
32
mod mkl {
31
- pub const ARCHIVE_NAME : & ' static str = "mkl_windows64" ;
32
- pub const ARCHIVE : & ' static str = "mkl_windows64.tar.xz" ;
33
+ pub const ARCHIVE : & ' static str = "mkl_windows64" ;
33
34
pub const EXT : & ' static str = "lib" ;
34
35
pub const PREFIX : & ' static str = "" ;
36
+ pub const VERSION_YEAR : u32 = 2019 ;
37
+ pub const VERSION_UPDATE : u32 = 5 ;
38
+ }
39
+
40
+ pub fn archive_filename ( ) -> String {
41
+ format ! (
42
+ "{}_{}_{}.tar.zst" ,
43
+ mkl:: ARCHIVE ,
44
+ mkl:: VERSION_YEAR ,
45
+ mkl:: VERSION_UPDATE
46
+ )
35
47
}
36
48
37
49
pub fn home_library_path ( ) -> PathBuf {
@@ -65,13 +77,14 @@ pub fn download(out_dir: &Path) -> Fallible<()> {
65
77
bail ! ( "Not a directory: {}" , out_dir. display( ) ) ;
66
78
}
67
79
68
- let archive = out_dir. join ( mkl :: ARCHIVE ) ;
80
+ let archive = out_dir. join ( archive_filename ( ) ) ;
69
81
if !archive. exists ( ) {
70
- info ! ( "Download archive from AWS S3: {}/{}" , S3_ADDR , mkl:: ARCHIVE ) ;
82
+ let url = format ! ( "{}/{}" , S3_ADDR , archive_filename( ) ) ;
83
+ info ! ( "Download archive from AWS S3: {}" , url) ;
71
84
let f = fs:: File :: create ( & archive) ?;
72
85
let mut buf = io:: BufWriter :: new ( f) ;
73
86
let mut easy = Easy :: new ( ) ;
74
- easy. url ( & format ! ( "{}/{}" , S3_ADDR , mkl :: ARCHIVE ) ) ?;
87
+ easy. url ( & url ) ?;
75
88
easy. write_function ( move |data| Ok ( buf. write ( data) . unwrap ( ) ) ) ?;
76
89
easy. perform ( ) ?;
77
90
assert ! ( archive. exists( ) ) ;
@@ -82,7 +95,7 @@ pub fn download(out_dir: &Path) -> Fallible<()> {
82
95
let core = out_dir. join ( format ! ( "{}mkl_core.{}" , mkl:: PREFIX , mkl:: EXT ) ) ;
83
96
if !core. exists ( ) {
84
97
let f = fs:: File :: open ( & archive) ?;
85
- let de = xz2 :: read:: XzDecoder :: new ( f) ;
98
+ let de = zstd :: stream :: read:: Decoder :: new ( f) ? ;
86
99
let mut arc = tar:: Archive :: new ( de) ;
87
100
arc. unpack ( & out_dir) ?;
88
101
assert ! ( core. exists( ) ) ;
@@ -126,7 +139,7 @@ pub fn package(mkl_path: &Path) -> Fallible<PathBuf> {
126
139
}
127
140
let ( year, update) = get_mkl_version ( & mkl_path. join ( "include/mkl_version.h" ) ) ?;
128
141
info ! ( "Intel MKL version: {}.{}" , year, update) ;
129
- let out = PathBuf :: from ( format ! ( "{}_{}_{}.tar.zst" , mkl :: ARCHIVE_NAME , year , update ) ) ;
142
+ let out = PathBuf :: from ( archive_filename ( ) ) ;
130
143
info ! ( "Create archive: {}" , out. display( ) ) ;
131
144
132
145
let shared_libs: Vec < _ > = glob (
0 commit comments