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

Fix clippy lint mismatched_target_os #290

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 15 additions & 10 deletions surfman/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,26 @@ fn main() {
// Setup aliases for #[cfg] checks
cfg_aliases! {
// Platforms
windows: { target_os = "windows" },
macos: { target_os = "macos" },
android: { target_os = "android" },
// TODO: is `target_os = "linux"` the same as the following check?
linux: { all(unix, not(any(macos, android))) },
android_platform: { target_os = "android" },
web_platform: { all(target_family = "wasm", target_os = "unknown") },
macos_platform: { target_os = "macos" },
ios_platform: { target_os = "ios" },
windows_platform: { target_os = "windows" },
apple: { any(target_os = "ios", target_os = "macos") },
free_unix: { all(unix, not(apple), not(android_platform), not(target_os = "emscripten")) },

// Native displays.
x11_platform: { all(free_unix, feature = "sm-x11") },
wayland_platform: { all(free_unix) },

// Features:
// Here we collect the features that are only valid on certain platforms and
// we add aliases that include checks for the correct platform.
angle: { all(windows, feature = "sm-angle") },
angle_builtin: { all(windows, feature = "sm-angle-builtin") },
angle_default: { all(windows, feature = "sm-angle-default") },
no_wgl: { all(windows, feature = "sm-no-wgl") },
wayland_default: { all(linux, feature = "sm-wayland-default") },
x11: { all(linux, feature = "sm-x11") },
angle_builtin: { all(windows_platform, feature = "sm-angle-builtin") },
angle_default: { all(windows_platform, feature = "sm-angle-default") },
no_wgl: { all(windows_platform, feature = "sm-no-wgl") },
wayland_default: { all(wayland_platform, any(not(x11_platform), feature = "sm-wayland-default")) },
}

let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion surfman/src/platform/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
//! Backends that are not specific to any operating system.

#[cfg(any(android, angle, linux))]
#[cfg(any(android_platform, angle, free_unix))]
pub(crate) mod egl;

pub mod multi;
18 changes: 9 additions & 9 deletions surfman/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@

pub mod generic;

#[cfg(android)]
#[cfg(android_platform)]
pub mod android;
#[cfg(android)]
#[cfg(android_platform)]
pub use android as default;

#[cfg(macos)]
#[cfg(macos_platform)]
pub mod macos;
#[cfg(macos)]
#[cfg(macos_platform)]
pub use macos::cgl as default;
#[cfg(macos)]
#[cfg(macos_platform)]
pub use macos::system;

#[cfg(linux)]
#[cfg(free_unix)]
pub mod unix;
#[cfg(linux)]
#[cfg(free_unix)]
pub use unix::default;

#[cfg(windows)]
#[cfg(windows_platform)]
pub mod windows;
#[cfg(angle_default)]
pub use windows::angle as default;
#[cfg(all(windows, not(angle_default)))]
#[cfg(all(windows_platform, not(angle_default)))]
pub use windows::wgl as default;
13 changes: 6 additions & 7 deletions surfman/src/platform/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
//
//! Backends specific to Unix-like systems, particularly Linux.

// The default when x11 is enabled
#[cfg(x11)]
// The default when x11 is enabled, and wayland default is not explicitly selected.
#[cfg(all(x11_platform, not(wayland_default)))]
pub mod default;

// The default when x11 is not enabled
#[cfg(not(x11))]
#[cfg(wayland_default)]
pub use wayland as default;

#[cfg(linux)]
#[cfg(free_unix)]
pub mod generic;

#[cfg(linux)]
#[cfg(wayland_platform)]
pub mod wayland;
#[cfg(x11)]
#[cfg(x11_platform)]
pub mod x11;