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 <ReactorScram@users.noreply.github.com>
Co-authored-by: User <user@Users-MacBook-Pro.local>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
This commit is contained in:
Reactor Scram
2024-03-05 13:52:44 -06:00
committed by GitHub
parent 6419b1d096
commit b94eb4d4c7
12 changed files with 122 additions and 17 deletions

View File

@@ -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"

View File

@@ -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;

View File

@@ -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<Self, Error> {
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<Secret<SecureUrl>, Error> {
futures::future::pending().await
}
}
pub(crate) async fn open(_url: &url::Url) -> Result<(), Error> {
Ok(())
}
pub(crate) fn register() -> Result<(), Error> {
Ok(())
}

View File

@@ -14,6 +14,20 @@ mod imp {
}
}
// Stub only
#[cfg(target_os = "macos")]
mod imp {
use anyhow::Result;
pub(crate) fn check() -> Result<bool> {
Ok(true)
}
pub(crate) fn elevate() -> Result<()> {
unimplemented!()
}
}
#[cfg(target_os = "windows")]
mod imp {
use crate::client::wintun_install;

View File

@@ -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;

View File

@@ -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!()
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<bool> {
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<Self> {
Ok(Self {})
}
pub(crate) fn close(&mut self) -> Result<()> {
Ok(())
}
pub(crate) async fn notified(&self) {
futures::future::pending().await
}
}

View File

@@ -14,6 +14,11 @@ pub fn get() -> Result<Vec<IpAddr>, Error> {
todo!()
}
#[cfg(target_os = "macos")]
pub fn get() -> Result<Vec<IpAddr>, Error> {
todo!()
}
#[cfg(target_os = "windows")]
pub fn get() -> Result<Vec<IpAddr>, Error> {
Ok(ipconfig::get_adapters()?

View File

@@ -65,12 +65,16 @@ const LATEST_RELEASE_API_URL: &str =
/// <https://docs.github.com/en/rest/about-the-rest-api/api-versions?apiVersion=2022-11-28>
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";

View File

@@ -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;