Skip to content

Commit a2be88a

Browse files
refactor: remove bitness crate from bundler (#7405)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent 907425d commit a2be88a

File tree

5 files changed

+57
-55
lines changed

5 files changed

+57
-55
lines changed

.changes/remove-bitness.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri-bundler': 'patch:deps'
3+
---
4+
5+
Removed the `bitness` dependency to speed up compile time.

tooling/bundler/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ dunce = "1"
4343

4444
[target."cfg(target_os = \"windows\")".dependencies]
4545
uuid = { version = "1", features = [ "v4", "v5" ] }
46-
bitness = "0.4"
4746
winreg = "0.50"
4847
glob = "0.3"
4948

49+
[target."cfg(target_os = \"windows\")".dependencies.windows-sys]
50+
version = "0.48"
51+
features = [
52+
"Win32_System_SystemInformation",
53+
"Win32_System_Diagnostics_Debug"
54+
]
55+
5056
[target."cfg(target_os = \"macos\")".dependencies]
5157
icns = { package = "tauri-icns", version = "0.1" }
5258
time = { version = "0.3", features = [ "formatting" ] }

tooling/bundler/src/bundle/windows/sign.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
// SPDX-License-Identifier: Apache-2.0
44
// SPDX-License-Identifier: MIT
55

6-
use crate::{bundle::common::CommandExt, Settings};
7-
use bitness::{self, Bitness};
6+
use crate::{
7+
bundle::{common::CommandExt, windows::util},
8+
Settings,
9+
};
810
use log::{debug, info};
911
use std::{
1012
path::{Path, PathBuf},
@@ -69,11 +71,7 @@ fn locate_signtool() -> crate::Result<PathBuf> {
6971
kit_bin_paths.push(kits_root_10_bin_path);
7072

7173
// Choose which version of SignTool to use based on OS bitness
72-
let arch_dir = match bitness::os_bitness().expect("failed to get os bitness") {
73-
Bitness::X86_32 => "x86",
74-
Bitness::X86_64 => "x64",
75-
_ => return Err(crate::Error::UnsupportedBitness),
76-
};
74+
let arch_dir = util::os_bitness().ok_or(crate::Error::UnsupportedBitness)?;
7775

7876
/* Iterate through all bin paths, checking for existence of a SignTool executable. */
7977
for kit_bin_path in &kit_bin_paths {

tooling/bundler/src/bundle/windows/util.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,19 @@ pub fn extract_zip(data: &[u8], path: &Path) -> crate::Result<()> {
102102

103103
Ok(())
104104
}
105+
106+
#[cfg(target_os = "windows")]
107+
pub fn os_bitness<'a>() -> Option<&'a str> {
108+
use windows_sys::Win32::System::{
109+
Diagnostics::Debug::{PROCESSOR_ARCHITECTURE_AMD64, PROCESSOR_ARCHITECTURE_INTEL},
110+
SystemInformation::{GetNativeSystemInfo, SYSTEM_INFO},
111+
};
112+
113+
let mut system_info: SYSTEM_INFO = unsafe { std::mem::zeroed() };
114+
unsafe { GetNativeSystemInfo(&mut system_info) };
115+
match unsafe { system_info.Anonymous.Anonymous.wProcessorArchitecture } {
116+
PROCESSOR_ARCHITECTURE_INTEL => Some("x86"),
117+
PROCESSOR_ARCHITECTURE_AMD64 => Some("x64"),
118+
_ => None,
119+
}
120+
}

tooling/cli/Cargo.lock

Lines changed: 24 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)