2021-09-05 20:03:52 +02:00
|
|
|
use gen_features::{
|
2022-06-12 22:15:44 +02:00
|
|
|
chip_names_and_cores, embassy_stm32_needed_data, generate_cargo_toml_file, stm32_metapac_needed_data,
|
2021-09-05 20:03:52 +02:00
|
|
|
};
|
2021-08-27 11:09:27 +02:00
|
|
|
|
|
|
|
fn main() {
|
2021-09-05 20:03:52 +02:00
|
|
|
let names_and_cores = chip_names_and_cores();
|
|
|
|
update_cargo_file(
|
|
|
|
"../embassy-stm32/Cargo.toml",
|
|
|
|
&embassy_stm32_needed_data(&names_and_cores),
|
|
|
|
);
|
|
|
|
update_cargo_file(
|
|
|
|
"../stm32-metapac/Cargo.toml",
|
|
|
|
&stm32_metapac_needed_data(&names_and_cores),
|
|
|
|
);
|
2021-08-27 11:09:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Update a Cargo.toml file
|
|
|
|
///
|
|
|
|
/// Update the content between "# BEGIN GENERATED FEATURES" and "# END GENERATED FEATURES"
|
|
|
|
/// with the given content
|
2021-09-11 20:04:57 +02:00
|
|
|
fn update_cargo_file(path: &str, new_contents: &str) {
|
2021-08-27 11:09:27 +02:00
|
|
|
let previous_text = std::fs::read_to_string(path).unwrap();
|
|
|
|
let new_text = generate_cargo_toml_file(&previous_text, new_contents);
|
|
|
|
std::fs::write(path, new_text).unwrap();
|
|
|
|
}
|