From b94eb4d4c77055b572e635f240a2dd7f038d1d5a Mon Sep 17 00:00:00 2001 From: Reactor Scram Date: Tue, 5 Mar 2024 13:52:44 -0600 Subject: [PATCH] chore: make stub of the Tauri client for macOS (#3977) This would allow me to fix compile / check / fmt errors from macOS CI runners locally, e.g. https://github.com/firezone/firezone/pull/3920#discussion_r1513357337 It can't sign in or start connlib, but it shows the GUI ![image](https://github.com/firezone/firezone/assets/13400041/5307b66e-9874-4fe5-a6a6-43082dd6e385) --------- Signed-off-by: Reactor Scram Co-authored-by: User Co-authored-by: Jamil --- rust/gui-client/src-tauri/Cargo.toml | 5 +++ .../src-tauri/src/client/deep_link.rs | 5 +++ .../src-tauri/src/client/deep_link/macos.rs | 27 ++++++++++++++++ .../src-tauri/src/client/elevation.rs | 14 +++++++++ rust/gui-client/src-tauri/src/client/gui.rs | 5 +++ .../src-tauri/src/client/gui/os_macos.rs | 17 ++++++++++ .../src-tauri/src/client/known_dirs.rs | 2 +- .../src-tauri/src/client/network_changes.rs | 4 +++ .../src/client/network_changes/macos.rs | 31 +++++++++++++++++++ .../src-tauri/src/client/resolvers.rs | 5 +++ .../src-tauri/src/client/updates.rs | 8 +++-- rust/gui-client/src-tauri/src/main.rs | 16 ++-------- 12 files changed, 122 insertions(+), 17 deletions(-) create mode 100644 rust/gui-client/src-tauri/src/client/deep_link/macos.rs create mode 100644 rust/gui-client/src-tauri/src/client/gui/os_macos.rs create mode 100644 rust/gui-client/src-tauri/src/client/network_changes/macos.rs diff --git a/rust/gui-client/src-tauri/Cargo.toml b/rust/gui-client/src-tauri/Cargo.toml index 28cf12334..3876cbd3f 100644 --- a/rust/gui-client/src-tauri/Cargo.toml +++ b/rust/gui-client/src-tauri/Cargo.toml @@ -57,6 +57,11 @@ dirs = "5.0.1" # Used for infinite `pending` on not-yet-implemented functions futures = "0.3.30" +[target.'cfg(target_os = "macos")'.dependencies] +dirs = "5.0.1" +# Used for infinite `pending` on not-implemented functions +futures = "0.3.30" + [target.'cfg(target_os = "windows")'.dependencies] tauri-winrt-notification = "0.1.3" windows-implement = "0.53.0" diff --git a/rust/gui-client/src-tauri/src/client/deep_link.rs b/rust/gui-client/src-tauri/src/client/deep_link.rs index 3d110b3ce..ee2a2d7e9 100644 --- a/rust/gui-client/src-tauri/src/client/deep_link.rs +++ b/rust/gui-client/src-tauri/src/client/deep_link.rs @@ -11,6 +11,11 @@ pub(crate) const FZ_SCHEME: &str = "firezone-fd0020211111"; #[path = "deep_link/linux.rs"] mod imp; +// Stub only +#[cfg(target_os = "macos")] +#[path = "deep_link/macos.rs"] +mod imp; + #[cfg(target_os = "windows")] #[path = "deep_link/windows.rs"] mod imp; diff --git a/rust/gui-client/src-tauri/src/client/deep_link/macos.rs b/rust/gui-client/src-tauri/src/client/deep_link/macos.rs new file mode 100644 index 000000000..0169a2a5c --- /dev/null +++ b/rust/gui-client/src-tauri/src/client/deep_link/macos.rs @@ -0,0 +1,27 @@ +//! Placeholder + +use super::Error; +use connlib_shared::control::SecureUrl; +use secrecy::Secret; + +pub(crate) struct Server {} + +impl Server { + pub(crate) fn new() -> Result { + tracing::warn!("This is not the actual Mac client"); + tracing::trace!(scheme = super::FZ_SCHEME, "prevents dead code warning"); + Ok(Self {}) + } + + pub(crate) async fn accept(self) -> Result, Error> { + futures::future::pending().await + } +} + +pub(crate) async fn open(_url: &url::Url) -> Result<(), Error> { + Ok(()) +} + +pub(crate) fn register() -> Result<(), Error> { + Ok(()) +} diff --git a/rust/gui-client/src-tauri/src/client/elevation.rs b/rust/gui-client/src-tauri/src/client/elevation.rs index cd7739514..8422a5a08 100644 --- a/rust/gui-client/src-tauri/src/client/elevation.rs +++ b/rust/gui-client/src-tauri/src/client/elevation.rs @@ -14,6 +14,20 @@ mod imp { } } +// Stub only +#[cfg(target_os = "macos")] +mod imp { + use anyhow::Result; + + pub(crate) fn check() -> Result { + Ok(true) + } + + pub(crate) fn elevate() -> Result<()> { + unimplemented!() + } +} + #[cfg(target_os = "windows")] mod imp { use crate::client::wintun_install; diff --git a/rust/gui-client/src-tauri/src/client/gui.rs b/rust/gui-client/src-tauri/src/client/gui.rs index 2c7cc7702..9e8726630 100644 --- a/rust/gui-client/src-tauri/src/client/gui.rs +++ b/rust/gui-client/src-tauri/src/client/gui.rs @@ -25,6 +25,11 @@ mod system_tray_menu; #[path = "gui/os_linux.rs"] mod os; +// Stub only +#[cfg(target_os = "macos")] +#[path = "gui/os_macos.rs"] +mod os; + #[cfg(target_os = "windows")] #[path = "gui/os_windows.rs"] mod os; diff --git a/rust/gui-client/src-tauri/src/client/gui/os_macos.rs b/rust/gui-client/src-tauri/src/client/gui/os_macos.rs new file mode 100644 index 000000000..bb5125171 --- /dev/null +++ b/rust/gui-client/src-tauri/src/client/gui/os_macos.rs @@ -0,0 +1,17 @@ +//! This file is a stub only to do Tauri UI dev natively on a Mac. +use super::{ControllerRequest, CtlrTx, Error}; + +/// Show a notification in the bottom right of the screen +pub(crate) fn show_notification(_title: &str, _body: &str) -> Result<(), Error> { + unimplemented!() +} + +/// Show a notification that signals `Controller` when clicked +pub(crate) fn show_clickable_notification( + _title: &str, + _body: &str, + _tx: CtlrTx, + _req: ControllerRequest, +) -> Result<(), Error> { + unimplemented!() +} diff --git a/rust/gui-client/src-tauri/src/client/known_dirs.rs b/rust/gui-client/src-tauri/src/client/known_dirs.rs index 0ae032e07..df08567f8 100644 --- a/rust/gui-client/src-tauri/src/client/known_dirs.rs +++ b/rust/gui-client/src-tauri/src/client/known_dirs.rs @@ -9,7 +9,7 @@ pub(crate) use imp::{device_id, logs, runtime, session, settings}; -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "macos"))] mod imp { use connlib_shared::BUNDLE_ID; use std::path::PathBuf; diff --git a/rust/gui-client/src-tauri/src/client/network_changes.rs b/rust/gui-client/src-tauri/src/client/network_changes.rs index 1d59fecd7..af3ed8585 100644 --- a/rust/gui-client/src-tauri/src/client/network_changes.rs +++ b/rust/gui-client/src-tauri/src/client/network_changes.rs @@ -2,6 +2,10 @@ #[path = "network_changes/linux.rs"] mod imp; +#[cfg(target_os = "macos")] +#[path = "network_changes/macos.rs"] +mod imp; + #[cfg(target_os = "windows")] #[path = "network_changes/windows.rs"] mod imp; diff --git a/rust/gui-client/src-tauri/src/client/network_changes/macos.rs b/rust/gui-client/src-tauri/src/client/network_changes/macos.rs new file mode 100644 index 000000000..96b60cbf2 --- /dev/null +++ b/rust/gui-client/src-tauri/src/client/network_changes/macos.rs @@ -0,0 +1,31 @@ +//! Placeholder + +use anyhow::Result; + +#[derive(thiserror::Error, Debug)] +pub(crate) enum Error {} + +pub(crate) fn run_debug() -> Result<()> { + unimplemented!() +} + +pub(crate) fn check_internet() -> Result { + tracing::error!("This is not the real macOS client, so `network_changes` is not implemented"); + Ok(true) +} + +pub(crate) struct Worker {} + +impl Worker { + pub(crate) fn new() -> Result { + Ok(Self {}) + } + + pub(crate) fn close(&mut self) -> Result<()> { + Ok(()) + } + + pub(crate) async fn notified(&self) { + futures::future::pending().await + } +} diff --git a/rust/gui-client/src-tauri/src/client/resolvers.rs b/rust/gui-client/src-tauri/src/client/resolvers.rs index 2f217c60f..3f4582384 100644 --- a/rust/gui-client/src-tauri/src/client/resolvers.rs +++ b/rust/gui-client/src-tauri/src/client/resolvers.rs @@ -14,6 +14,11 @@ pub fn get() -> Result, Error> { todo!() } +#[cfg(target_os = "macos")] +pub fn get() -> Result, Error> { + todo!() +} + #[cfg(target_os = "windows")] pub fn get() -> Result, Error> { Ok(ipconfig::get_adapters()? diff --git a/rust/gui-client/src-tauri/src/client/updates.rs b/rust/gui-client/src-tauri/src/client/updates.rs index 61d0c3a35..b3466ea50 100644 --- a/rust/gui-client/src-tauri/src/client/updates.rs +++ b/rust/gui-client/src-tauri/src/client/updates.rs @@ -65,12 +65,16 @@ const LATEST_RELEASE_API_URL: &str = /// const GITHUB_API_VERSION: &str = "2022-11-28"; -/// The name of the Windows MSI asset. +/// The name of the Windows MSI / Linux AppImage or deb asset. /// -/// This ultimately comes from `cd.yml`, `git grep WCPYPXZF` +/// These ultimately come from `cd.yml`, `git grep WCPYPXZF` #[cfg(target_os = "linux")] const ASSET_NAME: &str = "firezone-linux-gui-client_amd64.AppImage"; +/// Unused - The Tauri client is not supported for macOS +#[cfg(target_os = "macos")] +const ASSET_NAME: &str = "firezone-mac-unused-client_aarch64.dmg"; + #[cfg(target_os = "windows")] const ASSET_NAME: &str = "firezone-windows-client-x64.msi"; diff --git a/rust/gui-client/src-tauri/src/main.rs b/rust/gui-client/src-tauri/src/main.rs index ceb332524..55636c3ec 100644 --- a/rust/gui-client/src-tauri/src/main.rs +++ b/rust/gui-client/src-tauri/src/main.rs @@ -3,20 +3,8 @@ // Prevents additional console window on Windows in release, DO NOT REMOVE!! #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] +mod client; + fn main() -> anyhow::Result<()> { client::run() } - -#[cfg(target_os = "linux")] -mod client; - -#[cfg(target_os = "macos")] -mod client { - pub(crate) fn run() -> anyhow::Result<()> { - println!("The GUI client does not compile on macOS yet"); - Ok(()) - } -} - -#[cfg(target_os = "windows")] -mod client;