@@ -590,58 +590,40 @@ fn copy_pregenerated_bindings(target: &str) {
590590 target,
591591 ) ;
592592
593- fs:: copy (
594- crate_path. join ( "sdl_bindings.rs" ) ,
595- out_path. join ( "sdl_bindings.rs" ) ,
596- )
597- . expect ( "Couldn't find pregenerated bindings!" ) ;
598-
599- if cfg ! ( feature = "image" ) {
600- fs:: copy (
601- crate_path. join ( "sdl_image_bindings.rs" ) ,
602- out_path. join ( "sdl_image_bindings.rs" ) ,
603- )
604- . expect ( "Couldn't find pregenerated SDL_image bindings!" ) ;
605- }
606- if cfg ! ( feature = "ttf" ) {
607- fs:: copy (
608- crate_path. join ( "sdl_ttf_bindings.rs" ) ,
609- out_path. join ( "sdl_ttf_bindings.rs" ) ,
610- )
611- . expect ( "Couldn't find pregenerated SDL_ttf bindings!" ) ;
612- }
613- if cfg ! ( feature = "mixer" ) {
614- fs:: copy (
615- crate_path. join ( "sdl_mixer_bindings.rs" ) ,
616- out_path. join ( "sdl_mixer_bindings.rs" ) ,
617- )
618- . expect ( "Couldn't find pregenerated SDL_mixer bindings!" ) ;
619- }
620-
621- if cfg ! ( feature = "gfx" ) {
622- fs:: copy (
623- crate_path. join ( "sdl_gfx_framerate_bindings.rs" ) ,
624- out_path. join ( "sdl_gfx_framerate_bindings.rs" ) ,
625- )
626- . expect ( "Couldn't find pregenerated SDL_gfx framerate bindings!" ) ;
627-
628- fs:: copy (
629- crate_path. join ( "sdl_gfx_primitives_bindings.rs" ) ,
630- out_path. join ( "sdl_gfx_primitives_bindings.rs" ) ,
631- )
632- . expect ( "Couldn't find pregenerated SDL_gfx primitives bindings!" ) ;
633-
634- fs:: copy (
635- crate_path. join ( "sdl_gfx_imagefilter_bindings.rs" ) ,
636- out_path. join ( "sdl_gfx_imagefilter_bindings.rs" ) ,
637- )
638- . expect ( "Couldn't find pregenerated SDL_gfx imagefilter bindings!" ) ;
639-
640- fs:: copy (
641- crate_path. join ( "sdl_gfx_rotozoom_bindings.rs" ) ,
642- out_path. join ( "sdl_gfx_rotozoom_bindings.rs" ) ,
643- )
644- . expect ( "Couldn't find pregenerated SDL_gfx rotozoom bindings!" ) ;
593+ #[ allow( unused_mut) ]
594+ let mut paths = vec ! [ "sdl_bindings.rs" ] ;
595+
596+ #[ cfg( feature = "image" ) ]
597+ paths. push ( "sdl_image_bindings.rs" ) ;
598+
599+ #[ cfg( feature = "ttf" ) ]
600+ paths. push ( "sdl_ttf_bindings.rs" ) ;
601+
602+ #[ cfg( feature = "mixer" ) ]
603+ paths. push ( "sdl_mixer_bindings.rs" ) ;
604+
605+ #[ cfg( feature = "gfx" ) ]
606+ paths. extend ( [
607+ "sdl_gfx_framerate_bindings.rs" ,
608+ "sdl_gfx_primitives_bindings.rs" ,
609+ "sdl_gfx_imagefilter_bindings.rs" ,
610+ "sdl_gfx_rotozoom_bindings.rs" ,
611+ ] ) ;
612+
613+ for path in paths {
614+ let from = crate_path. join ( path) ;
615+ let to = out_path. join ( path) ;
616+ match fs:: copy ( & from, & to) {
617+ Ok ( _) => { }
618+ Err ( err) => {
619+ panic ! (
620+ "unable to copy {} to {}: {err}\n \n \n \
621+ Could not copy pregenerated bindings \" {path}\" for target \" {target}\" : {err}.\n \
622+ If pregenerated bindings do not exist for your target, they can be generated by enabling the \" bindgen\" feature.\n \n ",
623+ from. display( ) , to. display( ) ,
624+ ) ;
625+ }
626+ }
645627 }
646628}
647629
0 commit comments