File tree 6 files changed +70
-0
lines changed
6 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " tauri-bundler " : patch
3
+ ---
4
+
5
+ Bundle Visual C++ redistributable files with VC142_CRT merge modules.
Original file line number Diff line number Diff line change @@ -100,6 +100,26 @@ impl Build {
100
100
101
101
if config_. tauri . bundle . active {
102
102
let bundler_settings = rust:: get_bundler_settings ( & config_, self . debug ) ?;
103
+ // move merge modules to the out dir so the bundler can load it
104
+ #[ cfg( windows) ]
105
+ {
106
+ let ( filename, vcruntime_msm) = if cfg ! ( target_arch = "x86" ) {
107
+ let _ =
108
+ std:: fs:: remove_file ( bundler_settings. out_dir . join ( "Microsoft_VC142_CRT_x64.msm" ) ) ;
109
+ (
110
+ "Microsoft_VC142_CRT_x86.msm" ,
111
+ include_bytes ! ( "./MergeModules/Microsoft_VC142_CRT_x86.msm" ) . to_vec ( ) ,
112
+ )
113
+ } else {
114
+ let _ =
115
+ std:: fs:: remove_file ( bundler_settings. out_dir . join ( "Microsoft_VC142_CRT_x86.msm" ) ) ;
116
+ (
117
+ "Microsoft_VC142_CRT_x64.msm" ,
118
+ include_bytes ! ( "./MergeModules/Microsoft_VC142_CRT_x64.msm" ) . to_vec ( ) ,
119
+ )
120
+ } ;
121
+ std:: fs:: write ( bundler_settings. out_dir . join ( filename) , vcruntime_msm) ?;
122
+ }
103
123
let mut settings_builder = SettingsBuilder :: new ( )
104
124
. package_settings ( bundler_settings. package_settings )
105
125
. bundle_settings ( bundler_settings. bundle_settings )
Original file line number Diff line number Diff line change 112
112
</Component >
113
113
</DirectoryRef >
114
114
115
+ {{#each merge_modules as |msm| ~}}
116
+ <DirectoryRef Id =" TARGETDIR" >
117
+ <Merge Id =" {{ msm.name }}" SourceFile =" {{ msm.path }}" DiskId =" 1" Language =" 0" />
118
+ </DirectoryRef >
119
+
120
+ <Feature Id =" {{ msm.name }}" Title =" {{ msm.name }}" AllowAdvertise =" no" Display =" hidden" Level =" 1" >
121
+ <MergeRef Id =" {{ msm.name }}" />
122
+ </Feature >
123
+ {{/each~}}
124
+
115
125
<Feature
116
126
Id =" MainProgram"
117
127
Title =" Application"
Original file line number Diff line number Diff line change @@ -482,6 +482,9 @@ pub fn build_wix_app_installer(
482
482
data. insert ( "resources" , to_json ( resources_wix_string) ) ;
483
483
data. insert ( "resource_file_ids" , to_json ( files_ids) ) ;
484
484
485
+ let merge_modules = get_merge_modules ( & settings) ?;
486
+ data. insert ( "merge_modules" , to_json ( merge_modules) ) ;
487
+
485
488
let main_binary = settings
486
489
. binaries ( )
487
490
. iter ( )
@@ -572,6 +575,38 @@ fn generate_binaries_data(settings: &Settings) -> crate::Result<Vec<Binary>> {
572
575
Ok ( binaries)
573
576
}
574
577
578
+ #[ derive( Serialize ) ]
579
+ struct MergeModule {
580
+ name : String ,
581
+ path : String ,
582
+ }
583
+
584
+ fn get_merge_modules ( settings : & Settings ) -> crate :: Result < Vec < MergeModule > > {
585
+ let mut merge_modules = Vec :: new ( ) ;
586
+ let regex = Regex :: new ( r"[^\w\d\.]" ) ?;
587
+ for msm in glob:: glob (
588
+ settings
589
+ . project_out_directory ( )
590
+ . join ( "*.msm" )
591
+ . to_string_lossy ( )
592
+ . to_string ( )
593
+ . as_str ( ) ,
594
+ ) ? {
595
+ let path = msm?;
596
+ let filename = path
597
+ . file_name ( )
598
+ . expect ( "failed to extract merge module filename" )
599
+ . to_os_string ( )
600
+ . into_string ( )
601
+ . expect ( "failed to convert merge module filename to string" ) ;
602
+ merge_modules. push ( MergeModule {
603
+ name : regex. replace_all ( & filename, "" ) . to_string ( ) ,
604
+ path : path. to_string_lossy ( ) . to_string ( ) ,
605
+ } ) ;
606
+ }
607
+ Ok ( merge_modules)
608
+ }
609
+
575
610
/// Generates the data required for the resource bundling on wix
576
611
fn generate_resource_data ( settings : & Settings ) -> crate :: Result < ResourceMap > {
577
612
let mut resources = ResourceMap :: new ( ) ;
You can’t perform that action at this time.
0 commit comments