Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

FreeBSD: CI job and X11 drag-and-drop on every non-Apple Unix

Brandon Thomas811b0d884677
diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml
new file mode 100644
index 000000000..6e42fc71e
--- /dev/null
+++ b/.github/workflows/freebsd.yml
@@ -0,0 +1,43 @@
+# Builds and tests the workspace on FreeBSD, inside a FreeBSD VM on a Linux runner
+# (GitHub has no FreeBSD runners). GPU tests skip themselves when the VM has no adapter.
+name: FreeBSD
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+ paths:
+ - Cargo.toml
+ - Cargo.lock
+ - "**/Cargo.toml"
+ - .github/workflows/freebsd.yml
+ workflow_dispatch:
+
+concurrency:
+ group: freebsd-${{ github.ref }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+
+jobs:
+ freebsd:
+ name: FreeBSD 14 (build + test)
+ runs-on: ubuntu-latest
+ timeout-minutes: 180
+ steps:
+ - uses: actions/checkout@v4
+ - name: Build and test in a FreeBSD VM
+ uses: vmactions/freebsd-vm@v1
+ with:
+ release: "14.3"
+ usesh: true
+ mem: 12288
+ prepare: |
+ pkg install -y curl pkgconf cmake python3 libxkbcommon wayland libX11 libXcursor libXrandr libXi libxcb mesa-libs vulkan-loader gtk3 fontconfig freetype2
+ curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal
+ run: |
+ . "$HOME/.cargo/env"
+ rustc --version
+ CARGO_PROFILE_DEV_DEBUG=0 cargo build --workspace --all-targets --locked
+ CARGO_PROFILE_DEV_DEBUG=0 cargo test --workspace --locked
diff --git a/apps/designcraft/Cargo.toml b/apps/designcraft/Cargo.toml
index 649714284..eaacdd328 100644
--- a/apps/designcraft/Cargo.toml
+++ b/apps/designcraft/Cargo.toml
@@ -24,7 +24,7 @@ winresource = "0.1"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rfd = { workspace = true }
-[target.'cfg(target_os = "linux")'.dependencies]
+[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
# The same winit eframe uses: to pick the X11 backend (file drag-and-drop) in main.rs.
winit = { version = "0.30", default-features = false, features = ["x11"] }
diff --git a/apps/designcraft/src/main.rs b/apps/designcraft/src/main.rs
index dc68f0807..d0b9c2e23 100644
--- a/apps/designcraft/src/main.rs
+++ b/apps/designcraft/src/main.rs
@@ -202,7 +202,7 @@ fn main() -> eframe::Result {
// winit has no file drag-and-drop on Wayland (only on X11), so dropping images from the file
// manager showed a "no" cursor. Run through XWayland when it's there; DESIGNCRAFT_WAYLAND=1
// keeps the native Wayland backend.
- #[cfg(target_os = "linux")]
+ #[cfg(all(unix, not(target_os = "macos")))]
if std::env::var_os("DISPLAY").is_some() && std::env::var_os("DESIGNCRAFT_WAYLAND").is_none() {
options.event_loop_builder = Some(Box::new(|b| {
use winit::platform::x11::EventLoopBuilderExtX11;