forked from ulagbulag/dlib-face-recognition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
83 lines (69 loc) · 2.03 KB
/
build.rs
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#[allow(dead_code)]
fn system_is_debian() -> bool {
cfg!(target_os = "linux")
&& ::sys_info::linux_os_release()
.map(|os| os.id_like.map(|id| id == "debian").unwrap_or_default())
.unwrap_or_default()
}
#[allow(dead_code)]
enum BlasLibrary {
#[cfg(feature = "openblas")]
Openblas,
Blas,
Cblas,
}
impl BlasLibrary {
fn as_str(&self) -> &'static str {
match self {
#[cfg(feature = "openblas")]
BlasLibrary::Openblas => "openblas",
BlasLibrary::Cblas => "cblas",
BlasLibrary::Blas => "blas",
}
}
}
fn set_blas_library() -> BlasLibrary {
#[cfg(feature = "openblas")] {
BlasLibrary::Openblas
}
#[cfg(not(feature = "openblas"))] {
if system_is_debian() {
BlasLibrary::Blas
} else {
BlasLibrary::Cblas
}
}
}
fn main() {
let mut config = cpp_build::Config::new();
println!("cargo:rerun-if-changed=./files");
let blas_library = set_blas_library().as_str();
#[cfg(target_family = "windows")]
{
let root_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let windows = std::path::PathBuf::from(root_dir)
.join("external-libs")
.join("windows");
#[cfg(target_env = "gnu")]
{
config.flag("-Os");
config.flag("-Wa,-mbig-obj");
}
println!("cargo:rustc-flags=-L {}", windows.display());
println!("cargo:rustc-link-lib={blas_library}");
println!("cargo:rustc-link-lib=lapack");
println!("cargo:rustc-link-lib=static=dlib");
}
#[cfg(not(target_family = "windows"))]
{
println!("cargo:rustc-link-lib={blas_library}");
println!("cargo:rustc-link-lib=dlib");
println!("cargo:rustc-link-lib=lapack");
}
if let Ok(paths) = std::env::var("DEP_DLIB_INCLUDE") {
for path in std::env::split_paths(&paths) {
config.include(path);
}
}
config.flag("-std=c++14").build("src/lib.rs");
}