2021-06-07 05:10:11 +02:00
|
|
|
use std::env;
|
2021-11-23 23:49:06 +01:00
|
|
|
use std::path::PathBuf;
|
2021-06-07 05:10:11 +02:00
|
|
|
|
|
|
|
fn main() {
|
2021-11-23 23:49:06 +01:00
|
|
|
let crate_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
|
|
|
|
|
|
|
|
let chip_core_name = env::vars_os()
|
2021-06-07 05:10:11 +02:00
|
|
|
.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()
|
2021-11-23 23:49:06 +01:00
|
|
|
.to_ascii_lowercase()
|
|
|
|
.replace('_', "-");
|
2021-06-07 05:10:11 +02:00
|
|
|
|
2021-11-23 23:49:06 +01:00
|
|
|
println!(
|
|
|
|
"cargo:rustc-link-search={}/src/chips/{}",
|
|
|
|
crate_dir.display(),
|
|
|
|
chip_core_name,
|
|
|
|
);
|
2021-09-21 13:42:27 +02:00
|
|
|
|
2021-08-02 19:29:06 +02:00
|
|
|
#[cfg(feature = "memory-x")]
|
2021-11-23 23:49:06 +01:00
|
|
|
println!(
|
|
|
|
"cargo:rustc-link-search={}/src/chips/{}/memory_x/",
|
|
|
|
crate_dir.display(),
|
2022-02-26 02:01:59 +01:00
|
|
|
chip_core_name
|
|
|
|
);
|
|
|
|
println!(
|
|
|
|
"cargo:rustc-env=STM32_METAPAC_PAC_PATH=chips/{}/pac.rs",
|
|
|
|
chip_core_name
|
|
|
|
);
|
|
|
|
println!(
|
|
|
|
"cargo:rustc-env=STM32_METAPAC_METADATA_PATH=chips/{}/metadata.rs",
|
|
|
|
chip_core_name
|
2021-11-23 23:49:06 +01:00
|
|
|
);
|
2022-03-15 08:20:19 +01:00
|
|
|
println!(
|
|
|
|
"cargo:rustc-env=STM32_METAPAC_COMMON_PATH={}/src/common.rs",
|
|
|
|
crate_dir.display(),
|
|
|
|
);
|
2021-06-07 05:10:11 +02:00
|
|
|
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
}
|