@@ -133,6 +133,7 @@ const BINDGEN_FILE_GENERATORS_TUPLES: &[(&str, GenerateFn)] = &[
133133 ( "wdf.rs" , generate_wdf) ,
134134 ( "hid.rs" , generate_hid) ,
135135 ( "spb.rs" , generate_spb) ,
136+ ( "storage.rs" , generate_storage) ,
136137] ;
137138
138139fn initialize_tracing ( ) -> Result < ( ) , ParseError > {
@@ -199,6 +200,8 @@ fn generate_constants(out_path: &Path, config: &Config) -> Result<(), ConfigErro
199200 ApiSubset :: Hid ,
200201 #[ cfg( feature = "spb" ) ]
201202 ApiSubset :: Spb ,
203+ #[ cfg( feature = "storage" ) ]
204+ ApiSubset :: Storage ,
202205 ] ) ;
203206 trace ! ( header_contents = ?header_contents) ;
204207
@@ -223,6 +226,8 @@ fn generate_types(out_path: &Path, config: &Config) -> Result<(), ConfigError> {
223226 ApiSubset :: Hid ,
224227 #[ cfg( feature = "spb" ) ]
225228 ApiSubset :: Spb ,
229+ #[ cfg( feature = "storage" ) ]
230+ ApiSubset :: Storage ,
226231 ] ) ;
227232 trace ! ( header_contents = ?header_contents) ;
228233
@@ -358,6 +363,45 @@ fn generate_spb(out_path: &Path, config: &Config) -> Result<(), ConfigError> {
358363 }
359364}
360365
366+ fn generate_storage ( out_path : & Path , config : & Config ) -> Result < ( ) , ConfigError > {
367+ cfg_if:: cfg_if! {
368+ if #[ cfg( feature = "storage" ) ] {
369+ info!( "Generating bindings to WDK: storage.rs" ) ;
370+
371+ let header_contents = config. bindgen_header_contents( [
372+ ApiSubset :: Base ,
373+ ApiSubset :: Wdf ,
374+ ApiSubset :: Storage ,
375+ ] ) ;
376+ trace!( header_contents = ?header_contents) ;
377+
378+ let bindgen_builder = {
379+ let mut builder = bindgen:: Builder :: wdk_default( config) ?
380+ . with_codegen_config( ( CodegenConfig :: TYPES | CodegenConfig :: VARS ) . complement( ) )
381+ . header_contents( "storage-input.h" , & header_contents) ;
382+
383+ // Only allowlist files in the storage-specific files to avoid
384+ // duplicate definitions
385+ for header_file in config. headers( ApiSubset :: Storage ) {
386+ builder = builder. allowlist_file( format!( "(?i).*{header_file}.*" ) ) ;
387+ }
388+ builder
389+ } ;
390+ trace!( bindgen_builder = ?bindgen_builder) ;
391+
392+ Ok ( bindgen_builder
393+ . generate( )
394+ . expect( "Bindings should succeed to generate" )
395+ . write_to_file( out_path. join( "storage.rs" ) ) ?)
396+ } else {
397+ let _ = ( out_path, config) ; // Silence unused variable warnings when storage feature is not enabled
398+
399+ info!( "Skipping storage.rs generation since storage feature is not enabled" ) ;
400+ Ok ( ( ) )
401+ }
402+ }
403+ }
404+
361405/// Generates a `wdf_function_count.rs` file in `OUT_DIR` which contains the
362406/// definition of the function `get_wdf_function_count()`. This is required to
363407/// be generated here since the size of the table is derived from either a
0 commit comments