From 5a973c2454d887380bbcaaad8b45aa884c088243 Mon Sep 17 00:00:00 2001
From: Oliver
Date: Mon, 12 Jan 2026 21:23:24 -0700
Subject: [PATCH] add FreeBSD support
---
Cargo.toml | 2 +-
src/lib.rs | 2 +-
src/native.rs | 6 +++---
src/native/egl.rs | 6 +++---
src/native/module.rs | 6 +++---
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 224bebe17..821f247b2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,7 +21,7 @@ categories = ["rendering::graphics-api"]
# disabled by default
log-impl = []
-[target.'cfg(target_os = "linux")'.dependencies]
+[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
libc = "0.2"
[target.'cfg(windows)'.dependencies]
diff --git a/src/lib.rs b/src/lib.rs
index e7f9d5004..9c159a65c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -462,7 +462,7 @@ pub fn start(conf: conf::Conf, f: F)
where
F: 'static + FnOnce() -> Box,
{
- #[cfg(target_os = "linux")]
+ #[cfg(any(target_os = "linux", target_os = "freebsd"))]
{
let mut f = Some(f);
let f = &mut f;
diff --git a/src/native.rs b/src/native.rs
index f38200360..b3aa89c62 100644
--- a/src/native.rs
+++ b/src/native.rs
@@ -87,10 +87,10 @@ pub trait Clipboard: Send + Sync {
pub mod module;
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub mod linux_x11;
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub mod linux_wayland;
#[cfg(target_os = "android")]
@@ -114,7 +114,7 @@ pub mod macos;
#[cfg(target_os = "ios")]
pub mod ios;
-#[cfg(any(target_os = "android", target_os = "linux"))]
+#[cfg(any(target_os = "android", target_os = "linux", target_os = "freebsd"))]
pub mod egl;
// there is no glGetProcAddr on webgl, so its impossible to make "gl" module work
diff --git a/src/native/egl.rs b/src/native/egl.rs
index 5dc24e27f..e7e3ff85e 100644
--- a/src/native/egl.rs
+++ b/src/native/egl.rs
@@ -1,10 +1,10 @@
#![allow(non_camel_case_types, non_snake_case, dead_code)]
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub type EGLNativeDisplayType = *mut crate::native::linux_x11::libx11::Display;
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub type EGLNativePixmapType = crate::native::linux_x11::libx11::Pixmap;
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub type EGLNativeWindowType = crate::native::linux_x11::libx11::Window;
#[cfg(target_os = "android")]
diff --git a/src/native/module.rs b/src/native/module.rs
index 0b8a36003..a9a3fdd6b 100644
--- a/src/native/module.rs
+++ b/src/native/module.rs
@@ -13,7 +13,7 @@ impl Display for Error {
}
}
-#[cfg(any(target_os = "linux", target_os = "android"))]
+#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
pub mod linux {
use super::Error;
use libc::{dlclose, dlopen, dlsym, RTLD_LAZY, RTLD_LOCAL};
@@ -90,13 +90,13 @@ mod windows {
use std::fmt::Display;
-#[cfg(any(target_os = "linux", target_os = "android"))]
+#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
pub use linux::*;
#[cfg(target_os = "windows")]
pub use windows::Module;
-#[cfg(any(target_os = "linux", target_os = "android"))]
+#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
#[macro_export]
macro_rules! declare_module {
($name:ident,