fix(build): statically link VC runtime only on tauri build (#4292)

This commit is contained in:
Lucas Fernandes Nogueira
2022-06-07 18:34:30 -07:00
committed by GitHub
parent 3455244436
commit d703d27a70
5 changed files with 18 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---
Configure the `STATIC_VCRUNTIME` environment variable so `tauri-build` statically links it on the build command.

View File

@@ -0,0 +1,5 @@
---
"tauri-build": patch
---
Only statically link the VC runtime when the `STATIC_VCRUNTIME` environment variable is set to `true` (automatically done by the Tauri CLI).

View File

@@ -187,7 +187,9 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
};
#[cfg(windows)]
static_vcruntime::build();
if std::env::var("STATIC_VCRUNTIME").map_or(false, |v| v == "true") {
static_vcruntime::build();
}
cfg_alias("dev", !has_feature("custom-protocol"));

View File

@@ -2,4 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
fn main() {}
fn main() {
tauri_build::build()
}

View File

@@ -104,6 +104,7 @@ pub fn build_project(runner: String, args: Vec<String>) -> crate::Result<()> {
Command::new(&runner)
.args(&["build", "--features=custom-protocol"])
.args(args)
.env("STATIC_VCRUNTIME", "true")
.pipe()?
.output_ok()
.with_context(|| format!("Result of `{} build` operation was unsuccessful", runner))?;