Use cfg aliases throught the code base

Co-authored-by: Mads Marquart <mads@marquart.dk>
This commit is contained in:
Amr Bashir 2022-12-25 09:57:27 +02:00 committed by GitHub
parent 58ec458877
commit 5e77d70245
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 185 additions and 227 deletions

View file

@ -1,8 +1,4 @@
#[cfg(any(
all(target_os = "linux", feature = "x11"),
target_os = "macos",
target_os = "windows"
))]
#[cfg(any(x11_platform, macos_platform, windows_platform))]
fn main() {
use std::collections::HashMap;
@ -78,11 +74,7 @@ fn main() {
})
}
#[cfg(not(any(
all(target_os = "linux", feature = "x11"),
target_os = "macos",
target_os = "windows"
)))]
#[cfg(not(any(x11_platform, macos_platform, windows_platform)))]
fn main() {
panic!("This example is supported only on x11, macOS, and Windows.");
}

View file

@ -1,6 +1,6 @@
#![allow(clippy::single_match)]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(wasm_platform))]
fn main() {
use simple_logger::SimpleLogger;
use winit::{
@ -49,7 +49,7 @@ fn main() {
});
}
#[cfg(target_arch = "wasm32")]
#[cfg(wasm_platform)]
fn main() {
panic!("This example is not supported on web.");
}

View file

@ -1,6 +1,6 @@
#![allow(clippy::single_match)]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(wasm_platform))]
fn main() {
use std::{collections::HashMap, sync::mpsc, thread, time::Duration};
@ -193,7 +193,7 @@ fn main() {
})
}
#[cfg(target_arch = "wasm32")]
#[cfg(wasm_platform)]
fn main() {
panic!("Example not supported on Wasm");
}

View file

@ -1,6 +1,6 @@
#![allow(clippy::single_match)]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(wasm_platform))]
fn main() {
use std::{thread, time};
@ -42,7 +42,7 @@ fn main() {
});
}
#[cfg(target_arch = "wasm32")]
#[cfg(wasm_platform)]
fn main() {
unimplemented!() // `Window` can't be sent between threads
}

View file

@ -14,13 +14,13 @@ pub fn main() {
.build(&event_loop)
.unwrap();
#[cfg(target_arch = "wasm32")]
#[cfg(wasm_platform)]
let log_list = wasm::insert_canvas_and_create_log_list(&window);
event_loop.run(move |event, _, control_flow| {
control_flow.set_wait();
#[cfg(target_arch = "wasm32")]
#[cfg(wasm_platform)]
wasm::log_event(&log_list, &event);
match event {
@ -36,7 +36,7 @@ pub fn main() {
});
}
#[cfg(target_arch = "wasm32")]
#[cfg(wasm_platform)]
mod wasm {
use wasm_bindgen::prelude::*;
use winit::{event::Event, window::Window};

View file

@ -2,7 +2,7 @@ pub fn main() {
println!("This example must be run with cargo run-wasm --example web_aspect_ratio")
}
#[cfg(target_arch = "wasm32")]
#[cfg(wasm_platform)]
mod wasm {
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;

View file

@ -2,14 +2,11 @@
// Limit this example to only compatible platforms.
#[cfg(any(
target_os = "windows",
target_os = "macos",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "android",
windows_platform,
macos_platform,
x11_platform,
wayland_platform,
android_platform
))]
fn main() {
use std::{thread::sleep, time::Duration};
@ -60,7 +57,7 @@ fn main() {
}
}
#[cfg(any(target_os = "ios", target_arch = "wasm32"))]
#[cfg(any(ios_platform, wasm_platform))]
fn main() {
println!("This platform doesn't support run_return.");
}