-
Notifications
You must be signed in to change notification settings - Fork 139
/
build.rs
58 lines (51 loc) · 1.8 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
extern crate cc;
use std::env;
fn main() {
let target = env::var("TARGET").unwrap();
if target.starts_with("thumb") && env::var_os("CARGO_FEATURE_INLINE_ASM").is_none() {
// NOTE we need to place each routine in a separate assembly file or the linker won't be
// able to discard the unused routines
let mut build = cc::Build::new();
build
.file("asm/basepri_r.s")
.file("asm/bkpt.s")
.file("asm/control.s")
.file("asm/cpsid.s")
.file("asm/cpsie.s")
.file("asm/dmb.s")
.file("asm/dsb.s")
.file("asm/faultmask.s")
.file("asm/isb.s")
.file("asm/msp_r.s")
.file("asm/msp_w.s")
.file("asm/nop.s")
.file("asm/primask.s")
.file("asm/psp_r.s")
.file("asm/psp_w.s")
.file("asm/sev.s")
.file("asm/wfe.s")
.file("asm/wfi.s");
if env::var_os("CARGO_FEATURE_CM7_R0P1").is_some() {
build.file("asm/basepri_max-cm7-r0p1.s");
build.file("asm/basepri_w-cm7-r0p1.s");
} else {
build.file("asm/basepri_max.s");
build.file("asm/basepri_w.s");
}
build.compile("asm");
}
if target.starts_with("thumbv6m-") {
println!("cargo:rustc-cfg=cortex_m");
println!("cargo:rustc-cfg=armv6m");
} else if target.starts_with("thumbv7m-") {
println!("cargo:rustc-cfg=cortex_m");
println!("cargo:rustc-cfg=armv7m");
} else if target.starts_with("thumbv7em-") {
println!("cargo:rustc-cfg=cortex_m");
println!("cargo:rustc-cfg=armv7m");
//println!("cargo:rustc-cfg=armv7em");
}
if target.ends_with("-eabihf") {
println!("cargo:rustc-cfg=has_fpu");
}
}