Skip to content

Commit f6f9192

Browse files
authored
fix(core): Android compilation on Windows (#5658)
1 parent 03d6c6a commit f6f9192

File tree

6 files changed

+52
-170
lines changed

6 files changed

+52
-170
lines changed

.changes/default-tls-features.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": major
3+
---
4+
5+
Added the `default-tls` and `reqwest-default-tls` Cargo features for enabling TLS suppport to connect over HTTPS.

core/tauri-build/src/lib.rs

+39-37
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,12 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
348348
.window_icon_path
349349
.unwrap_or_else(|| find_icon(&config, |i| i.ends_with(".ico"), "icons/icon.ico"));
350350

351-
if window_icon_path.exists() {
352-
let mut res = WindowsResource::new();
351+
if target_triple.contains("windows") {
352+
if window_icon_path.exists() {
353+
let mut res = WindowsResource::new();
353354

354-
res.set_manifest(
355-
r#"
355+
res.set_manifest(
356+
r#"
356357
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
357358
<dependency>
358359
<dependentAssembly>
@@ -368,42 +369,43 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
368369
</dependency>
369370
</assembly>
370371
"#,
371-
);
372-
373-
if let Some(sdk_dir) = &attributes.windows_attributes.sdk_dir {
374-
if let Some(sdk_dir_str) = sdk_dir.to_str() {
375-
res.set_toolkit_path(sdk_dir_str);
376-
} else {
377-
return Err(anyhow!(
378-
"sdk_dir path is not valid; only UTF-8 characters are allowed"
379-
));
372+
);
373+
374+
if let Some(sdk_dir) = &attributes.windows_attributes.sdk_dir {
375+
if let Some(sdk_dir_str) = sdk_dir.to_str() {
376+
res.set_toolkit_path(sdk_dir_str);
377+
} else {
378+
return Err(anyhow!(
379+
"sdk_dir path is not valid; only UTF-8 characters are allowed"
380+
));
381+
}
380382
}
381-
}
382-
if let Some(version) = &config.package.version {
383-
if let Ok(v) = Version::parse(version) {
384-
let version = v.major << 48 | v.minor << 32 | v.patch << 16;
385-
res.set_version_info(VersionInfo::FILEVERSION, version);
386-
res.set_version_info(VersionInfo::PRODUCTVERSION, version);
383+
if let Some(version) = &config.package.version {
384+
if let Ok(v) = Version::parse(version) {
385+
let version = v.major << 48 | v.minor << 32 | v.patch << 16;
386+
res.set_version_info(VersionInfo::FILEVERSION, version);
387+
res.set_version_info(VersionInfo::PRODUCTVERSION, version);
388+
}
389+
res.set("FileVersion", version);
390+
res.set("ProductVersion", version);
387391
}
388-
res.set("FileVersion", version);
389-
res.set("ProductVersion", version);
390-
}
391-
if let Some(product_name) = &config.package.product_name {
392-
res.set("ProductName", product_name);
393-
res.set("FileDescription", product_name);
394-
}
395-
res.set_icon_with_id(&window_icon_path.display().to_string(), "32512");
396-
res.compile().with_context(|| {
397-
format!(
398-
"failed to compile `{}` into a Windows Resource file during tauri-build",
392+
if let Some(product_name) = &config.package.product_name {
393+
res.set("ProductName", product_name);
394+
res.set("FileDescription", product_name);
395+
}
396+
res.set_icon_with_id(&window_icon_path.display().to_string(), "32512");
397+
res.compile().with_context(|| {
398+
format!(
399+
"failed to compile `{}` into a Windows Resource file during tauri-build",
400+
window_icon_path.display()
401+
)
402+
})?;
403+
} else {
404+
return Err(anyhow!(format!(
405+
"`{}` not found; required for generating a Windows Resource file during tauri-build",
399406
window_icon_path.display()
400-
)
401-
})?;
402-
} else {
403-
return Err(anyhow!(format!(
404-
"`{}` not found; required for generating a Windows Resource file during tauri-build",
405-
window_icon_path.display()
406-
)));
407+
)));
408+
}
407409
}
408410

409411
let target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap();

core/tauri/Cargo.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ dirs-next = "2.0"
6767
percent-encoding = "2.2"
6868
base64 = { version = "0.13", optional = true }
6969
clap = { version = "3", optional = true }
70-
reqwest = { version = "0.11", features = [ "json", "stream" ], optional = true }
70+
reqwest = { version = "0.11", default-features = false, features = [ "json", "stream" ], optional = true }
7171
bytes = { version = "1", features = [ "serde" ], optional = true }
72-
attohttpc = { version = "0.22", features = [ "compress", "json", "form" ] }
72+
attohttpc = { version = "0.24", default-features = false, features = [ "compress", "json", "form" ] }
7373
open = { version = "3.0", optional = true }
7474
shared_child = { version = "1.0", optional = true }
7575
os_pipe = { version = "1.0", optional = true }
@@ -147,6 +147,8 @@ http-multipart = [ "attohttpc/multipart-form", "reqwest/multipart" ]
147147
shell-open-api = [ "open", "regex", "tauri-macros/shell-scope" ]
148148
fs-extract-api = [ "zip" ]
149149
reqwest-client = [ "reqwest", "bytes" ]
150+
reqwest-default-tls = [ "reqwest-client", "reqwest/default-tls" ]
151+
default-tls = [ "attohttpc/tls-native" ]
150152
reqwest-native-tls-vendored = [ "reqwest-client", "reqwest/native-tls-vendored" ]
151153
native-tls-vendored = [ "attohttpc/tls-vendored" ]
152154
process-command-api = [ "shared_child", "os_pipe" ]

core/tauri/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
//! - **http-api**: Enables the [`api::http`] module.
2323
//! - **http-multipart**: Adds support to `multipart/form-data` requests.
2424
//! - **reqwest-client**: Uses `reqwest` as HTTP client on the `http` APIs. Improves performance, but increases the bundle size.
25+
//! - **default-tls**: Provides TLS support to connect over HTTPS (applies to the default HTTP client).
26+
//! - **reqwest-default-tls**: Provides TLS support to connect over HTTPS (applies to the `reqwest` HTTP client).
2527
//! - **native-tls-vendored**: Compile and statically link to a vendored copy of OpenSSL (applies to the default HTTP client).
2628
//! - **reqwest-native-tls-vendored**: Compile and statically link to a vendored copy of OpenSSL (applies to the `reqwest` HTTP client).
2729
//! - **process-command-api**: Enables the [`api::process::Command`] APIs.

examples/api/src-tauri/Cargo.lock

-129
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tooling/cli/src/interface/rust.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ fn shared_options(
353353
let all_features = app_settings
354354
.manifest
355355
.all_enabled_features(if let Some(f) = features { f } else { &[] });
356-
if !all_features.contains(&"tauri/native-tls-vendored".into())
357-
&& !all_features.contains(&"tauri/reqwest-native-tls-vendored".into())
356+
if all_features.contains(&"tauri/default-tls".into())
357+
|| all_features.contains(&"tauri/reqwest-default-tls".into())
358358
{
359359
if all_features.contains(&"tauri/reqwest-client".into()) {
360360
features

0 commit comments

Comments
 (0)