-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathbuild.rs
36 lines (31 loc) · 1.33 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
fn main() {
embuild::espidf::sysenv::output();
println!("cargo::rustc-check-cfg=cfg(esp32)");
println!("cargo::rustc-check-cfg=cfg(esp32c3)");
println!("cargo::rustc-check-cfg=cfg(esp_idf_soc_esp_nimble_controller)");
println!("cargo::rustc-check-cfg=cfg(esp_idf_bt_nimble_ext_adv)");
println!("cargo::rustc-check-cfg=cfg(esp_idf_version_major, values(\"4\", \"5\"))");
println!("cargo::rustc-check-cfg=cfg(esp_idf_version_minor, values(\"2\", \"3\"))");
println!("cargo::rustc-check-cfg=cfg(esp_idf_version_patch, values(\"0\"))");
println!("cargo::rustc-check-cfg=cfg(esp_idf_version_patch, values(\"1\"))");
println!("cargo::rustc-check-cfg=cfg(esp_idf_version_patch, values(\"2\"))");
let esp_idf_info = embuild::espidf::sysenv::cfg_args().unwrap();
let version: Vec<usize> = ["major", "minor", "patch"]
.iter()
.filter_map(|ver_part| {
let search_string = format!("esp_idf_version_{}", ver_part);
esp_idf_info.args.iter().find_map(|arg| {
if arg.starts_with(&search_string) {
let version_str = arg.split_terminator('"').nth(1).unwrap();
Some(version_str.parse::<usize>().unwrap())
} else {
None
}
})
})
.collect();
println!("cargo::rustc-check-cfg=cfg(cpfd)");
if version > vec![5, 2, 0] {
println!("cargo::rustc-cfg=cpfd");
}
}