File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 1
- use std:: env;
1
+ use std:: { collections :: HashSet , env} ;
2
2
3
3
#[ derive( Clone , Copy , Debug ) ]
4
4
enum GetOneError {
@@ -175,16 +175,20 @@ const FEATURES: phf::Map<&str, &[&str]> = phf::phf_map! {
175
175
"pac_dfsdm2" => & [ "any_dfsdm" ] ,
176
176
} ;
177
177
178
- fn enable_feature ( fname : & str ) {
179
- if let Some ( v) = FEATURES . get ( fname) {
180
- for & f in v. iter ( ) {
181
- println ! ( "cargo:rustc-cfg={}" , f) ;
182
- enable_feature ( f) ;
178
+ fn enable_feature < ' a > ( fname : & ' a str , enabled : & mut HashSet < & ' a str > ) {
179
+ if !enabled. contains ( fname) {
180
+ if let Some ( v) = FEATURES . get ( fname) {
181
+ for & f in v. iter ( ) {
182
+ println ! ( "cargo:rustc-cfg={}" , f) ;
183
+ enabled. insert ( fname) ;
184
+ enable_feature ( f, enabled) ;
185
+ }
183
186
}
184
187
}
185
188
}
186
189
187
190
fn main ( ) {
191
+ let mut enabled = HashSet :: new ( ) ;
188
192
let chip_name = match env:: vars ( )
189
193
. map ( |( a, _) | a)
190
194
. filter ( |x| x. starts_with ( "CARGO_FEATURE_STM32F4" ) )
@@ -198,5 +202,5 @@ fn main() {
198
202
. unwrap ( )
199
203
. to_ascii_lowercase ( ) ;
200
204
201
- enable_feature ( & chip_name) ;
205
+ enable_feature ( & chip_name, & mut enabled ) ;
202
206
}
You can’t perform that action at this time.
0 commit comments