File tree Expand file tree Collapse file tree 2 files changed +33
-9
lines changed Expand file tree Collapse file tree 2 files changed +33
-9
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,16 @@ use structopt::StructOpt;
5
5
/// CLI tool for intel-mkl crate
6
6
#[ derive( Debug , StructOpt ) ]
7
7
enum Opt {
8
- Download { path : Option < PathBuf > } ,
8
+ /// Download Intel-MKL library
9
+ Download {
10
+ /// Install destination. Default is `$XDG_DATA_HOME/intel-mkl-tool`
11
+ path : Option < PathBuf > ,
12
+ } ,
13
+ /// Seek Intel-MKL library
14
+ ///
15
+ /// 1. pkg-config
16
+ /// 2. `$XDG_DATA_HOME/intel-mkl-tool`
17
+ /// will be sought.
9
18
Seek { } ,
10
19
}
11
20
@@ -20,14 +29,13 @@ fn main() -> Fallible<()> {
20
29
let path = if let Some ( path) = path {
21
30
path
22
31
} else {
23
- let data_dir = dirs:: data_local_dir ( ) . unwrap ( ) ;
24
- data_dir. join ( "intel-mkl-tool" )
32
+ intel_mkl_tool:: home_library_path ( )
25
33
} ;
26
34
intel_mkl_tool:: download ( & path) ?;
27
35
}
28
36
Opt :: Seek { } => {
29
- let paths = intel_mkl_tool:: seek_pkg_config ( ) ?;
30
- println ! ( "{:? }" , paths) ;
37
+ let paths = intel_mkl_tool:: seek ( ) . ok_or ( err_msg ( "MKL not found" ) ) ?;
38
+ println ! ( "{}" , paths. display ( ) ) ;
31
39
}
32
40
}
33
41
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -34,9 +34,25 @@ pub fn home_library_path() -> PathBuf {
34
34
dirs:: data_local_dir ( ) . unwrap ( ) . join ( "intel-mkl-tool" )
35
35
}
36
36
37
- /// Seek MKL library from pkg-config
38
- pub fn seek_pkg_config ( ) -> Fallible < pkg_config:: Library > {
39
- Ok ( pkg_config:: probe_library ( "mkl-dynamic-lp64-iomp" ) ?)
37
+ /// Seek MKL library from
38
+ ///
39
+ /// 1. pkg-config
40
+ /// 2. `$XDG_DATA_HOME/intel-mkl-tool`
41
+ ///
42
+ /// returns `None` if not found.
43
+ ///
44
+ pub fn seek ( ) -> Option < PathBuf > {
45
+ if let Ok ( lib) = pkg_config:: probe_library ( "mkl-dynamic-lp64-iomp" ) {
46
+ if lib. libs . len ( ) > 1 {
47
+ warn ! ( "Found {} MKL libraries. Use first found." , lib. libs. len( ) )
48
+ }
49
+ return Some ( PathBuf :: from ( lib. libs [ 0 ] . clone ( ) ) ) ;
50
+ }
51
+ let home_lib = home_library_path ( ) ;
52
+ if home_lib. is_dir ( ) {
53
+ return Some ( home_lib) ;
54
+ }
55
+ None
40
56
}
41
57
42
58
pub fn download ( out_dir : & Path ) -> Fallible < ( ) > {
@@ -59,7 +75,7 @@ pub fn download(out_dir: &Path) -> Fallible<()> {
59
75
easy. perform ( ) ?;
60
76
assert ! ( archive. exists( ) ) ;
61
77
} else {
62
- info ! ( "Use existing archive : {}" , archive. display( ) ) ;
78
+ info ! ( "Archive already exists : {}" , archive. display( ) ) ;
63
79
}
64
80
65
81
let core = out_dir. join ( format ! ( "{}mkl_core.{}" , mkl:: PREFIX , mkl:: EXT ) ) ;
You can’t perform that action at this time.
0 commit comments