Add support and CI tests for BSDs

This adds a fallback using `shm_open`/`shm_unlink` for platforms where
`memfd_create` doesn't exist. This seems to be how this is normally
handled, though it's a bit ugly.

This also builds the wayland/x11 code for NetBSD/OpenBSD/DragonFlyBSD.

Add CI builds for FreeBSD and NetBSD. We would need some kind of
virtualisation though to actually run tests on such targets.

I've tested the `shm_open` logic on Linux, but haven't run it on any
BSDs.
This commit is contained in:
Ian Douglas Scott 2022-12-22 10:13:32 -08:00
parent afe6da235b
commit 4f6542ceaa
4 changed files with 112 additions and 16 deletions

View file

@ -14,7 +14,7 @@ rust-version = "1.60.0"
[features]
default = ["x11", "wayland", "wayland-dlopen"]
wayland = ["wayland-backend", "wayland-client", "nix"]
wayland = ["wayland-backend", "wayland-client", "nix", "fastrand"]
wayland-dlopen = ["wayland-sys/dlopen"]
x11 = ["bytemuck", "x11rb", "x11-dl"]
@ -23,7 +23,7 @@ thiserror = "1.0.30"
raw-window-handle = "0.5.0"
log = "0.4.17"
[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
nix = { version = "0.26.1", optional = true }
wayland-backend = { version = "0.1.0", features = ["client_system"], optional = true }
wayland-client = { version = "0.30.0", optional = true }
@ -32,6 +32,9 @@ bytemuck = { version = "1.12.3", optional = true }
x11-dl = { version = "2.19.1", optional = true }
x11rb = { version = "0.11.0", features = ["allow-unsafe-code", "dl-libxcb"], optional = true }
[target.'cfg(any(target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
fastrand = { version = "1.8.0", optional = true }
[target.'cfg(target_os = "windows")'.dependencies.windows-sys]
version = "0.42.0"
features = ["Win32_Graphics_Gdi", "Win32_UI_WindowsAndMessaging", "Win32_Foundation"]