-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
152 lines (135 loc) · 4.69 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
use cmake::Config;
use std::env;
fn main() {
let custom_cc = env::var("CC");
let custom_cxx = env::var("CXX");
let conda_build = env::var("CONDA_BUILD");
let nopie_build = env::var("NOPIE");
let nobmi2_var = env::var("NO_BMI2");
let is_conda_build = match conda_build {
Ok(val) => match val.to_uppercase().as_str() {
"TRUE" | "1" | "YES" => true,
"FALSE" | "0" | "NO" => false,
_ => true,
},
Err(_e) => false,
};
println!("cargo:rerun-if-changed=cuttlefish/CMakeLists.txt");
println!("cargo:rerun-if-changed=piscem-cpp/CMakeLists.txt");
let mut cfg_piscem_cpp = Box::new(Config::new("piscem-cpp"));
let mut cfg_cf = Box::new(Config::new("cuttlefish"));
(*cfg_cf).define("INSTANCE_COUNT", "32");
if let Ok(cc_var) = custom_cc {
(*cfg_piscem_cpp).define("CMAKE_C_COMPILER", cc_var.clone());
(*cfg_cf).define("CMAKE_C_COMPILER", cc_var);
}
if let Ok(cxx_var) = custom_cxx {
(*cfg_piscem_cpp).define("CMAKE_CXX_COMPILER", cxx_var.clone());
(*cfg_cf).define("CMAKE_CXX_COMPILER", cxx_var);
}
if is_conda_build {
(*cfg_cf).define("CONDA_BUILD", "TRUE");
(*cfg_cf).define("CMAKE_OSX_DEPLOYMENT_TARGET", "10.15");
(*cfg_cf).define("MACOSX_SDK_VERSION", "10.15");
}
if let Ok(nobmi2) = nobmi2_var {
match nobmi2.as_str() {
"1" | "TRUE" | "true" | "True" => {
(*cfg_piscem_cpp).define("NO_BMI2", "TRUE");
}
_ => {}
}
}
(*cfg_piscem_cpp).always_configure(false);
(*cfg_cf).always_configure(false);
let dst_piscem_cpp = (*cfg_piscem_cpp).build();
let dst_cf = (*cfg_cf).build();
if let Ok(nopie) = nopie_build {
match nopie.as_str() {
"1" | "TRUE" | "true" | "True" => {
println!("cargo:rustc-link-arg=-no-pie");
}
_ => {}
}
}
println!(
"cargo:rustc-link-search=native={}",
dst_cf.join("lib").display()
);
println!(
"cargo:rustc-link-search=native={}",
dst_piscem_cpp.join("lib").display()
);
// For some reason, if we are using
// *some* linux distros (and on conda) and are
// building for the linux target;
// things get put in the lib64 directory
// rather than lib... So, we add that here
println!(
"cargo:rustc-link-search=native={}",
dst_cf.join("lib64").display()
);
println!(
"cargo:rustc-link-search=native={}",
dst_piscem_cpp.join("lib64").display()
);
let profile = std::env::var("PROFILE").unwrap();
match profile.as_str() {
"debug" => {
println!(
"cargo:rustc-link-search=native={}",
dst_piscem_cpp.join("Debug").join("lib64").display()
);
println!(
"cargo:rustc-link-search=native={}",
dst_piscem_cpp.join("Debug").join("lib").display()
);
}
"release" => {
println!(
"cargo:rustc-link-search=native={}",
dst_piscem_cpp.join("Release").join("lib64").display()
);
println!(
"cargo:rustc-link-search=native={}",
dst_piscem_cpp.join("Release").join("lib").display()
);
}
_ => (),
}
let profile = std::env::var("PROFILE").unwrap();
match profile.as_str() {
"debug" => {
println!(
"cargo:rustc-link-search=native={}",
dst_piscem_cpp.join("Debug").join("lib64").display()
);
println!(
"cargo:rustc-link-search=native={}",
dst_piscem_cpp.join("Debug").join("lib").display()
);
}
"release" => {
println!(
"cargo:rustc-link-search=native={}",
dst_piscem_cpp.join("Release").join("lib64").display()
);
println!(
"cargo:rustc-link-search=native={}",
dst_piscem_cpp.join("Release").join("lib").display()
);
}
_ => (),
}
println!("cargo:rustc-link-lib=static=kmc_core");
//println!("cargo:rustc-link-lib=static=pesc_static");
//println!("cargo:rustc-link-lib=static=build_static");
println!("cargo:rustc-link-lib=static=sshash_static");
println!("cargo:rustc-link-lib=static=zcf");
println!("cargo:rustc-link-lib=static=bz2");
println!("cargo:rustc-link-lib=static=radicl");
#[cfg(target_os = "linux")]
println!("cargo:rustc-link-lib=dylib=stdc++");
#[cfg(target_os = "macos")]
println!("cargo:rustc-link-lib=dylib=c++");
}