2021-05-25 02:17:24 +00:00
|
|
|
use std::env;
|
|
|
|
use std::path::PathBuf;
|
2021-06-07 03:10:11 +00:00
|
|
|
use stm32_metapac_gen::*;
|
2021-06-09 11:40:34 +00:00
|
|
|
|
2021-05-25 02:17:24 +00:00
|
|
|
fn main() {
|
2021-06-07 03:10:11 +00:00
|
|
|
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
|
|
|
let data_dir = PathBuf::from("../stm32-data/data");
|
2021-05-25 02:17:24 +00:00
|
|
|
|
|
|
|
println!("cwd: {:?}", env::current_dir());
|
|
|
|
|
|
|
|
let chip_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_uppercase();
|
|
|
|
|
2021-06-07 03:10:11 +00:00
|
|
|
gen(Options {
|
|
|
|
out_dir: out_dir.clone(),
|
|
|
|
data_dir: data_dir.clone(),
|
|
|
|
chips: vec![chip_name.clone()],
|
2021-06-09 16:48:32 +00:00
|
|
|
});
|
2021-06-09 11:40:34 +00:00
|
|
|
|
2021-06-07 03:10:11 +00:00
|
|
|
println!(
|
|
|
|
"cargo:rustc-link-search={}/src/chips/{}",
|
|
|
|
out_dir.display(),
|
|
|
|
chip_name.to_ascii_lowercase()
|
2021-05-25 02:17:24 +00:00
|
|
|
);
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
}
|