Skip to content

Commit

Permalink
refactor: remove bitness crate from bundler (#7405)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
  • Loading branch information
amrbashir and lucasfernog authored Jul 12, 2023
1 parent 907425d commit a2be88a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 55 deletions.
5 changes: 5 additions & 0 deletions .changes/remove-bitness.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-bundler': 'patch:deps'
---

Removed the `bitness` dependency to speed up compile time.
8 changes: 7 additions & 1 deletion tooling/bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ dunce = "1"

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

[target."cfg(target_os = \"windows\")".dependencies.windows-sys]
version = "0.48"
features = [
"Win32_System_SystemInformation",
"Win32_System_Diagnostics_Debug"
]

[target."cfg(target_os = \"macos\")".dependencies]
icns = { package = "tauri-icns", version = "0.1" }
time = { version = "0.3", features = [ "formatting" ] }
Expand Down
12 changes: 5 additions & 7 deletions tooling/bundler/src/bundle/windows/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use crate::{bundle::common::CommandExt, Settings};
use bitness::{self, Bitness};
use crate::{
bundle::{common::CommandExt, windows::util},
Settings,
};
use log::{debug, info};
use std::{
path::{Path, PathBuf},
Expand Down Expand Up @@ -69,11 +71,7 @@ fn locate_signtool() -> crate::Result<PathBuf> {
kit_bin_paths.push(kits_root_10_bin_path);

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

/* Iterate through all bin paths, checking for existence of a SignTool executable. */
for kit_bin_path in &kit_bin_paths {
Expand Down
16 changes: 16 additions & 0 deletions tooling/bundler/src/bundle/windows/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,19 @@ pub fn extract_zip(data: &[u8], path: &Path) -> crate::Result<()> {

Ok(())
}

#[cfg(target_os = "windows")]
pub fn os_bitness<'a>() -> Option<&'a str> {
use windows_sys::Win32::System::{
Diagnostics::Debug::{PROCESSOR_ARCHITECTURE_AMD64, PROCESSOR_ARCHITECTURE_INTEL},
SystemInformation::{GetNativeSystemInfo, SYSTEM_INFO},
};

let mut system_info: SYSTEM_INFO = unsafe { std::mem::zeroed() };
unsafe { GetNativeSystemInfo(&mut system_info) };
match unsafe { system_info.Anonymous.Anonymous.wProcessorArchitecture } {
PROCESSOR_ARCHITECTURE_INTEL => Some("x86"),
PROCESSOR_ARCHITECTURE_AMD64 => Some("x64"),
_ => None,
}
}
71 changes: 24 additions & 47 deletions tooling/cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a2be88a

Please sign in to comment.