Skip to content

Commit

Permalink
fix: better feature handling
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Oct 4, 2024
1 parent 9a0ac19 commit 2d4d125
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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\'
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/functionality/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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...");

Expand Down
2 changes: 0 additions & 2 deletions src-tauri/src/functionality/hotkeys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ pub fn set_keybind(action: String, keys: Vec<KeyStruct>) {
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();
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/functionality/keyboard.rs
Original file line number Diff line number Diff line change
@@ -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<Keycode>,
Expand All @@ -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<Keycode> {
// Might have to make a PR not gonna lie
match keycode.as_str() {
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/functionality/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src-tauri/src/functionality/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(|| {
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/util/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 2d4d125

Please sign in to comment.