From 67f54c39beae1388bae228b3374a42546503e3ea Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Fri, 13 Mar 2026 13:44:44 +0100 Subject: [PATCH] fix(ci): restore cross-platform and linux checks --- crates/weft-appd/src/main.rs | 22 +++++++++++++++++++++ crates/weft-appd/src/runtime.rs | 10 ++++++++++ crates/weft-compositor/src/protocols/mod.rs | 3 +++ crates/weft-compositor/src/state.rs | 6 ++++++ crates/weft-file-portal/src/main.rs | 21 ++++++++++++++++++-- 5 files changed, 60 insertions(+), 2 deletions(-) diff --git a/crates/weft-appd/src/main.rs b/crates/weft-appd/src/main.rs index d194538..e08c3e9 100644 --- a/crates/weft-appd/src/main.rs +++ b/crates/weft-appd/src/main.rs @@ -1,11 +1,22 @@ +#![cfg_attr(not(unix), allow(dead_code, unused_imports))] + use std::path::PathBuf; use std::sync::Arc; use anyhow::Context; +#[cfg(unix)] use tokio::io::AsyncWriteExt; use tokio::sync::Mutex; +#[cfg(unix)] mod compositor_client; +#[cfg(not(unix))] +mod compositor_client { + use tokio::sync::mpsc; + use weft_ipc_types::AppdToCompositor; + + pub type CompositorSender = mpsc::Sender; +} mod ipc; mod mount; mod runtime; @@ -149,6 +160,7 @@ async fn main() -> anyhow::Result<()> { run().await } +#[cfg(unix)] async fn run() -> anyhow::Result<()> { let socket_path = appd_socket_path()?; @@ -247,11 +259,18 @@ async fn run() -> anyhow::Result<()> { Ok(()) } +#[cfg(not(unix))] +async fn run() -> anyhow::Result<()> { + anyhow::bail!("weft-appd requires a Unix platform") +} + +#[cfg_attr(not(any(unix, test)), allow(dead_code))] fn session_file_path() -> Option { let runtime_dir = std::env::var("XDG_RUNTIME_DIR").ok()?; Some(PathBuf::from(runtime_dir).join("weft/last-session.json")) } +#[cfg_attr(not(any(unix, test)), allow(dead_code))] async fn save_session(app_ids: Vec) { let Some(path) = session_file_path() else { return; @@ -278,6 +297,7 @@ fn ws_port() -> u16 { .unwrap_or(7410) } +#[cfg_attr(not(any(unix, test)), allow(dead_code))] fn write_ws_port(port: u16) -> anyhow::Result<()> { let runtime_dir = std::env::var("XDG_RUNTIME_DIR").context("XDG_RUNTIME_DIR not set")?; let path = PathBuf::from(runtime_dir).join("weft/appd.wsport"); @@ -288,6 +308,7 @@ fn write_ws_port(port: u16) -> anyhow::Result<()> { Ok(()) } +#[cfg(unix)] async fn handle_connection( stream: tokio::net::UnixStream, registry: Registry, @@ -493,6 +514,7 @@ fn scan_installed_apps() -> Vec { apps } +#[cfg_attr(not(any(unix, test)), allow(dead_code))] fn appd_socket_path() -> anyhow::Result { if let Ok(p) = std::env::var("WEFT_APPD_SOCKET") { return Ok(PathBuf::from(p)); diff --git a/crates/weft-appd/src/runtime.rs b/crates/weft-appd/src/runtime.rs index 09008d0..3958e7b 100644 --- a/crates/weft-appd/src/runtime.rs +++ b/crates/weft-appd/src/runtime.rs @@ -8,6 +8,7 @@ use crate::Registry; use crate::compositor_client::CompositorSender; use crate::ipc::{AppStateKind, Response}; +#[cfg(unix)] pub(crate) async fn spawn_ipc_relay( session_id: u64, socket_path: PathBuf, @@ -58,6 +59,15 @@ pub(crate) async fn spawn_ipc_relay( Some(html_to_wasm_tx) } +#[cfg(not(unix))] +pub(crate) async fn spawn_ipc_relay( + _session_id: u64, + _socket_path: PathBuf, + _broadcast: tokio::sync::broadcast::Sender, +) -> Option> { + None +} + const READY_TIMEOUT: Duration = Duration::from_secs(30); fn systemd_cgroup_available() -> bool { diff --git a/crates/weft-compositor/src/protocols/mod.rs b/crates/weft-compositor/src/protocols/mod.rs index b1a3bad..18922b4 100644 --- a/crates/weft-compositor/src/protocols/mod.rs +++ b/crates/weft-compositor/src/protocols/mod.rs @@ -25,8 +25,11 @@ pub struct WeftShellState { } pub struct WeftShellWindowData { + #[allow(dead_code)] pub app_id: String, + #[allow(dead_code)] pub title: String, + #[allow(dead_code)] pub role: String, pub surface: Option, pub closed: std::sync::atomic::AtomicBool, diff --git a/crates/weft-compositor/src/state.rs b/crates/weft-compositor/src/state.rs index bc06b14..fed2a0f 100644 --- a/crates/weft-compositor/src/state.rs +++ b/crates/weft-compositor/src/state.rs @@ -80,11 +80,17 @@ pub struct WeftCompositorState { pub layer_shell_state: WlrLayerShellState, pub shm_state: ShmState, pub dmabuf_state: DmabufState, + #[allow(dead_code)] pub output_manager_state: OutputManagerState, + #[allow(dead_code)] pub presentation_state: PresentationState, + #[allow(dead_code)] pub text_input_state: TextInputManagerState, + #[allow(dead_code)] pub input_method_state: InputMethodManagerState, + #[allow(dead_code)] pub pointer_constraints_state: PointerConstraintsState, + #[allow(dead_code)] pub cursor_shape_state: CursorShapeManagerState, pub space: Space, diff --git a/crates/weft-file-portal/src/main.rs b/crates/weft-file-portal/src/main.rs index e346511..c8f3ad3 100644 --- a/crates/weft-file-portal/src/main.rs +++ b/crates/weft-file-portal/src/main.rs @@ -1,10 +1,17 @@ +#[cfg(unix)] use std::io::{BufRead, BufReader, Write}; -use std::os::unix::net::{UnixListener, UnixStream}; use std::path::{Path, PathBuf}; + +use serde::{Deserialize, Serialize}; + +#[cfg(unix)] use std::sync::Arc; +#[cfg(unix)] use anyhow::Context; -use serde::{Deserialize, Serialize}; + +#[cfg(unix)] +use std::os::unix::net::{UnixListener, UnixStream}; #[derive(Deserialize)] #[serde(tag = "op", rename_all = "snake_case")] @@ -31,6 +38,7 @@ impl Response { } } +#[cfg(unix)] fn main() -> anyhow::Result<()> { let args: Vec = std::env::args().collect(); if args.len() < 2 { @@ -62,6 +70,12 @@ fn main() -> anyhow::Result<()> { Ok(()) } +#[cfg(not(unix))] +fn main() -> anyhow::Result<()> { + anyhow::bail!("weft-file-portal requires a Unix platform") +} + +#[cfg_attr(not(any(unix, test)), allow(dead_code))] fn parse_allowed(args: &[String]) -> Vec { let mut allowed = Vec::new(); let mut i = 0; @@ -78,6 +92,7 @@ fn parse_allowed(args: &[String]) -> Vec { allowed } +#[cfg_attr(not(any(unix, test)), allow(dead_code))] fn normalize_path(path: &Path) -> PathBuf { use std::path::Component; let mut out = PathBuf::new(); @@ -101,6 +116,7 @@ fn is_allowed(path: &Path, allowed: &[PathBuf]) -> bool { allowed.iter().any(|a| norm.starts_with(a)) } +#[cfg(unix)] fn handle_connection(stream: UnixStream, allowed: &[PathBuf]) { let mut writer = match stream.try_clone() { Ok(s) => s, @@ -134,6 +150,7 @@ fn handle_connection(stream: UnixStream, allowed: &[PathBuf]) { } } +#[cfg_attr(not(any(unix, test)), allow(dead_code))] fn handle_request(req: Request, allowed: &[PathBuf]) -> Response { match req { Request::Read { path } => {