stm32: Use build.rs to generate a more coarse feature

This commit is contained in:
Thales Fragoso
2021-07-31 02:20:37 -03:00
parent 16d5294817
commit 21e3acaa00
4 changed files with 17 additions and 255 deletions

View File

@ -9,7 +9,7 @@ fn main() {
.expect("No stm32xx Cargo feature enabled")
.strip_prefix("CARGO_FEATURE_")
.unwrap()
.to_ascii_uppercase();
.to_ascii_lowercase();
let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
let out_file = out_dir.join("generated.rs").to_string_lossy().to_string();
@ -30,6 +30,15 @@ fn main() {
};
);
let mut chip_and_core = chip_name.split('_');
let chip = chip_and_core.next().expect("Unexpected stm32xx feature");
if let Some(core) = chip_and_core.next() {
println!("cargo:rustc-cfg={}_{}", &chip[..(chip.len() - 2)], core);
} else {
println!("cargo:rustc-cfg={}", &chip[..(chip.len() - 2)]);
}
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=gen.py");
}