From 16fd2baba04ec2dac8228b79de207f7ffc4f7737 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Mon, 6 May 2024 07:11:57 +0200 Subject: [PATCH] Use `rustc-check-cfg` (#3682) --- build.rs | 15 +++++++++++++++ src/event_loop.rs | 7 +++++-- src/platform/windows.rs | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index 371e4978..034288e2 100644 --- a/build.rs +++ b/build.rs @@ -21,4 +21,19 @@ fn main() { wayland_platform: { all(feature = "wayland", free_unix, not(redox)) }, orbital_platform: { redox }, } + + println!("cargo:rustc-check-cfg=cfg(android_platform)"); + println!("cargo:rustc-check-cfg=cfg(web_platform)"); + println!("cargo:rustc-check-cfg=cfg(macos_platform)"); + println!("cargo:rustc-check-cfg=cfg(ios_platform)"); + println!("cargo:rustc-check-cfg=cfg(windows_platform)"); + println!("cargo:rustc-check-cfg=cfg(apple)"); + println!("cargo:rustc-check-cfg=cfg(free_unix)"); + println!("cargo:rustc-check-cfg=cfg(redox)"); + + println!("cargo:rustc-check-cfg=cfg(x11_platform)"); + println!("cargo:rustc-check-cfg=cfg(wayland_platform)"); + println!("cargo:rustc-check-cfg=cfg(orbital_platform)"); + + println!("cargo:rustc-check-cfg=cfg(unreleased_changelogs)"); } diff --git a/src/event_loop.rs b/src/event_loop.rs index c0f64d9e..99e72040 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -103,11 +103,14 @@ impl EventLoopBuilder { /// /// [`platform`]: crate::platform #[cfg_attr( - android, + android_platform, doc = "[`.with_android_app(app)`]: \ crate::platform::android::EventLoopBuilderExtAndroid::with_android_app" )] - #[cfg_attr(not(android), doc = "[`.with_android_app(app)`]: #only-available-on-android")] + #[cfg_attr( + not(android_platform), + doc = "[`.with_android_app(app)`]: #only-available-on-android" + )] #[inline] pub fn build(&mut self) -> Result, EventLoopError> { let _span = tracing::debug_span!("winit::EventLoopBuilder::build").entered(); diff --git a/src/platform/windows.rs b/src/platform/windows.rs index bce4637b..5b79771a 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -476,10 +476,10 @@ pub trait WindowAttributesExtWindows { /// the menus look. If you use this, it is recommended that you combine it with /// `with_theme(Some(Theme::Light))` to avoid a jarring effect. #[cfg_attr( - platform_windows, + windows_platform, doc = "[`CreateMenu`]: windows_sys::Win32::UI::WindowsAndMessaging::CreateMenu" )] - #[cfg_attr(not(platform_windows), doc = "[`CreateMenu`]: #only-available-on-windows")] + #[cfg_attr(not(windows_platform), doc = "[`CreateMenu`]: #only-available-on-windows")] fn with_menu(self, menu: HMENU) -> Self; /// This sets `ICON_BIG`. A good ceiling here is 256x256.