Skip to content

Commit dfba0ed

Browse files
fix(bundler): Detect ARM gnueabi as soft-float (fix: #10970) (#11084)
* Detect ARM gnueabi as soft-float (armel) Detect ARM gnueabi as soft-float (armel) instead of hard-float (armhf). Also change the signature of `tauri_bundler::bundle::Settings::binary_arch` to return an enum instead of a `&str`. * Update .changes/bundler-gnueabi-armel.md * fix dmg --------- Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app> Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent 1efa5e7 commit dfba0ed

File tree

8 files changed

+93
-43
lines changed

8 files changed

+93
-43
lines changed

Diff for: .changes/bundler-gnueabi-armel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": patch:bug
3+
---
4+
5+
Detect ARM gnueabi as soft-float (armel) instead of hard-float (armhf). Also change the signature of `tauri_bundler::bundle::Settings::binary_arch` to return an enum instead of a `&str`.

Diff for: crates/tauri-bundler/src/bundle/linux/appimage/mod.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::{
1010
},
1111
debian,
1212
};
13-
use crate::Settings;
13+
use crate::{bundle::settings::Arch, Settings};
1414
use anyhow::Context;
1515
use handlebars::Handlebars;
1616
use std::{
@@ -24,11 +24,17 @@ use std::{
2424
/// Returns a vector of PathBuf that shows where the AppImage was created.
2525
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
2626
// generate the deb binary name
27-
let arch = match settings.binary_arch() {
28-
"x86" => "i386",
29-
"x86_64" => "amd64",
30-
"armv7" => "armhf",
31-
other => other,
27+
let arch: &str = match settings.binary_arch() {
28+
Arch::X86_64 => "amd64",
29+
Arch::X86 => "i386",
30+
Arch::AArch64 => "aarch64",
31+
Arch::Armhf => "armhf",
32+
target => {
33+
return Err(crate::Error::ArchError(format!(
34+
"Unsupported architecture: {:?}",
35+
target
36+
)));
37+
}
3238
};
3339
let package_dir = settings.project_out_directory().join("bundle/appimage_deb");
3440

Diff for: crates/tauri-bundler/src/bundle/linux/debian.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// generate postinst or prerm files.
2525

2626
use super::{super::common, freedesktop};
27-
use crate::Settings;
27+
use crate::{bundle::settings::Arch, Settings};
2828
use anyhow::Context;
2929
use flate2::{write::GzEncoder, Compression};
3030
use tar::HeaderMode;
@@ -41,12 +41,17 @@ use std::{
4141
/// Returns a vector of PathBuf that shows where the DEB was created.
4242
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
4343
let arch = match settings.binary_arch() {
44-
"x86" => "i386",
45-
"x86_64" => "amd64",
46-
// ARM64 is detected differently, armel isn't supported, so armhf is the only reasonable choice here.
47-
"arm" => "armhf",
48-
"aarch64" => "arm64",
49-
other => other,
44+
Arch::X86_64 => "amd64",
45+
Arch::X86 => "i386",
46+
Arch::AArch64 => "arm64",
47+
Arch::Armhf => "armhf",
48+
Arch::Armel => "armel",
49+
target => {
50+
return Err(crate::Error::ArchError(format!(
51+
"Unsupported architecture: {:?}",
52+
target
53+
)));
54+
}
5055
};
5156
let package_base_name = format!(
5257
"{}_{}_{}",

Diff for: crates/tauri-bundler/src/bundle/linux/rpm.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// SPDX-License-Identifier: Apache-2.0
44
// SPDX-License-Identifier: MIT
55

6-
use crate::Settings;
6+
use crate::{bundle::settings::Arch, Settings};
77

88
use anyhow::Context;
99
use rpm::{self, signature::pgp, Dependency, FileMode, FileOptions};
@@ -23,9 +23,17 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
2323
let release = settings.rpm().release.as_str();
2424
let epoch = settings.rpm().epoch;
2525
let arch = match settings.binary_arch() {
26-
"x86" => "i386",
27-
"arm" => "armhfp",
28-
other => other,
26+
Arch::X86_64 => "x86_64",
27+
Arch::X86 => "i386",
28+
Arch::AArch64 => "aarch64",
29+
Arch::Armhf => "armhfp",
30+
Arch::Armel => "armel",
31+
target => {
32+
return Err(crate::Error::ArchError(format!(
33+
"Unsupported architecture: {:?}",
34+
target
35+
)));
36+
}
2937
};
3038

3139
let summary = settings.short_description().trim();

Diff for: crates/tauri-bundler/src/bundle/macos/dmg/mod.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use super::{app, icon::create_icns_file};
77
use crate::{
8-
bundle::{common::CommandExt, Bundle},
8+
bundle::{common::CommandExt, settings::Arch, Bundle},
99
PackageType, Settings,
1010
};
1111

@@ -43,8 +43,15 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result<
4343
settings.product_name(),
4444
settings.version_string(),
4545
match settings.binary_arch() {
46-
"x86_64" => "x64",
47-
other => other,
46+
Arch::X86_64 => "x64",
47+
Arch::AArch64 => "aarch64",
48+
Arch::Universal => "universal",
49+
target => {
50+
return Err(crate::Error::ArchError(format!(
51+
"Unsupported architecture: {:?}",
52+
target
53+
)));
54+
}
4855
}
4956
);
5057
let dmg_name = format!("{}.dmg", &package_base_name);

Diff for: crates/tauri-bundler/src/bundle/settings.rs

+24-6
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,22 @@ impl BundleBinary {
683683
}
684684
}
685685

686+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
687+
pub enum Arch {
688+
/// For the x86_64 / x64 / AMD64 instruction sets (64 bits).
689+
X86_64,
690+
/// For the x86 / i686 / i686 / 8086 instruction sets (32 bits).
691+
X86,
692+
/// For the AArch64 / ARM64 instruction sets (64 bits).
693+
AArch64,
694+
/// For the AArch32 / ARM32 instruction sets with hard-float (32 bits).
695+
Armhf,
696+
/// For the AArch32 / ARM32 instruction sets with soft-float (32 bits).
697+
Armel,
698+
/// For universal macOS applications.
699+
Universal,
700+
}
701+
686702
/// The Settings exposed by the module.
687703
#[derive(Clone, Debug)]
688704
pub struct Settings {
@@ -845,17 +861,19 @@ impl Settings {
845861
}
846862

847863
/// Returns the architecture for the binary being bundled (e.g. "arm", "x86" or "x86_64").
848-
pub fn binary_arch(&self) -> &str {
864+
pub fn binary_arch(&self) -> Arch {
849865
if self.target.starts_with("x86_64") {
850-
"x86_64"
866+
Arch::X86_64
851867
} else if self.target.starts_with('i') {
852-
"x86"
868+
Arch::X86
869+
} else if self.target.starts_with("arm") && self.target.ends_with("hf") {
870+
Arch::Armhf
853871
} else if self.target.starts_with("arm") {
854-
"arm"
872+
Arch::Armel
855873
} else if self.target.starts_with("aarch64") {
856-
"aarch64"
874+
Arch::AArch64
857875
} else if self.target.starts_with("universal") {
858-
"universal"
876+
Arch::Universal
859877
} else {
860878
panic!("Unexpected target triple {}", self.target)
861879
}

Diff for: crates/tauri-bundler/src/bundle/windows/msi/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use crate::bundle::{
77
common::CommandExt,
88
path_utils::{copy_file, FileOpts},
9-
settings::Settings,
9+
settings::{Arch, Settings},
1010
windows::{
1111
sign::try_sign,
1212
util::{
@@ -217,12 +217,12 @@ fn app_installer_output_path(
217217
updater: bool,
218218
) -> crate::Result<PathBuf> {
219219
let arch = match settings.binary_arch() {
220-
"x86" => "x86",
221-
"x86_64" => "x64",
222-
"aarch64" => "arm64",
220+
Arch::X86_64 => "x64",
221+
Arch::X86 => "x86",
222+
Arch::AArch64 => "arm64",
223223
target => {
224224
return Err(crate::Error::ArchError(format!(
225-
"Unsupported architecture: {}",
225+
"Unsupported architecture: {:?}",
226226
target
227227
)))
228228
}
@@ -330,12 +330,12 @@ fn run_candle(
330330
extensions: Vec<PathBuf>,
331331
) -> crate::Result<()> {
332332
let arch = match settings.binary_arch() {
333-
"x86_64" => "x64",
334-
"x86" => "x86",
335-
"aarch64" => "arm64",
333+
Arch::X86_64 => "x64",
334+
Arch::X86 => "x86",
335+
Arch::AArch64 => "arm64",
336336
target => {
337337
return Err(crate::Error::ArchError(format!(
338-
"unsupported target: {}",
338+
"unsupported architecture: {:?}",
339339
target
340340
)))
341341
}
@@ -421,12 +421,12 @@ pub fn build_wix_app_installer(
421421
updater: bool,
422422
) -> crate::Result<Vec<PathBuf>> {
423423
let arch = match settings.binary_arch() {
424-
"x86_64" => "x64",
425-
"x86" => "x86",
426-
"aarch64" => "arm64",
424+
Arch::X86_64 => "x64",
425+
Arch::X86 => "x86",
426+
Arch::AArch64 => "arm64",
427427
target => {
428428
return Err(crate::Error::ArchError(format!(
429-
"unsupported target: {}",
429+
"unsupported architecture: {:?}",
430430
target
431431
)))
432432
}

Diff for: crates/tauri-bundler/src/bundle/windows/nsis/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5+
use crate::bundle::settings::Arch;
56
use crate::bundle::windows::sign::{sign_command, try_sign};
67

78
use crate::{
@@ -152,12 +153,12 @@ fn build_nsis_app_installer(
152153
updater: bool,
153154
) -> crate::Result<Vec<PathBuf>> {
154155
let arch = match settings.binary_arch() {
155-
"x86_64" => "x64",
156-
"x86" => "x86",
157-
"aarch64" => "arm64",
156+
Arch::X86_64 => "x64",
157+
Arch::X86 => "x86",
158+
Arch::AArch64 => "arm64",
158159
target => {
159160
return Err(crate::Error::ArchError(format!(
160-
"unsupported target: {}",
161+
"unsupported architecture: {:?}",
161162
target
162163
)))
163164
}

0 commit comments

Comments
 (0)