Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .changes/bundle-vc-runtime.md

This file was deleted.

17 changes: 17 additions & 0 deletions .changes/no-dest-resource-target.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"tauri-utils": "patch:bug"
---

Fix a regression in tauri-utils 2.8.3 that made empty path an invalid resource target, e.g.

```json
{
"bundle": {
"resources": {
"README.md": "",
}
}
}
```

(this means `README.md` -> `$RESOURCE/README.md`, note this is a confusing behavior, and will be changed in v3)
18 changes: 18 additions & 0 deletions .changes/resources-after-empty-diretory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"tauri-utils": "patch:bug"
---

Fix a regression in tauri-utils 2.8.3 that made an empty directory makes it skip all the following entries, e.g.

```json
{
"bundle": {
"resources": [
"empty-directory",
"README.md"
]
}
}
```

if `empty-directory` is empty, the `README.md` will not be copied to the resource directory (skipped)
6 changes: 0 additions & 6 deletions .changes/static-vc-runtime.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changes/tauri-build-static-vc-runtime.md

This file was deleted.

112 changes: 1 addition & 111 deletions crates/tauri-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ fn cfg_alias(alias: &str, has_feature: bool) {
#[derive(Debug)]
pub struct WindowsAttributes {
window_icon_path: Option<PathBuf>,
/// Whether to statically link the Visual C++ runtime into the application binary on Windows MSVC targets
static_vc_runtime: Option<bool>,
/// A string containing an [application manifest] to be included with the application on Windows.
///
/// Defaults to:
Expand Down Expand Up @@ -259,7 +257,6 @@ impl WindowsAttributes {
pub fn new() -> Self {
Self {
window_icon_path: Default::default(),
static_vc_runtime: None,
app_manifest: Some(include_str!("windows-app-manifest.xml").into()),
append_rc_content: Vec::new(),
}
Expand All @@ -271,7 +268,6 @@ impl WindowsAttributes {
Self {
app_manifest: None,
window_icon_path: Default::default(),
static_vc_runtime: None,
append_rc_content: Vec::new(),
}
}
Expand All @@ -286,15 +282,6 @@ impl WindowsAttributes {
self
}

/// Sets whether to statically link the Visual C++ runtime into the application binary on Windows MSVC targets.
///
/// If unset, this is read from `build > windows > staticVCRuntime` in the Tauri configuration.
#[must_use]
pub fn static_vc_runtime(mut self, static_vc_runtime: bool) -> Self {
self.static_vc_runtime.replace(static_vc_runtime);
self
}

/// Sets the [application manifest] to be included with the application on Windows.
///
/// Defaults to:
Expand Down Expand Up @@ -502,7 +489,6 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
json_patch::merge(&mut config, &merge_config);
}
let config: Config = serde_json::from_value(config)?;
let static_vc_runtime = should_static_link_vc_runtime(&config, &attributes);

let s = config.identifier.split('.');
let last = s.clone().count() - 1;
Expand Down Expand Up @@ -719,7 +705,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
}
}
}
"msvc" if static_vc_runtime => {
"msvc" if env::var_os("STATIC_VCRUNTIME").is_some_and(|v| v == "true") => {
static_vcruntime::build();
}
_ => (),
Expand All @@ -740,20 +726,6 @@ fn to_winres_version(v: &semver::Version) -> u64 {
(v.major << 48) | (v.minor << 32) | (v.patch << 16) | build
}

fn should_static_link_vc_runtime(config: &Config, attributes: &Attributes) -> bool {
if let Some(value) = env::var_os("STATIC_VCRUNTIME") {
println!(
"cargo:warning=STATIC_VCRUNTIME is deprecated; use build.windows.staticVCRuntime in tauri.conf.json or tauri_build::WindowsAttributes::static_vc_runtime instead."
);
value != "false"
} else {
attributes
.windows_attributes
.static_vc_runtime
.unwrap_or(config.build.windows.static_vc_runtime)
}
}

#[cfg(test)]
mod tests {
use semver::Version;
Expand Down Expand Up @@ -797,86 +769,4 @@ mod tests {
(1 << 48) | (2 << 32) | (3 << 16)
);
}

#[test]
fn static_vc_runtime_chain() {
// 1. Nothing is set, should default to true
let config = tauri_utils::config::Config::default();
let attributes = crate::Attributes::new();
assert!(crate::should_static_link_vc_runtime(&config, &attributes));

// 2. Set to anything but "false" in env, should be true
std::env::set_var("STATIC_VCRUNTIME", "qweqe");
let config = tauri_utils::config::Config::default();
let attributes = crate::Attributes::new();
assert!(crate::should_static_link_vc_runtime(&config, &attributes));
std::env::remove_var("STATIC_VCRUNTIME");

// 3. Set to "false" in env, should be false
std::env::set_var("STATIC_VCRUNTIME", "false");
let config = tauri_utils::config::Config::default();
let attributes = crate::Attributes::new();
assert!(!crate::should_static_link_vc_runtime(&config, &attributes));
std::env::remove_var("STATIC_VCRUNTIME");

// 4. Set to true in attributes, should be true
let config = tauri_utils::config::Config::default();
let attributes = crate::Attributes::new()
.windows_attributes(crate::WindowsAttributes::new().static_vc_runtime(true));
assert!(crate::should_static_link_vc_runtime(&config, &attributes));

// 5. Set to false in attributes, should be false
let config = tauri_utils::config::Config::default();
let attributes = crate::Attributes::new()
.windows_attributes(crate::WindowsAttributes::new().static_vc_runtime(false));
assert!(!crate::should_static_link_vc_runtime(&config, &attributes));

// 6. Set to true in config, should be true
let config = tauri_utils::config::Config {
build: tauri_utils::config::BuildConfig {
windows: tauri_utils::config::WindowsBuildConfig {
static_vc_runtime: true,
},
..Default::default()
},
..Default::default()
};
let attributes = crate::Attributes::new();
assert!(crate::should_static_link_vc_runtime(&config, &attributes));

// 7. Set to false in config, should be false
let config = tauri_utils::config::Config {
build: tauri_utils::config::BuildConfig {
windows: tauri_utils::config::WindowsBuildConfig {
static_vc_runtime: false,
},
..Default::default()
},
..Default::default()
};
let attributes = crate::Attributes::new();
assert!(!crate::should_static_link_vc_runtime(&config, &attributes));

// 8. Set to true in config and false in attributes, should be false because attributes takes precedence over config
let config = tauri_utils::config::Config {
build: tauri_utils::config::BuildConfig {
windows: tauri_utils::config::WindowsBuildConfig {
static_vc_runtime: true,
},
..Default::default()
},
..Default::default()
};
let attributes = crate::Attributes::new()
.windows_attributes(crate::WindowsAttributes::new().static_vc_runtime(false));
assert!(!crate::should_static_link_vc_runtime(&config, &attributes));

// 9. Set to false in env and true in attributes, should be false because env takes precedence over attributes
std::env::set_var("STATIC_VCRUNTIME", "false");
let config = tauri_utils::config::Config::default();
let attributes = crate::Attributes::new()
.windows_attributes(crate::WindowsAttributes::new().static_vc_runtime(true));
assert!(!crate::should_static_link_vc_runtime(&config, &attributes));
std::env::remove_var("STATIC_VCRUNTIME");
}
}
4 changes: 1 addition & 3 deletions crates/tauri-bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ plist = "1"
[target."cfg(target_os = \"windows\")".dependencies]
bitness = "0.4"
windows-registry = "0.5"
glob = "0.3"

