diff --git a/Cargo.toml b/Cargo.toml index 76f2eec..1c72d97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ tracing = { version = "0.1.41", default-features = false } bytemuck = "1.12.3" ndk = "0.9.0" -[target.'cfg(all(unix, not(any(target_vendor = "apple", target_os = "android", target_os = "redox"))))'.dependencies] +[target.'cfg(not(any(target_os = "android", target_vendor = "apple", target_os = "redox", target_family = "wasm", target_os = "windows")))'.dependencies] as-raw-xcb-connection = { version = "1.0.0", optional = true } bytemuck = { version = "1.12.3", optional = true } drm = { version = "0.14.1", default-features = false, optional = true } @@ -130,9 +130,6 @@ features = [ [target.'cfg(target_os = "redox")'.dependencies] redox_syscall = "0.5" -[build-dependencies] -cfg_aliases = "0.2.0" - [dev-dependencies] colorous = "1.0.12" criterion = { version = "0.4.0", default-features = false, features = [ @@ -158,7 +155,7 @@ rayon = "1.5.1" [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen-test = "0.3" -[target.'cfg(all(unix, not(any(target_vendor = "apple", target_os = "android", target_os = "redox"))))'.dev-dependencies] +[target.'cfg(not(any(target_os = "android", target_vendor = "apple", target_os = "redox", target_family = "wasm", target_os = "windows")))'.dev-dependencies] rustix = { version = "1.0.1", features = ["event"] } [workspace] diff --git a/build.rs b/build.rs deleted file mode 100644 index 9f046eb..0000000 --- a/build.rs +++ /dev/null @@ -1,13 +0,0 @@ -fn main() { - println!("cargo:rustc-check-cfg=cfg(free_unix)"); - println!("cargo:rustc-check-cfg=cfg(kms_platform)"); - println!("cargo:rustc-check-cfg=cfg(x11_platform)"); - println!("cargo:rustc-check-cfg=cfg(wayland_platform)"); - - cfg_aliases::cfg_aliases! { - free_unix: { all(unix, not(any(target_vendor = "apple", target_os = "android", target_os = "redox"))) }, - kms_platform: { all(feature = "kms", free_unix, not(target_arch = "wasm32")) }, - x11_platform: { all(feature = "x11", free_unix, not(target_arch = "wasm32")) }, - wayland_platform: { all(feature = "wayland", free_unix, not(target_arch = "wasm32")) }, - } -} diff --git a/examples/drm.rs b/examples/drm.rs index 18bd61e..9d1b36e 100644 --- a/examples/drm.rs +++ b/examples/drm.rs @@ -1,6 +1,15 @@ //! Example of using softbuffer with drm-rs. -#[cfg(kms_platform)] +#[cfg(all( + feature = "kms", + not(any( + target_os = "android", + target_vendor = "apple", + target_os = "redox", + target_family = "wasm", + target_os = "windows" + )) +))] mod imple { use drm::control::{connector, Device as CtrlDevice, Event, ModeTypeFlags, PlaneType}; use drm::Device; @@ -210,7 +219,16 @@ mod imple { impl CtrlDevice for Card {} } -#[cfg(not(kms_platform))] +#[cfg(not(all( + feature = "kms", + not(any( + target_os = "android", + target_vendor = "apple", + target_os = "redox", + target_family = "wasm", + target_os = "windows" + )) +)))] mod imple { pub(super) fn entry() -> Result<(), Box> { eprintln!("This example requires the `kms` feature."); diff --git a/examples/libxcb.rs b/examples/libxcb.rs index 53efc5d..03a5593 100644 --- a/examples/libxcb.rs +++ b/examples/libxcb.rs @@ -1,6 +1,15 @@ //! Example of using `softbuffer` with `libxcb`. -#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "freebsd")))] +#[cfg(all( + feature = "x11", + not(any( + target_os = "android", + target_vendor = "apple", + target_os = "redox", + target_family = "wasm", + target_os = "windows" + )) +))] mod example { use raw_window_handle::{ DisplayHandle, RawDisplayHandle, RawWindowHandle, WindowHandle, XcbDisplayHandle, @@ -135,12 +144,30 @@ mod example { } } -#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "freebsd")))] +#[cfg(all( + feature = "x11", + not(any( + target_os = "android", + target_vendor = "apple", + target_os = "redox", + target_family = "wasm", + target_os = "windows" + )) +))] fn main() { example::run(); } -#[cfg(not(all(feature = "x11", any(target_os = "linux", target_os = "freebsd"))))] +#[cfg(not(all( + feature = "x11", + not(any( + target_os = "android", + target_vendor = "apple", + target_os = "redox", + target_family = "wasm", + target_os = "windows" + )) +)))] fn main() { eprintln!("This example requires the `x11` feature to be enabled on a supported platform."); } diff --git a/src/backend_dispatch.rs b/src/backend_dispatch.rs index 5a34a7c..21fe456 100644 --- a/src/backend_dispatch.rs +++ b/src/backend_dispatch.rs @@ -4,8 +4,6 @@ use crate::{backend_interface::*, backends, InitError, Rect, SoftBufferError}; use raw_window_handle::{HasDisplayHandle, HasWindowHandle}; use std::num::NonZeroU32; -#[cfg(any(wayland_platform, x11_platform, kms_platform))] -use std::sync::Arc; /// A macro for creating the enum used to statically dispatch to the platform-specific implementation. macro_rules! make_dispatch { @@ -201,12 +199,39 @@ make_dispatch! { => #[cfg(target_os = "android")] Android(D, backends::android::AndroidImpl, backends::android::BufferImpl<'a, D, W>), - #[cfg(x11_platform)] - X11(Arc>, backends::x11::X11Impl, backends::x11::BufferImpl<'a, D, W>), - #[cfg(wayland_platform)] - Wayland(Arc>, backends::wayland::WaylandImpl, backends::wayland::BufferImpl<'a, D, W>), - #[cfg(kms_platform)] - Kms(Arc>, backends::kms::KmsImpl, backends::kms::BufferImpl<'a, D, W>), + #[cfg(all( + feature = "x11", + not(any( + target_os = "android", + target_vendor = "apple", + target_os = "redox", + target_family = "wasm", + target_os = "windows" + )) + ))] + X11(std::sync::Arc>, backends::x11::X11Impl, backends::x11::BufferImpl<'a, D, W>), + #[cfg(all( + feature = "wayland", + not(any( + target_os = "android", + target_vendor = "apple", + target_os = "redox", + target_family = "wasm", + target_os = "windows" + )) + ))] + Wayland(std::sync::Arc>, backends::wayland::WaylandImpl, backends::wayland::BufferImpl<'a, D, W>), + #[cfg(all( + feature = "kms", + not(any( + target_os = "android", + target_vendor = "apple", + target_os = "redox", + target_family = "wasm", + target_os = "windows" + )) + ))] + Kms(std::sync::Arc>, backends::kms::KmsImpl, backends::kms::BufferImpl<'a, D, W>), #[cfg(target_os = "windows")] Win32(D, backends::win32::Win32Impl, backends::win32::BufferImpl<'a, D, W>), #[cfg(target_vendor = "apple")] diff --git a/src/backends/mod.rs b/src/backends/mod.rs index 703401d..9871163 100644 --- a/src/backends/mod.rs +++ b/src/backends/mod.rs @@ -5,17 +5,44 @@ use raw_window_handle::HasDisplayHandle; pub(crate) mod android; #[cfg(target_vendor = "apple")] pub(crate) mod cg; -#[cfg(kms_platform)] +#[cfg(all( + feature = "kms", + not(any( + target_os = "android", + target_vendor = "apple", + target_os = "redox", + target_family = "wasm", + target_os = "windows" + )) +))] pub(crate) mod kms; #[cfg(target_os = "redox")] pub(crate) mod orbital; -#[cfg(wayland_platform)] +#[cfg(all( + feature = "wayland", + not(any( + target_os = "android", + target_vendor = "apple", + target_os = "redox", + target_family = "wasm", + target_os = "windows" + )) +))] pub(crate) mod wayland; #[cfg(target_arch = "wasm32")] pub(crate) mod web; #[cfg(target_os = "windows")] pub(crate) mod win32; -#[cfg(x11_platform)] +#[cfg(all( + feature = "x11", + not(any( + target_os = "android", + target_vendor = "apple", + target_os = "redox", + target_family = "wasm", + target_os = "windows" + )) +))] pub(crate) mod x11; impl ContextInterface for D {