2021-08-19 22:16:27 +02:00
|
|
|
use std::env::args;
|
2021-06-07 05:10:11 +02:00
|
|
|
use std::path::PathBuf;
|
2022-06-12 22:15:44 +02:00
|
|
|
|
2021-06-07 05:10:11 +02:00
|
|
|
use stm32_metapac_gen::*;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let out_dir = PathBuf::from("out");
|
2021-07-13 05:47:10 +02:00
|
|
|
let data_dir = PathBuf::from("../stm32-data/data");
|
2021-06-07 05:10:11 +02:00
|
|
|
|
2021-08-19 22:16:27 +02:00
|
|
|
let args: Vec<String> = args().collect();
|
|
|
|
|
2021-11-29 02:10:06 +01:00
|
|
|
let mut chips = match &args[..] {
|
2021-08-19 22:16:27 +02:00
|
|
|
[_, chip] => {
|
|
|
|
vec![chip.clone()]
|
|
|
|
}
|
|
|
|
[_] => {
|
|
|
|
std::fs::read_dir(data_dir.join("chips"))
|
|
|
|
.unwrap()
|
|
|
|
.filter_map(|res| res.unwrap().file_name().to_str().map(|s| s.to_string()))
|
2022-02-07 02:10:12 +01:00
|
|
|
.filter(|s| s.ends_with(".json"))
|
2021-08-19 22:16:27 +02:00
|
|
|
.filter(|s| !s.starts_with("STM32GBK")) // cursed weird STM32G4
|
2022-02-07 02:10:12 +01:00
|
|
|
.map(|s| s.strip_suffix(".json").unwrap().to_string())
|
2021-08-19 22:16:27 +02:00
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
_ => panic!("usage: stm32-metapac-gen [chip?]"),
|
|
|
|
};
|
2021-06-07 05:10:11 +02:00
|
|
|
|
2021-11-29 02:10:06 +01:00
|
|
|
chips.sort();
|
|
|
|
|
2022-02-26 02:01:59 +01:00
|
|
|
let opts = Options {
|
2021-06-07 05:10:11 +02:00
|
|
|
out_dir,
|
|
|
|
data_dir,
|
|
|
|
chips,
|
2022-02-26 02:01:59 +01:00
|
|
|
};
|
|
|
|
Gen::new(opts).gen();
|
2021-06-07 05:10:11 +02:00
|
|
|
}
|