[target."cfg(target_os = \"windows\")".dependencies.windows-sys]
version = "0.60"
Expand All @@ -66,9 +67,6 @@ ar = "0.9"
md5 = "0.8"
rpm = { version = "0.16", features = ["bzip2-compression"] }

[target."cfg(any(target_os = \"windows\", target_os = \"macos\", target_os = \"linux\"))".dependencies]
glob = "0.3"

[target."cfg(unix)".dependencies]
which = "8"

Expand Down
2 changes: 0 additions & 2 deletions crates/tauri-bundler/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ mod settings;
mod updater_bundle;
mod windows;

pub use windows::vswhere_path;

use tauri_utils::{display_path, platform::Target as TargetPlatform};

const BUNDLE_VAR_TOKEN: &[u8] = b"__TAURI_BUNDLE_TYPE_VAR_UNK";
Expand Down
8 changes: 0 additions & 8 deletions crates/tauri-bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,6 @@ pub struct WindowsSettings {
/// if the user's WebView2 is older than this version,
/// the installer will try to trigger a WebView2 update.
pub minimum_webview2_version: Option<String>,
/// Whether to bundle the Visual C++ runtime DLLs alongside the application.
///
/// This can be particularly useful when the application includes sidecars or DLLs that do not
/// statically link the Visual C++ runtime and require the runtime DLLs at runtime, and users
/// should not be required to install the Visual C++ Redistributable. This can also be useful
/// when `static_vc_runtime` is set to `false`.
pub bundle_vc_runtime: bool,
}

