Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add freebsd target #2249

Merged
merged 4 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion druid-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ core-graphics = "0.22.0"
foreign-types = "0.3.2"
bitflags = "1.2.1"

[target.'cfg(any(target_os="linux", target_os="openbsd"))'.dependencies]
[target.'cfg(any(target_os = "freebsd", target_os="linux", target_os="openbsd"))'.dependencies]
ashpd = { version = "0.3.0", optional = true }
# TODO(x11/dependencies): only use feature "xcb" if using X11
cairo-rs = { version = "0.14.0", default_features = false, features = ["xcb"] }
Expand Down
5 changes: 3 additions & 2 deletions druid-shell/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ fn main() {
use std::env;
use std::path::PathBuf;

if env::var("CARGO_CFG_TARGET_OS").unwrap() != "linux"
&& env::var("CARGO_CFG_TARGET_OS").unwrap() != "openbsd"
if env::var("CARGO_CFG_TARGET_OS").unwrap() != "freebsd"
&& env::var("CARGO_CFG_TARGET_OS").unwrap() != "linux"
&& env::var("CARGO_CFG_TARGET_OS").unwrap() != "openbsd"
{
return;
}
Expand Down
18 changes: 9 additions & 9 deletions druid-shell/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,36 @@ pub use mac::*;
#[cfg(target_os = "macos")]
pub(crate) mod shared;

#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "openbsd")))]
#[cfg(all(feature = "x11", any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")))]
mod x11;
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "openbsd")))]
#[cfg(all(feature = "x11", any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")))]
pub use x11::*;
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "openbsd")))]
#[cfg(all(feature = "x11", any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")))]
pub(crate) mod shared;

#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "openbsd")))]
#[cfg(all(feature = "wayland", any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")))]
mod wayland;
#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "openbsd")))]
#[cfg(all(feature = "wayland", any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")))]
pub use wayland::*;
#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "openbsd")))]
#[cfg(all(feature = "wayland", any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")))]
pub(crate) mod shared;

#[cfg(all(
not(feature = "x11"),
not(feature = "wayland"),
any(target_os = "linux", target_os = "openbsd")
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
))]
mod gtk;
#[cfg(all(
not(feature = "x11"),
not(feature = "wayland"),
any(target_os = "linux", target_os = "openbsd")
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
))]
pub use self::gtk::*;
#[cfg(all(
not(feature = "x11"),
not(feature = "wayland"),
any(target_os = "linux", target_os = "openbsd")
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
))]
pub(crate) mod shared;

Expand Down
4 changes: 2 additions & 2 deletions druid-shell/src/backend/shared/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use keyboard_types::{Code, Location};
#[cfg(any(
all(
any(feature = "x11", feature = "wayland"),
any(target_os = "linux", target_os = "openbsd")
any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")
),
target_os = "macos"
))]
Expand Down Expand Up @@ -57,7 +57,7 @@ pub fn code_to_location(code: Code) -> Location {
}
}

#[cfg(any(target_os = "linux", target_os = "openbsd"))]
#[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "openbsd"))]
/// Map hardware keycode to code.
///
/// In theory, the hardware keycode is device dependent, but in
Expand Down
4 changes: 2 additions & 2 deletions druid-shell/src/backend/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
//! Logic that is shared by more than one backend.

cfg_if::cfg_if! {
if #[cfg(any(target_os = "macos", target_os = "linux", target_os = "openbsd"))] {
if #[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "linux", target_os = "openbsd"))] {
mod keyboard;
pub use keyboard::*;
}
}
cfg_if::cfg_if! {
if #[cfg(all(target_os = "linux", any(feature = "x11", feature = "wayland")))] {
if #[cfg(all(target_os = "freebsd", target_os = "linux", any(feature = "x11", feature = "wayland")))] {
nunotexbsd marked this conversation as resolved.
Show resolved Hide resolved
mod timer;
pub(crate) use timer::*;
pub(crate) mod xkb;
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ cfg_if::cfg_if! {
} else {
impl ClipboardFormat {
cfg_if::cfg_if! {
if #[cfg(any(target_os = "linux", target_os = "openbsd"))] {
if #[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "openbsd"))] {
// trial and error; this is the most supported string type for gtk?
pub const TEXT: &'static str = "UTF8_STRING";
} else {
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct FileInfo {

/// Type of file dialog.
#[cfg(not(any(
all(feature = "x11", any(target_os = "linux", target_os = "openbsd")),
all(feature = "x11", any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")),
feature = "wayland"
)))]
#[derive(Clone, Copy, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// Rename `gtk_rs` back to `gtk`.
// This allows us to use `gtk` as the feature name.
// The `target_os` requirement is there to exclude anything `wasm` like.
#[cfg(all(any(target_os = "linux", target_os = "openbsd"), feature = "gtk"))]
#[cfg(all(any(target_os = "freebsd", target_os = "linux", target_os = "openbsd"), feature = "gtk"))]
extern crate gtk_rs as gtk;

// Reexport the version of `image` we are using.
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

//! Platorm specific extensions.

#[cfg(any(doc, any(target_os = "linux", target_os = "openbsd")))]
#[cfg(any(doc, any(target_os = "freebsd", target_os = "linux", target_os = "openbsd")))]
pub mod linux;

#[cfg(any(doc, target_os = "macos"))]
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/markdown_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ fn make_menu<T: Data>(_window_id: Option<WindowId>, _app_state: &AppState, _env:
{
base = base.entry(druid::platform_menus::mac::application::default())
}
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "openbsd"))]
#[cfg(any(target_os = "windows", target_os = "freebsd", target_os = "linux", target_os = "openbsd"))]
{
base = base.entry(druid::platform_menus::win::file::default());
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/multiwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ fn make_menu(_: Option<WindowId>, state: &State, _: &Env) -> Menu<State> {
{
base = druid::platform_menus::mac::menu_bar();
}
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "openbsd"))]
#[cfg(any(target_os = "windows", target_os = "freebsd", target_os = "linux", target_os = "openbsd"))]
{
base = base.entry(druid::platform_menus::win::file::default());
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn make_menu<T: Data>(_window: Option<WindowId>, _data: &AppState, _env: &Env) -
{
base = base.entry(druid::platform_menus::mac::application::default())
}
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "openbsd"))]
#[cfg(any(target_os = "windows", target_os = "freebsd", target_os = "linux", target_os = "openbsd"))]
{
base = base.entry(druid::platform_menus::win::file::default());
}
Expand Down
2 changes: 1 addition & 1 deletion druid/src/menu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl<T: Data> MenuManager<T> {
#[cfg(target_os = "macos")]
return Some(MenuManager::new(|_, _, _| sys::mac::menu_bar()));

#[cfg(any(target_os = "windows", target_os = "linux", target_os = "openbsd"))]
#[cfg(any(target_os = "windows", target_os = "freebsd", target_os = "linux", target_os = "openbsd"))]
return None;

// we want to explicitly handle all platforms; log if a platform is missing.
Expand Down
1 change: 1 addition & 0 deletions druid/src/widget/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use super::LabelText;

const CURSOR_BLINK_DURATION: Duration = Duration::from_millis(500);
const MAC_OR_LINUX_OR_OBSD: bool = cfg!(any(
target_os = "freebsd",
target_os = "macos",
target_os = "linux",
target_os = "openbsd"
Expand Down