@@ -906,28 +906,51 @@ impl AppSettings for RustAppSettings {
906
906
}
907
907
}
908
908
909
- let mut bins_path = tauri_dir ( ) . to_path_buf ( ) ;
910
- bins_path. push ( "src/bin" ) ;
911
- if let Ok ( fs_bins) = std:: fs:: read_dir ( bins_path) {
912
- for entry in fs_bins {
913
- let path = entry?. path ( ) ;
914
- if let Some ( name) = path. file_stem ( ) {
915
- // see https://github.com/tauri-apps/tauri/pull/10977#discussion_r1759742414
916
- let bin_exists = binaries. iter ( ) . any ( |bin| {
917
- bin. name ( ) == name || path. ends_with ( bin. src_path ( ) . unwrap_or ( & "" . to_string ( ) ) )
918
- } ) ;
919
- if !bin_exists {
920
- binaries. push ( BundleBinary :: new (
921
- format ! ( "{}{}" , name. to_string_lossy( ) , ext) ,
922
- false ,
923
- ) )
924
- }
925
- }
909
+ let mut binaries_paths = std:: fs:: read_dir ( tauri_dir ( ) . join ( "src/bin" ) )
910
+ . map ( |dir| {
911
+ dir
912
+ . into_iter ( )
913
+ . flatten ( )
914
+ . map ( |entry| {
915
+ (
916
+ entry
917
+ . path ( )
918
+ . file_stem ( )
919
+ . unwrap_or_default ( )
920
+ . to_string_lossy ( )
921
+ . into_owned ( ) ,
922
+ entry. path ( ) ,
923
+ )
924
+ } )
925
+ . collect :: < Vec < _ > > ( )
926
+ } )
927
+ . unwrap_or_default ( ) ;
928
+
929
+ if !binaries_paths
930
+ . iter ( )
931
+ . any ( |( _name, path) | path == Path :: new ( "src/main.rs" ) )
932
+ && tauri_dir ( ) . join ( "src/main.rs" ) . exists ( )
933
+ {
934
+ binaries_paths. push ( (
935
+ self . cargo_package_settings . name . clone ( ) ,
936
+ tauri_dir ( ) . join ( "src/main.rs" ) ,
937
+ ) ) ;
938
+ }
939
+
940
+ for ( name, path) in binaries_paths {
941
+ // see https://github.com/tauri-apps/tauri/pull/10977#discussion_r1759742414
942
+ let bin_exists = binaries
943
+ . iter ( )
944
+ . any ( |bin| bin. name ( ) == name || path. ends_with ( bin. src_path ( ) . unwrap_or ( & "" . to_string ( ) ) ) ) ;
945
+ if !bin_exists {
946
+ binaries. push ( BundleBinary :: new ( format ! ( "{name}{ext}" ) , false ) )
926
947
}
927
948
}
928
949
929
950
if let Some ( default_run) = self . package_settings . default_run . as_ref ( ) {
930
- if !binaries. iter_mut ( ) . any ( |bin| bin. name ( ) == default_run) {
951
+ if let Some ( binary) = binaries. iter_mut ( ) . find ( |bin| bin. name ( ) == default_run) {
952
+ binary. set_main ( true ) ;
953
+ } else {
931
954
binaries. push ( BundleBinary :: new ( format ! ( "{}{}" , default_run, ext) , true ) ) ;
932
955
}
933
956
}
0 commit comments