This repository was archived by the owner on Feb 1, 2020. It is now read-only.
forked from mikkyang/rust-blas
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.rs
More file actions
41 lines (35 loc) · 1.22 KB
/
Copy pathbuild.rs
File metadata and controls
41 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
extern crate pkg_config;
use std::env;
fn main() {
let variant = env::var("BLAS_VARIANT").unwrap_or_else(|_| {
if let Ok("x86_64-apple-darwin") = std::env::var("TARGET").as_ref().map(|s| &s[..]) {
"BLAS".to_string()
} else {
"openblas".to_string()
}
});
let lib_dir = env::var("BLAS_LIB_DIR").ok();
let include_dir = env::var("BLAS_INCLUDE_DIR").ok();
if lib_dir.is_none() && include_dir.is_none() {
if let Ok(info) = pkg_config::find_library(variant.as_str()) {
// avoid empty include paths as they are not supported by GCC
if info.include_paths.len() > 0 {
let paths = env::join_paths(info.include_paths).unwrap();
println!("cargo:include={}", paths.to_str().unwrap());
}
return;
}
}
let mode = if env::var_os("BLAS_STATIC").is_some() {
"static"
} else {
"dylib"
};
if let Some(lib_dir) = lib_dir {
println!("cargo:rustc-link-search=native={}", lib_dir);
}
println!("cargo:rustc-link-lib={}={}", mode, variant);
if let Some(include_dir) = include_dir.clone() {
println!("cargo:include={}", include_dir);
}
}