fix(ci): restore cross-platform and linux checks

This commit is contained in:
Marco Allegretti 2026-03-13 13:44:44 +01:00
parent a46af65e6e
commit 67f54c39be
5 changed files with 60 additions and 2 deletions

View file

@ -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<AppdToCompositor>;
}
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<std::path::PathBuf> {
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<String>) {
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<AppInfo> {
apps
}
#[cfg_attr(not(any(unix, test)), allow(dead_code))]
fn appd_socket_path() -> anyhow::Result<PathBuf> {
if let Ok(p) = std::env::var("WEFT_APPD_SOCKET") {
return Ok(PathBuf::from(p));

View file

@ -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<Response>,
) -> Option<tokio::sync::mpsc::Sender<String>> {
None
}
const READY_TIMEOUT: Duration = Duration::from_secs(30);
fn systemd_cgroup_available() -> bool {

View file

@ -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<wayland_server::protocol::wl_surface::WlSurface>,
pub closed: std::sync::atomic::AtomicBool,

View file

@ -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<Window>,

View file

@ -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<String> = 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<PathBuf> {
let mut allowed = Vec::new();
let mut i = 0;
@ -78,6 +92,7 @@ fn parse_allowed(args: &[String]) -> Vec<PathBuf> {
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 } => {