forked from knurling-rs/defmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
36 lines (34 loc) · 1.04 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
use std::env;
fn main() {
// allow all possible configs
let possible_configs = [
"cortex_m",
"armv6m",
"armv7m",
"armv7em",
"armv8m",
"armv8m_base",
"armv8m_main",
];
for config in possible_configs {
println!("cargo:rustc-check-cfg=cfg({config})");
}
// enable configs for target
let target = env::var("TARGET").unwrap();
let enabled_configs = if target.starts_with("thumbv6m-") {
["cortex_m", "armv6m"].as_slice()
} else if target.starts_with("thumbv7m-") {
["cortex_m", "armv7m"].as_slice()
} else if target.starts_with("thumbv7em-") {
["cortex_m", "armv7m", "armv7em"].as_slice()
} else if target.starts_with("thumbv8m.base") {
["cortex_m", "armv8m", "armv8m_base"].as_slice()
} else if target.starts_with("thumbv8m.main") {
["cortex_m", "armv8m", "armv8m_main"].as_slice()
} else {
[].as_slice()
};
for config in enabled_configs {
println!("cargo:rustc-cfg={config}");
}
}