Skip to content

Commit 3160b5c

Browse files
nunotexbsdpanekj
andauthored
add freebsd target (#2249)
Co-authored-by: Jakub Panek <me@panekj.dev>
1 parent 79eb774 commit 3160b5c

File tree

14 files changed

+72
-23
lines changed

14 files changed

+72
-23
lines changed

druid-shell/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ core-graphics = "0.22.0"
9797
foreign-types = "0.3.2"
9898
bitflags = "1.2.1"
9999

100-
[target.'cfg(any(target_os="linux", target_os="openbsd"))'.dependencies]
100+
[target.'cfg(any(target_os = "freebsd", target_os="linux", target_os="openbsd"))'.dependencies]
101101
ashpd = { version = "0.3.0", optional = true }
102102
# TODO(x11/dependencies): only use feature "xcb" if using X11
103103
cairo-rs = { version = "0.14.0", default_features = false, features = ["xcb"] }

druid-shell/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ fn main() {
77
use std::env;
88
use std::path::PathBuf;
99

10-
if env::var("CARGO_CFG_TARGET_OS").unwrap() != "linux"
10+
if env::var("CARGO_CFG_TARGET_OS").unwrap() != "freebsd"
11+
&& env::var("CARGO_CFG_TARGET_OS").unwrap() != "linux"
1112
&& env::var("CARGO_CFG_TARGET_OS").unwrap() != "openbsd"
1213
{
1314
return;

druid-shell/src/backend/mod.rs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,54 @@ pub use mac::*;
2828
#[cfg(target_os = "macos")]
2929
pub(crate) mod shared;
3030

31-
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "openbsd")))]
31+
#[cfg(all(
32+
feature = "x11",
33+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
34+
))]
3235
mod x11;
33-
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "openbsd")))]
36+
#[cfg(all(
37+
feature = "x11",
38+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
39+
))]
3440
pub use x11::*;
35-
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "openbsd")))]
41+
#[cfg(all(
42+
feature = "x11",
43+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
44+
))]
3645
pub(crate) mod shared;
3746

38-
#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "openbsd")))]
47+
#[cfg(all(
48+
feature = "wayland",
49+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
50+
))]
3951
mod wayland;
40-
#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "openbsd")))]
52+
#[cfg(all(
53+
feature = "wayland",
54+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
55+
))]
4156
pub use wayland::*;
42-
#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "openbsd")))]
57+
#[cfg(all(
58+
feature = "wayland",
59+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
60+
))]
4361
pub(crate) mod shared;
4462

4563
#[cfg(all(
4664
not(feature = "x11"),
4765
not(feature = "wayland"),
48-
any(target_os = "linux", target_os = "openbsd")
66+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
4967
))]
5068
mod gtk;
5169
#[cfg(all(
5270
not(feature = "x11"),
5371
not(feature = "wayland"),
54-
any(target_os = "linux", target_os = "openbsd")
72+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
5573
))]
5674
pub use self::gtk::*;
5775
#[cfg(all(
5876
not(feature = "x11"),
5977
not(feature = "wayland"),
60-
any(target_os = "linux", target_os = "openbsd")
78+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
6179
))]
6280
pub(crate) mod shared;
6381

druid-shell/src/backend/shared/keyboard.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use keyboard_types::{Code, Location};
2020
#[cfg(any(
2121
all(
2222
any(feature = "x11", feature = "wayland"),
23-
any(target_os = "linux", target_os = "openbsd")
23+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
2424
),
2525
target_os = "macos"
2626
))]
@@ -57,7 +57,7 @@ pub fn code_to_location(code: Code) -> Location {
5757
}
5858
}
5959

60-
#[cfg(any(target_os = "linux", target_os = "openbsd"))]
60+
#[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "openbsd"))]
6161
/// Map hardware keycode to code.
6262
///
6363
/// In theory, the hardware keycode is device dependent, but in

druid-shell/src/backend/shared/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
//! Logic that is shared by more than one backend.
1616
1717
cfg_if::cfg_if! {
18-
if #[cfg(any(target_os = "macos", target_os = "linux", target_os = "openbsd"))] {
18+
if #[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "linux", target_os = "openbsd"))] {
1919
mod keyboard;
2020
pub use keyboard::*;
2121
}
2222
}
2323
cfg_if::cfg_if! {
24-
if #[cfg(all(target_os = "linux", any(feature = "x11", feature = "wayland")))] {
24+
if #[cfg(all(any(target_os = "freebsd", target_os = "linux"), any(feature = "x11", feature = "wayland")))] {
2525
mod timer;
2626
pub(crate) use timer::*;
2727
pub(crate) mod xkb;

druid-shell/src/clipboard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ cfg_if::cfg_if! {
226226
} else {
227227
impl ClipboardFormat {
228228
cfg_if::cfg_if! {
229-
if #[cfg(any(target_os = "linux", target_os = "openbsd"))] {
229+
if #[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "openbsd"))] {
230230
// trial and error; this is the most supported string type for gtk?
231231
pub const TEXT: &'static str = "UTF8_STRING";
232232
} else {

druid-shell/src/dialog.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ pub struct FileInfo {
3838

3939
/// Type of file dialog.
4040
#[cfg(not(any(
41-
all(feature = "x11", any(target_os = "linux", target_os = "openbsd")),
41+
all(
42+
feature = "x11",
43+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
44+
),
4245
feature = "wayland"
4346
)))]
4447
#[derive(Clone, Copy, PartialEq, Eq)]

druid-shell/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
// Rename `gtk_rs` back to `gtk`.
3939
// This allows us to use `gtk` as the feature name.
4040
// The `target_os` requirement is there to exclude anything `wasm` like.
41-
#[cfg(all(any(target_os = "linux", target_os = "openbsd"), feature = "gtk"))]
41+
#[cfg(all(
42+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd"),
43+
feature = "gtk"
44+
))]
4245
extern crate gtk_rs as gtk;
4346

4447
// Reexport the version of `image` we are using.

druid-shell/src/platform/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
//! Platorm specific extensions.
1616
17-
#[cfg(any(doc, any(target_os = "linux", target_os = "openbsd")))]
17+
#[cfg(any(
18+
doc,
19+
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
20+
))]
1821
pub mod linux;
1922

2023
#[cfg(any(doc, target_os = "macos"))]

druid/examples/markdown_preview.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,12 @@ fn make_menu<T: Data>(_window_id: Option<WindowId>, _app_state: &AppState, _env:
239239
{
240240
base = base.entry(druid::platform_menus::mac::application::default())
241241
}
242-
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "openbsd"))]
242+
#[cfg(any(
243+
target_os = "windows",
244+
target_os = "freebsd",
245+
target_os = "linux",
246+
target_os = "openbsd"
247+
))]
243248
{
244249
base = base.entry(druid::platform_menus::win::file::default());
245250
}

0 commit comments

Comments
 (0)