stm32: rename core features from _cmX to -cmX, cleanup gen.

This commit is contained in:
Dario Nieuwenhuis
2021-11-23 23:49:06 +01:00
parent 039621c56d
commit dfb6d407a1
9 changed files with 611 additions and 630 deletions

View File

@ -1,30 +1,30 @@
use std::env;
use std::path::PathBuf;
fn main() {
let chip_name = env::vars_os()
let crate_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
let chip_core_name = env::vars_os()
.map(|(a, _)| a.to_string_lossy().to_string())
.find(|x| x.starts_with("CARGO_FEATURE_STM32"))
.expect("No stm32xx Cargo feature enabled")
.strip_prefix("CARGO_FEATURE_")
.unwrap()
.to_ascii_lowercase();
.to_ascii_lowercase()
.replace('_', "-");
let mut s = chip_name.split('_');
let mut chip_name: String = s.next().unwrap().to_string();
if let Some(c) = s.next() {
if !c.starts_with("CM") {
chip_name.push('-');
} else {
chip_name.push('_');
}
chip_name.push_str(c);
}
println!(
"cargo:rustc-link-search={}/src/chips/{}",
crate_dir.display(),
chip_core_name,
);
#[cfg(feature = "memory-x")]
println!("cargo:rustc-link-search=src/chips/{}/memory_x/", _chip_name);
#[cfg(feature = "rt")]
println!("cargo:rustc-link-search=src/chips/{}", _chip_name);
println!(
"cargo:rustc-link-search={}/src/chips/{}/memory_x/",
crate_dir.display(),
chip_core_name,
);
println!("cargo:rerun-if-changed=build.rs");
}