mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
feat(bundler): add visual c++ redistributable files with MSM (#1368)
This commit is contained in:
committed by
GitHub
parent
2afb3f8ad5
commit
3047a18975
5
.changes/vc-redistributable.md
Normal file
5
.changes/vc-redistributable.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-bundler": patch
|
||||
---
|
||||
|
||||
Bundle Visual C++ redistributable files with VC142_CRT merge modules.
|
||||
BIN
cli/core/src/MergeModules/Microsoft_VC142_CRT_x64.msm
Normal file
BIN
cli/core/src/MergeModules/Microsoft_VC142_CRT_x64.msm
Normal file
Binary file not shown.
BIN
cli/core/src/MergeModules/Microsoft_VC142_CRT_x86.msm
Normal file
BIN
cli/core/src/MergeModules/Microsoft_VC142_CRT_x86.msm
Normal file
Binary file not shown.
@@ -100,6 +100,26 @@ impl Build {
|
||||
|
||||
if config_.tauri.bundle.active {
|
||||
let bundler_settings = rust::get_bundler_settings(&config_, self.debug)?;
|
||||
// move merge modules to the out dir so the bundler can load it
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let (filename, vcruntime_msm) = if cfg!(target_arch = "x86") {
|
||||
let _ =
|
||||
std::fs::remove_file(bundler_settings.out_dir.join("Microsoft_VC142_CRT_x64.msm"));
|
||||
(
|
||||
"Microsoft_VC142_CRT_x86.msm",
|
||||
include_bytes!("./MergeModules/Microsoft_VC142_CRT_x86.msm").to_vec(),
|
||||
)
|
||||
} else {
|
||||
let _ =
|
||||
std::fs::remove_file(bundler_settings.out_dir.join("Microsoft_VC142_CRT_x86.msm"));
|
||||
(
|
||||
"Microsoft_VC142_CRT_x64.msm",
|
||||
include_bytes!("./MergeModules/Microsoft_VC142_CRT_x64.msm").to_vec(),
|
||||
)
|
||||
};
|
||||
std::fs::write(bundler_settings.out_dir.join(filename), vcruntime_msm)?;
|
||||
}
|
||||
let mut settings_builder = SettingsBuilder::new()
|
||||
.package_settings(bundler_settings.package_settings)
|
||||
.bundle_settings(bundler_settings.bundle_settings)
|
||||
|
||||
@@ -112,6 +112,16 @@
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
||||
{{#each merge_modules as |msm| ~}}
|
||||
<DirectoryRef Id="TARGETDIR">
|
||||
<Merge Id="{{ msm.name }}" SourceFile="{{ msm.path }}" DiskId="1" Language="0"/>
|
||||
</DirectoryRef>
|
||||
|
||||
<Feature Id="{{ msm.name }}" Title="{{ msm.name }}" AllowAdvertise="no" Display="hidden" Level="1">
|
||||
<MergeRef Id="{{ msm.name }}"/>
|
||||
</Feature>
|
||||
{{/each~}}
|
||||
|
||||
<Feature
|
||||
Id="MainProgram"
|
||||
Title="Application"
|
||||
|
||||
@@ -482,6 +482,9 @@ pub fn build_wix_app_installer(
|
||||
data.insert("resources", to_json(resources_wix_string));
|
||||
data.insert("resource_file_ids", to_json(files_ids));
|
||||
|
||||
let merge_modules = get_merge_modules(&settings)?;
|
||||
data.insert("merge_modules", to_json(merge_modules));
|
||||
|
||||
let main_binary = settings
|
||||
.binaries()
|
||||
.iter()
|
||||
@@ -572,6 +575,38 @@ fn generate_binaries_data(settings: &Settings) -> crate::Result<Vec<Binary>> {
|
||||
Ok(binaries)
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct MergeModule {
|
||||
name: String,
|
||||
path: String,
|
||||
}
|
||||
|
||||
fn get_merge_modules(settings: &Settings) -> crate::Result<Vec<MergeModule>> {
|
||||
let mut merge_modules = Vec::new();
|
||||
let regex = Regex::new(r"[^\w\d\.]")?;
|
||||
for msm in glob::glob(
|
||||
settings
|
||||
.project_out_directory()
|
||||
.join("*.msm")
|
||||
.to_string_lossy()
|
||||
.to_string()
|
||||
.as_str(),
|
||||
)? {
|
||||
let path = msm?;
|
||||
let filename = path
|
||||
.file_name()
|
||||
.expect("failed to extract merge module filename")
|
||||
.to_os_string()
|
||||
.into_string()
|
||||
.expect("failed to convert merge module filename to string");
|
||||
merge_modules.push(MergeModule {
|
||||
name: regex.replace_all(&filename, "").to_string(),
|
||||
path: path.to_string_lossy().to_string(),
|
||||
});
|
||||
}
|
||||
Ok(merge_modules)
|
||||
}
|
||||
|
||||
/// Generates the data required for the resource bundling on wix
|
||||
fn generate_resource_data(settings: &Settings) -> crate::Result<ResourceMap> {
|
||||
let mut resources = ResourceMap::new();
|
||||
|
||||
Reference in New Issue
Block a user