File tree 2 files changed +35
-21
lines changed
2 files changed +35
-21
lines changed Original file line number Diff line number Diff line change 24
24
25
25
use anyhow:: { bail, Result } ;
26
26
use intel_mkl_tool:: * ;
27
- use std:: { str:: FromStr } ;
27
+ use std:: str:: FromStr ;
28
28
29
29
#[ cfg( feature = "mkl-static-lp64-iomp" ) ]
30
30
const MKL_CONFIG : & str = "mkl-static-lp64-iomp" ;
@@ -45,26 +45,9 @@ const MKL_CONFIG: &str = "mkl-dynamic-ilp64-seq";
45
45
46
46
fn main ( ) -> Result < ( ) > {
47
47
let cfg = Config :: from_str ( MKL_CONFIG ) . unwrap ( ) ;
48
-
49
- // already exists on system
50
- if let Ok ( entry) = Entry :: from_config ( cfg) {
51
- entry. print_cargo_metadata ( ) ;
48
+ if let Ok ( lib) = Library :: new ( cfg) {
49
+ lib. print_cargo_metadata ( ) ?;
52
50
return Ok ( ( ) ) ;
53
51
}
54
-
55
- // download if not found
56
- #[ cfg( feature = "download" ) ]
57
- {
58
- let path = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
59
- println ! (
60
- r#"cargo:warning="Download Intel MKL archive into {}""# ,
61
- path. display( )
62
- ) ;
63
- cfg. download ( path) ?;
64
- let entry = Entry :: from_config ( cfg) . unwrap ( ) ; // must found
65
- entry. print_cargo_metadata ( ) ;
66
- return Ok ( ( ) ) ;
67
- }
68
-
69
- bail ! ( "No MKL found, and download flag is off." ) ;
52
+ bail ! ( "No MKL found" ) ;
70
53
}
Original file line number Diff line number Diff line change @@ -235,6 +235,37 @@ impl Library {
235
235
_ => bail ! ( "Invalid mkl_version.h" ) ,
236
236
}
237
237
}
238
+
239
+ /// Print `cargo:rustc-link-*` metadata to stdout
240
+ pub fn print_cargo_metadata ( & self ) -> Result < ( ) > {
241
+ match self {
242
+ Library :: PkgConfig { config, .. } => {
243
+ pkg_config:: probe_library ( & config. to_string ( ) ) ?;
244
+ }
245
+ Library :: Directory {
246
+ config,
247
+ library_dir,
248
+ iomp5_dir,
249
+ ..
250
+ } => {
251
+ println ! ( "cargo:rustc-link-search={}" , library_dir. display( ) ) ;
252
+ if let Some ( iomp5_dir) = iomp5_dir {
253
+ println ! ( "cargo:rustc-link-search={}" , iomp5_dir. display( ) ) ;
254
+ }
255
+ for lib in config. libs ( ) {
256
+ match config. link {
257
+ LinkType :: Static => {
258
+ println ! ( "cargo:rustc-link-lib=static={}" , lib) ;
259
+ }
260
+ LinkType :: Dynamic => {
261
+ println ! ( "cargo:rustc-link-lib=dylib={}" , lib) ;
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }
267
+ Ok ( ( ) )
268
+ }
238
269
}
239
270
240
271
#[ derive( Debug , Deref ) ]
You can’t perform that action at this time.
0 commit comments