okay fixed our winit hell situation

This commit is contained in:
Jack Spira 2021-09-05 14:30:47 -07:00
parent 16c44b2acb
commit 6570f0bf40
4 changed files with 29 additions and 28 deletions

View File

@ -1,5 +1,5 @@
[package]
name = "examples"
name = "imgui-examples"
version = "0.0.0"
edition = "2018"
authors = ["The imgui-rs Developers"]
@ -11,7 +11,7 @@ publish = false
[dev-dependencies]
clipboard = "0.5"
glium = { version = "0.29", default-features = true }
glium = { version = "0.30", default-features = true }
image = "0.23"
imgui = { path = "../imgui" }
imgui-glium-renderer = { path = "../imgui-glium-renderer" }

View File

@ -15,11 +15,11 @@ winit-19 = { version = ">= 0.16, < 0.20", package = "winit", optional = true }
winit-20 = { version = ">= 0.20, < 0.22", package = "winit", optional = true }
winit-22 = { version = "0.22", package = "winit", optional = true }
winit-23 = { version = "0.23", package = "winit", optional = true }
winit-24 = { version = "0.24", package = "winit", optional = true }
winit-24 = { version = "=0.24", package = "winit", optional = true }
winit-25 = { version = "0.25", package = "winit", optional = true }
[features]
default = ["winit-24"] # TODO: Change to winit-25 when glutin has upgraded to it
default = ["winit-25"]
# This is phrased as a negative (unlike most features) so that it needs to be
# explicitly disabled (and `default-features = false` won't do it). To avoid

View File

@ -0,0 +1,8 @@
# Updating Winit
Updating the default version of Winit is very annoying and error prone. We should make some automated way to do it so we don't have any issues in the future, but here is what needs to be done:
1. Make sure that glutin is on the new version of Winit that you want to use. It's easier if our default winit version is on that new default.
2. Update the default in the Cargo.toml by simply changing the default guard.
3. At the top of lib.rs, edit the CFG guards which handle `use winit_x as winit;` such that the new default only relies on a positive feature guard (just copy the form used for the old default). If you don't do this, you'll get some particularly strange errors about two crates being used, since somehow the dependency resolver will pick a winit that the user didn't choose (and presumably won't use if it actually made it to compilation).
4. Profit??

View File

@ -79,10 +79,10 @@
//!
//! The following versions are supported, controlled by the listed feature.
//!
//! - The `winit-25` feature uses winit versions compatible with `0.25`.
//! - The `winit-24` feature supports winit versions `0.24`. This is
//! - The `winit-25` feature uses winit versions compatible with `0.25`. This is
//! on by default, so to use any other version you need to disable this crates
//! default features.
//! - The `winit-24` feature supports winit versions `0.24`.
//! - The `winit-23` feature uses winit versions compatible with `0.23`.
//! - The `winit-22` feature uses winit versions compatible with `0.22`.
//! - The `winit-20` feature should support winit either `0.20` or winit `0.21`.
@ -95,7 +95,7 @@
//! feature, fixing the configuration, or disabling `debug_assertions`.
//!
//! Conversely, if no `winit-*` features are enabled, we will fail to compile.
//! This is not an issue generally, as by default we turn on `winit-24`.
//! This is not an issue generally, as by default we turn on `winit-25`.
//!
//! All of this is in attempt to preserve the additive nature of features (while
//! still helping users notice project configuration issues), however it's done
@ -133,10 +133,10 @@
//! - Changing the default feature to the new latest `winit` version is *not* a
//! breaking change.
#[cfg(all(not(feature = "winit-24"), feature = "winit-25"))]
#[cfg(feature = "winit-25")]
use winit_25 as winit;
#[cfg(feature = "winit-24")]
#[cfg(all(not(feature = "winit-25"), feature = "winit-24"))]
use winit_24 as winit;
#[cfg(all(
@ -194,22 +194,6 @@ use winit::{
TouchPhase, VirtualKeyCode, Window, WindowEvent,
};
#[cfg(any(
feature = "winit-20",
feature = "winit-22",
feature = "winit-23",
feature = "winit-24",
feature = "winit-25"
))]
use winit::{
error::ExternalError,
event::{
DeviceEvent, ElementState, Event, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase,
VirtualKeyCode, WindowEvent,
},
window::{CursorIcon as MouseCursor, Window},
};
// Ensure at least one is enabled
#[cfg(not(any(
feature = "winit-19",
@ -221,6 +205,15 @@ use winit::{
)))]
compile_error!("Please enable at least one version of `winit` (see documentation for details).");
use winit::{
error::ExternalError,
event::{
DeviceEvent, ElementState, Event, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase,
VirtualKeyCode, WindowEvent,
},
window::{CursorIcon as MouseCursor, Window},
};
// FIXME(thom): make updading winit and adding a new feature less of a hassle here.
fn check_multiple_winits() {
use std::io::Write as _;
@ -258,8 +251,8 @@ fn check_multiple_winits() {
(this likely indicates misconfiguration, see documentation for details)."
);
let feats = [
("winit-25", cfg!(feature = "winit-25"), ""),
("winit-24", cfg!(feature = "winit-24"), " (default)"),
("winit-25", cfg!(feature = "winit-25"), " (default)"),
("winit-24", cfg!(feature = "winit-24"), ""),
("winit-23", cfg!(feature = "winit-23"), ""),
("winit-22", cfg!(feature = "winit-22"), ""),
("winit-20", cfg!(feature = "winit-20"), ""),
@ -270,7 +263,7 @@ fn check_multiple_winits() {
let _ = writeln!(err, " `feature = {:?}` is enabled{}", name, extra);
}
}
if cfg!(feature = "winit-24") && winits_enabled == 2 {
if cfg!(feature = "winit-25") && winits_enabled == 2 {
let _ = writeln!(
err,
" Perhaps you are missing a `default-features = false`?",