Skip to content

Commit 7f54b8d

Browse files
committed
Split seek function
1 parent b5f2200 commit 7f54b8d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

intel-mkl-tool/src/bin/intel-mkl-tool.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,15 @@ fn main() -> Fallible<()> {
3434
intel_mkl_tool::download(&path)?;
3535
}
3636
Opt::Seek {} => {
37-
let paths = intel_mkl_tool::seek().ok_or(err_msg("MKL not found"))?;
38-
println!("{}", paths.display());
37+
if let Some(path) = intel_mkl_tool::seek_pkg_config() {
38+
println!("{}", path.display());
39+
return Ok(());
40+
}
41+
if let Some(path) = intel_mkl_tool::seek_home() {
42+
println!("{}", path.display());
43+
return Ok(());
44+
}
45+
bail!("Intel-MKL not found.");
3946
}
4047
}
4148
Ok(())

intel-mkl-tool/src/lib.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,17 @@ pub fn home_library_path() -> PathBuf {
3434
dirs::data_local_dir().unwrap().join("intel-mkl-tool")
3535
}
3636

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> {
37+
pub fn seek_pkg_config() -> Option<PathBuf> {
4538
if let Ok(lib) = pkg_config::probe_library("mkl-dynamic-lp64-iomp") {
4639
if lib.libs.len() > 1 {
4740
warn!("Found {} MKL libraries. Use first found.", lib.libs.len())
4841
}
4942
return Some(PathBuf::from(lib.libs[0].clone()));
5043
}
44+
None
45+
}
46+
47+
pub fn seek_home() -> Option<PathBuf> {
5148
let home_lib = home_library_path();
5249
if home_lib.is_dir() {
5350
return Some(home_lib);

0 commit comments

Comments
 (0)