impl WindowsSettings {
Expand All @@ -636,7 +629,6 @@ mod _default {
allow_downgrades: true,
sign_command: None,
minimum_webview2_version: None,
bundle_vc_runtime: false,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-bundler/src/bundle/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ pub mod sign;

mod util;
pub use util::{
vswhere_path, NSIS_OUTPUT_FOLDER_NAME, NSIS_UPDATER_OUTPUT_FOLDER_NAME, WIX_OUTPUT_FOLDER_NAME,
NSIS_OUTPUT_FOLDER_NAME, NSIS_UPDATER_OUTPUT_FOLDER_NAME, WIX_OUTPUT_FOLDER_NAME,
WIX_UPDATER_OUTPUT_FOLDER_NAME,
};
17 changes: 1 addition & 16 deletions crates/tauri-bundler/src/bundle/windows/msi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
windows::{
sign::{should_sign, try_sign},
util::{
download_webview2_bootstrapper, download_webview2_offline_installer, vc_runtime_dlls,
download_webview2_bootstrapper, download_webview2_offline_installer,
WIX_OUTPUT_FOLDER_NAME, WIX_UPDATER_OUTPUT_FOLDER_NAME,
},
},
Expand Down Expand Up @@ -1066,21 +1066,6 @@ fn generate_resource_data(settings: &Settings) -> crate::Result<ResourceMap> {

let mut dlls = Vec::new();

if settings.windows().bundle_vc_runtime {
for dll in vc_runtime_dlls(settings.binary_arch())? {
let resource_path = dunce::simplified(&dll);
if added_resources.contains(&resource_path.to_path_buf()) {
continue;
}
added_resources.push(resource_path.to_path_buf());
dlls.push(ResourceFile {
id: format!("I{}", Uuid::new_v4().as_simple()),
guid: Uuid::new_v4().to_string(),
path: resource_path.to_path_buf(),
});
}
}

// TODO: The bundler should not include all DLLs it finds. Instead it should only include WebView2Loader.dll if present and leave the rest to the resources config.
let out_dir = settings.project_out_directory();
for dll in glob::glob(
Expand Down
18 changes: 1 addition & 17 deletions crates/tauri-bundler/src/bundle/windows/nsis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
windows::{
sign::{should_sign, sign_command, try_sign},
util::{
download_webview2_bootstrapper, download_webview2_offline_installer, vc_runtime_dlls,
download_webview2_bootstrapper, download_webview2_offline_installer,
NSIS_OUTPUT_FOLDER_NAME, NSIS_UPDATER_OUTPUT_FOLDER_NAME,
},
},
Expand Down Expand Up @@ -774,22 +774,6 @@ fn generate_resource_data(settings: &Settings) -> crate::Result<ResourcesMap> {
}
}

if settings.windows().bundle_vc_runtime {
for dll in vc_runtime_dlls(settings.binary_arch())? {
let dll = dunce::simplified(&dll).to_path_buf();
if added_resources.contains(&dll) {
continue;
}
let target = PathBuf::from(
dll
.file_name()
.expect("failed to extract Visual C++ runtime DLL filename"),
);
added_resources.push(dll.clone());
resources.insert(dll, (PathBuf::new(), target));
}
}

for resource in settings.resource_files().iter() {
let resource = resource?;

Expand Down
Loading
Loading