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:
parent
afe6da235b
commit
4f6542ceaa
4 changed files with 112 additions and 16 deletions
59
src/lib.rs
59
src/lib.rs
|
|
@ -10,13 +10,31 @@ extern crate core;
|
|||
mod cg;
|
||||
#[cfg(target_os = "redox")]
|
||||
mod orbital;
|
||||
#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "freebsd")))]
|
||||
#[cfg(all(
|
||||
feature = "wayland",
|
||||
any(
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
)
|
||||
))]
|
||||
mod wayland;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
mod web;
|
||||
#[cfg(target_os = "windows")]
|
||||
mod win32;
|
||||
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "freebsd")))]
|
||||
#[cfg(all(
|
||||
feature = "x11",
|
||||
any(
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
)
|
||||
))]
|
||||
mod x11;
|
||||
|
||||
mod error;
|
||||
|
|
@ -66,9 +84,9 @@ macro_rules! make_dispatch {
|
|||
}
|
||||
|
||||
make_dispatch! {
|
||||
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "freebsd")))]
|
||||
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd")))]
|
||||
X11(x11::X11Impl),
|
||||
#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "freebsd")))]
|
||||
#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd")))]
|
||||
Wayland(wayland::WaylandImpl),
|
||||
#[cfg(target_os = "windows")]
|
||||
Win32(win32::Win32Impl),
|
||||
|
|
@ -105,21 +123,48 @@ impl GraphicsContext {
|
|||
raw_display_handle: RawDisplayHandle,
|
||||
) -> Result<Self, SoftBufferError> {
|
||||
let imple: Dispatch = match (raw_window_handle, raw_display_handle) {
|
||||
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "freebsd")))]
|
||||
#[cfg(all(
|
||||
feature = "x11",
|
||||
any(
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
)
|
||||
))]
|
||||
(
|
||||
RawWindowHandle::Xlib(xlib_window_handle),
|
||||
RawDisplayHandle::Xlib(xlib_display_handle),
|
||||
) => Dispatch::X11(unsafe {
|
||||
x11::X11Impl::from_xlib(xlib_window_handle, xlib_display_handle)?
|
||||
}),
|
||||
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "freebsd")))]
|
||||
#[cfg(all(
|
||||
feature = "x11",
|
||||
any(
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
)
|
||||
))]
|
||||
(
|
||||
RawWindowHandle::Xcb(xcb_window_handle),
|
||||
RawDisplayHandle::Xcb(xcb_display_handle),
|
||||
) => Dispatch::X11(unsafe {
|
||||
x11::X11Impl::from_xcb(xcb_window_handle, xcb_display_handle)?
|
||||
}),
|
||||
#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "freebsd")))]
|
||||
#[cfg(all(
|
||||
feature = "wayland",
|
||||
any(
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
)
|
||||
))]
|
||||
(
|
||||
RawWindowHandle::Wayland(wayland_window_handle),
|
||||
RawDisplayHandle::Wayland(wayland_display_handle),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue