From 5f06a35f4e6fe58d287ee8abed87fb1bb2c36246 Mon Sep 17 00:00:00 2001 From: Sherzod Mutalov Date: Sun, 3 Aug 2025 11:12:37 +0500 Subject: [PATCH] fix: use attributes to check the feature existence --- src-tauri/src/core/utils/mod.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src-tauri/src/core/utils/mod.rs b/src-tauri/src/core/utils/mod.rs index c479bd252..4e0149e20 100644 --- a/src-tauri/src/core/utils/mod.rs +++ b/src-tauri/src/core/utils/mod.rs @@ -103,6 +103,21 @@ pub fn normalize_path(path: &Path) -> PathBuf { ret } +pub fn can_override_npx() -> bool { + // we need to check the CPU for the AVX2 instruction support if we are running under the MacOS + // with Intel CPU. We can override `npx` command with `bun` only if CPU is + // supporting AVX2, otherwise we need to use default `npx` binary + #[cfg(all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")))] + { + if !is_x86_feature_detected!("avx2") { + log::warn!("Your CPU doesn't support AVX2 instruction, default npx binary will be used"); + return false; // we cannot override npx with bun binary + } + } + + true // by default, we can override npx with bun binary +} + #[tauri::command] pub fn write_yaml( app: tauri::AppHandle, @@ -196,17 +211,3 @@ pub fn is_library_available(library: &str) -> bool { } } -pub fn can_override_npx() -> bool { - // we need to check the CPU for the AVX2 instruction support if we are running under the MacOS - // with Intel CPU. We can override `npx` command with `bun` only if CPU is - // supporting AVX2, otherwise we need to use default `npx` binary - if cfg!(all(target_os="macos", any(target_arch = "x86", target_arch = "x86_64"))) - { - if !is_x86_feature_detected!("avx2") { - log::warn!("Your CPU doesn't support AVX2 instruction, default npx binary will be used"); - return false; // we cannot override npx with bun binary - } - } - - true // by default, we can override npx with bun binary -}