Skip to content

Commit d703d27

Browse files
authored
fix(build): statically link VC runtime only on tauri build (#4292)
1 parent 3455244 commit d703d27

5 files changed

Lines changed: 18 additions & 2 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"cli.js": patch
4+
---
5+
6+
Configure the `STATIC_VCRUNTIME` environment variable so `tauri-build` statically links it on the build command.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-build": patch
3+
---
4+
5+
Only statically link the VC runtime when the `STATIC_VCRUNTIME` environment variable is set to `true` (automatically done by the Tauri CLI).

core/tauri-build/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
187187
};
188188

189189
#[cfg(windows)]
190-
static_vcruntime::build();
190+
if std::env::var("STATIC_VCRUNTIME").map_or(false, |v| v == "true") {
191+
static_vcruntime::build();
192+
}
191193

192194
cfg_alias("dev", !has_feature("custom-protocol"));
193195

core/tests/app-updater/build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5-
fn main() {}
5+
fn main() {
6+
tauri_build::build()
7+
}

tooling/cli/src/interface/rust.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ pub fn build_project(runner: String, args: Vec<String>) -> crate::Result<()> {
104104
Command::new(&runner)
105105
.args(&["build", "--features=custom-protocol"])
106106
.args(args)
107+
.env("STATIC_VCRUNTIME", "true")
107108
.pipe()?
108109
.output_ok()
109110
.with_context(|| format!("Result of `{} build` operation was unsuccessful", runner))?;

0 commit comments

Comments
 (0)