diff --git a/espanso-mac-utils/src/ffi.rs b/espanso-mac-utils/src/ffi.rs index e590558..3491298 100644 --- a/espanso-mac-utils/src/ffi.rs +++ b/espanso-mac-utils/src/ffi.rs @@ -17,8 +17,10 @@ * along with espanso. If not, see . */ +#[cfg(target_os = "macos")] use std::os::raw::c_char; +#[cfg(target_os = "macos")] #[link(name = "espansomacutils", kind = "static")] extern "C" { pub fn mac_utils_get_secure_input_process(pid: *mut i64) -> i32; diff --git a/espanso-mac-utils/src/lib.rs b/espanso-mac-utils/src/lib.rs index cc879d7..8e5b57c 100644 --- a/espanso-mac-utils/src/lib.rs +++ b/espanso-mac-utils/src/lib.rs @@ -17,15 +17,18 @@ * along with espanso. If not, see . */ +#[cfg(target_os = "macos")] use std::{ffi::CStr, os::raw::c_char}; #[macro_use] +#[cfg(target_os = "macos")] extern crate lazy_static; mod ffi; /// Check whether an application is currently holding the Secure Input. /// Return None if no application has claimed SecureInput, its PID otherwise. +#[cfg(target_os = "macos")] pub fn get_secure_input_pid() -> Option { unsafe { let mut pid: i64 = -1; @@ -41,6 +44,7 @@ pub fn get_secure_input_pid() -> Option { /// Check whether an application is currently holding the Secure Input. /// Return None if no application has claimed SecureInput, Some((AppName, AppPath)) otherwise. +#[cfg(target_os = "macos")] pub fn get_secure_input_application() -> Option<(String, String)> { unsafe { let pid = get_secure_input_pid(); @@ -73,6 +77,7 @@ pub fn get_secure_input_application() -> Option<(String, String)> { } } +#[cfg(target_os = "macos")] fn get_app_name_from_path(path: &str) -> Option { use regex::Regex; @@ -89,6 +94,7 @@ fn get_app_name_from_path(path: &str) -> Option { } #[cfg(test)] +#[cfg(target_os = "macos")] mod tests { use super::*;