-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
44 lines (37 loc) · 976 Bytes
/
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
// build.rs
use std::{
env,
error,
time::{SystemTime, UNIX_EPOCH}
};
fn main() -> Result<(), Box<dyn error::Error>>
{
let current_time = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs();
println!("cargo:rerun-if-changed={}", current_time);
if let Ok(rustflags) = env::var("RUSTFLAGS") {
unsafe {
env::set_var(
"RUSTFLAGS",
format!(
"{} -C target-cpu=generic -C target-feature=+crt-static -C \
relocation-model=pic",
rustflags
)
);
}
}
else {
unsafe {
env::set_var(
"RUSTFLAGS",
"-C target-cpu=generic -C target-feature=+crt-static relocation-model=pic"
);
}
}
println!("cargo:rustc-link-arg=-s");
println!("cargo:rustc-link-arg=-Wl,--gc-sections");
Ok(())
}