Skip to content

Commit

Permalink
fix(build): statically link VC runtime only on tauri build (#4292)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Jun 8, 2022
1 parent 3455244 commit d703d27
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/set-static-vcruntime-envvar.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions .changes/static-vcruntime-config-envvar.md
Original file line number Diff line number Diff line change
@@ -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).
4 changes: 3 additions & 1 deletion core/tauri-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down
4 changes: 3 additions & 1 deletion core/tests/app-updater/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

fn main() {}
fn main() {
tauri_build::build()
}
1 change: 1 addition & 0 deletions tooling/cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?;
Expand Down

0 comments on commit d703d27

Please sign in to comment.