File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -13,5 +13,5 @@ include!(env!("MSPM0_METAPAC_PAC_PATH"));
1313pub mod metadata {
1414 include ! ( "metadata.rs" ) ;
1515 include ! ( env!( "MSPM0_METAPAC_METADATA_PATH" ) ) ;
16- // TODO: all_chips
16+ include ! ( " all_chips.rs" ) ;
1717}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ use std::{
99
1010use anyhow:: Context ;
1111use mspm0_data_types:: { Chip , Package } ;
12+ use quote:: quote;
1213
1314mod interrupt;
1415mod krate;
@@ -65,6 +66,8 @@ fn main() -> anyhow::Result<()> {
6566 }
6667 }
6768
69+ generate_all_chips ( & out_dir, chips. values ( ) ) ?;
70+
6871 krate:: generate ( & out_dir, & chips) ?;
6972
7073 Ok ( ( ) )
@@ -155,6 +158,28 @@ fn generate_chip_metadata(
155158 rustfmt ( path) ;
156159}
157160
161+ fn generate_all_chips < ' a > ( out_dir : & Path , chips : impl Iterator < Item = & ' a Chip > ) -> anyhow:: Result < ( ) > {
162+ let mut list = Vec :: new ( ) ;
163+
164+ for chip in chips {
165+ for package in chip. packages . iter ( ) {
166+ list. push ( & package. chip ) ;
167+ }
168+ }
169+
170+ let list = quote ! {
171+ pub const ALL_CHIPS : & [ & str ] = & [
172+ #( #list) , *
173+ ] ;
174+ } ;
175+
176+ let all_chips = out_dir. join ( "src/all_chips.rs" ) ;
177+ fs:: write ( & all_chips, list. to_string ( ) ) ?;
178+ rustfmt ( all_chips) ;
179+
180+ Ok ( ( ) )
181+ }
182+
158183fn rustfmt < P : AsRef < Path > > ( path : P ) {
159184 Command :: new ( "rustfmt" )
160185 . arg ( path. as_ref ( ) )
You can’t perform that action at this time.
0 commit comments