From 2d4d125c674e6f98ab150a79708883a636e03106 Mon Sep 17 00:00:00 2001 From: SpikeHD <25207995+SpikeHD@users.noreply.github.com> Date: Fri, 4 Oct 2024 09:15:23 -0700 Subject: [PATCH] fix: better feature handling --- .github/workflows/build.yml | 9 +-------- src-tauri/src/functionality/extension.rs | 2 +- src-tauri/src/functionality/hotkeys.rs | 2 -- src-tauri/src/functionality/keyboard.rs | 3 +++ src-tauri/src/functionality/mod.rs | 2 ++ src-tauri/src/functionality/window.rs | 5 +++-- src-tauri/src/main.rs | 12 ++++++++---- src-tauri/src/util/paths.rs | 1 + 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 652c060..0af7455 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -150,20 +150,13 @@ jobs: run: pnpm install && pnpm shupdate - name: Build - if: matrix.config.target != 'armv7-unknown-linux-gnueabihf' && matrix.config.target != 'aarch64-unknown-linux-gnu' && matrix.config.platform != 'macos-latest' + if: matrix.config.target != 'armv7-unknown-linux-gnueabihf' && matrix.config.target != 'aarch64-unknown-linux-gnu' # If we are compiling for Windows ARM, we can only support NSIS # However, I cannot phase out the MSI or a buncha package managers will explode run: pnpm tauri build --target ${{ matrix.config.target }} ${{ matrix.config.target == 'aarch64-pc-windows-msvc' && '--bundles nsis' || '' }} env: RUSTFLAGS: -Awarnings - - name: Build (macOS) - if: matrix.config.platform == 'macos-latest' - # Don't compile features that don't work anyways - run: pnpm tauri build --target ${{ matrix.config.target }} -- --no-default-features --features blur - env: - RUSTFLAGS: -Awarnings - - name: (Linux) (ARMv7) Build if: matrix.config.target == 'armv7-unknown-linux-gnueabihf' run: pnpm tauri build --target ${{ matrix.config.target }} --bundles deb -- --config target.armv7-unknown-linux-gnueabihf.linker=\'arm-linux-gnueabihf-gcc\' diff --git a/src-tauri/src/functionality/extension.rs b/src-tauri/src/functionality/extension.rs index c080204..8c93d1f 100644 --- a/src-tauri/src/functionality/extension.rs +++ b/src-tauri/src/functionality/extension.rs @@ -68,8 +68,8 @@ pub fn add_extension(win: &WebviewWindow, path: std::path::PathBuf) { #[cfg(target_os = "windows")] pub fn load_extensions(win: &WebviewWindow) { - use std::fs; use crate::util::paths::get_extensions_dir; + use std::fs; log!("Loading extensions..."); diff --git a/src-tauri/src/functionality/hotkeys.rs b/src-tauri/src/functionality/hotkeys.rs index 6bd9be1..05b070e 100644 --- a/src-tauri/src/functionality/hotkeys.rs +++ b/src-tauri/src/functionality/hotkeys.rs @@ -38,12 +38,10 @@ pub fn set_keybind(action: String, keys: Vec) { set_keybinds(keybinds); } -#[cfg(target_os = "macos")] pub fn start_keybind_watcher(_win: &tauri::WebviewWindow) { log!("Keybinds are not supported on macOS yet."); } -#[cfg(not(target_os = "macos"))] pub fn start_keybind_watcher(win: &tauri::WebviewWindow) { win.listen("keybinds_changed", |evt| { let payload = evt.payload(); diff --git a/src-tauri/src/functionality/keyboard.rs b/src-tauri/src/functionality/keyboard.rs index 4fef7f0..e2a7dd7 100644 --- a/src-tauri/src/functionality/keyboard.rs +++ b/src-tauri/src/functionality/keyboard.rs @@ -1,8 +1,10 @@ #[cfg(feature = "hotkeys")] +#[cfg(not(target_os = "macos"))] use device_query::keymap::Keycode; use serde::{Deserialize, Serialize}; #[cfg(feature = "hotkeys")] +#[cfg(not(target_os = "macos"))] #[derive(Debug)] pub struct KeyComboState { pub keys: Vec, @@ -23,6 +25,7 @@ pub struct KeyStruct { // this sucks #[cfg(feature = "hotkeys")] +#[cfg(not(target_os = "macos"))] pub fn js_keycode_to_key(keycode: String) -> Option { // Might have to make a PR not gonna lie match keycode.as_str() { diff --git a/src-tauri/src/functionality/mod.rs b/src-tauri/src/functionality/mod.rs index 3657a5b..a7ec0d2 100644 --- a/src-tauri/src/functionality/mod.rs +++ b/src-tauri/src/functionality/mod.rs @@ -2,12 +2,14 @@ pub mod cache; pub mod extension; #[cfg(feature = "hotkeys")] +#[cfg(not(target_os = "macos"))] pub mod hotkeys; pub mod keyboard; pub mod menu; #[cfg(feature = "rpc")] +#[cfg(not(target_os = "macos"))] pub mod rpc; pub mod streamer_mode; diff --git a/src-tauri/src/functionality/window.rs b/src-tauri/src/functionality/window.rs index 00832f6..1ef2e2f 100644 --- a/src-tauri/src/functionality/window.rs +++ b/src-tauri/src/functionality/window.rs @@ -62,6 +62,7 @@ pub fn after_build(window: &tauri::WebviewWindow) { } #[cfg(feature = "hotkeys")] + #[cfg(not(target_os = "macos"))] if config.keybinds_enabled.unwrap_or(false) { log!("Starting global keybind watcher..."); super::hotkeys::start_keybind_watcher(window); @@ -102,10 +103,10 @@ pub fn after_build(window: &tauri::WebviewWindow) { #[cfg(target_os = "windows")] { + use super::extension::add_extension; + use crate::util::paths::get_main_extension_path; use std::fs; use std::path::PathBuf; - use crate::util::paths::get_main_extension_path; - use super::extension::add_extension; use tauri::path::BaseDirectory; // This should be the last extension loaded, the others are loaded early on diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index afa9f04..504ea68 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -3,7 +3,7 @@ windows_subsystem = "windows" )] -use std::{env, sync::LazyLock, time::Duration}; +use std::{env, time::Duration}; use tauri::{Manager, WebviewWindowBuilder}; use tauri_plugin_window_state::{AppHandleExt, StateFlags, WindowExt}; @@ -38,11 +38,9 @@ mod release; mod util; mod window; -static GIT_HASH: LazyLock<&str> = LazyLock::new(|| option_env!("GIT_HASH").unwrap_or("Unknown")); - #[tauri::command] fn git_hash() -> String { - GIT_HASH.to_string() + option_env!("GIT_HASH").unwrap_or("Unknown").to_string() } #[tauri::command] @@ -164,14 +162,19 @@ fn main() { release::do_update, release::update_check, #[cfg(feature = "rpc")] + #[cfg(not(target_os = "macos"))] functionality::rpc::get_windows, #[cfg(feature = "rpc")] + #[cfg(not(target_os = "macos"))] functionality::rpc::get_local_detectables, #[cfg(feature = "hotkeys")] + #[cfg(not(target_os = "macos"))] functionality::hotkeys::get_keybinds, #[cfg(feature = "hotkeys")] + #[cfg(not(target_os = "macos"))] functionality::hotkeys::set_keybinds, #[cfg(feature = "hotkeys")] + #[cfg(not(target_os = "macos"))] functionality::hotkeys::set_keybind, injection_runner::get_injection_js, config::get_config, @@ -286,6 +289,7 @@ fn main() { // begin the RPC server if needed #[cfg(feature = "rpc")] + #[cfg(not(target_os = "macos"))] if get_config().rpc_server.unwrap_or(false) { let win_cln = win.clone(); std::thread::spawn(|| { diff --git a/src-tauri/src/util/paths.rs b/src-tauri/src/util/paths.rs index 002002a..111b826 100644 --- a/src-tauri/src/util/paths.rs +++ b/src-tauri/src/util/paths.rs @@ -233,6 +233,7 @@ pub fn updater_dir(win: &tauri::WebviewWindow) -> PathBuf { } #[cfg(feature = "rpc")] +#[cfg(not(target_os = "macos"))] pub fn custom_detectables_path() -> PathBuf { let current_exe = std::env::current_exe().unwrap_or_default();