From 8fd2aef870a4ad6f689d3105552cdbed87add0fc Mon Sep 17 00:00:00 2001 From: Jimmy Hartzell Date: Thu, 23 Mar 2023 14:22:28 -0400 Subject: [PATCH 1/5] crossterm_winapi optional --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4fd7df20c..7bb0c15a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ all-features = true # Features # [features] -default = ["bracketed-paste"] +default = ["bracketed-paste", "crossterm_winapi"] bracketed-paste = [] event-stream = ["futures-core"] use-dev-tty = ["filedescriptor"] @@ -50,7 +50,7 @@ version = "0.3.9" features = ["winuser", "winerror"] [target.'cfg(windows)'.dependencies] -crossterm_winapi = "0.9" +crossterm_winapi = { version = "0.9", optional = true } # # UNIX dependencies From ddfbedd9fdd20af2f548eaa0e19f2b5d6900b386 Mon Sep 17 00:00:00 2001 From: Jimmy Hartzell Date: Thu, 23 Mar 2023 14:28:42 -0400 Subject: [PATCH 2/5] more windows --- Cargo.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7bb0c15a7..50af01cee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,8 @@ all-features = true # Features # [features] -default = ["bracketed-paste", "crossterm_winapi"] +default = ["bracketed-paste", "windows"] +windows = ["winapi", "crossterm_winapi"] bracketed-paste = [] event-stream = ["futures-core"] use-dev-tty = ["filedescriptor"] @@ -48,6 +49,7 @@ serde = { version = "1.0", features = ["derive"], optional = true } [target.'cfg(windows)'.dependencies.winapi] version = "0.3.9" features = ["winuser", "winerror"] +optional = true [target.'cfg(windows)'.dependencies] crossterm_winapi = { version = "0.9", optional = true } From 75862df529c36423214aa1434e99ba416e8345ba Mon Sep 17 00:00:00 2001 From: Jimmy Hartzell Date: Tue, 28 Mar 2023 10:45:58 -0400 Subject: [PATCH 3/5] add compiler errors to explain Windows situation with features disabled --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 0f6bcc1a3..06f84ab88 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -257,3 +257,13 @@ pub mod ansi_support; mod command; mod error; pub(crate) mod macros; + +#[cfg(all(windows, not(feature = "windows")))] +compile_error!("Compiling on Windows with \"windows\" feature disabled. Feature \"windows\" should only be disabled when project will never be compiled on Windows."); + +#[cfg(all(winapi, not(feature = "winapi")))] +compile_error!("Compiling on Windows with \"winapi\" feature disabled. Feature \"winapi\" should only be disabled when project will never be compiled on Windows."); + +#[cfg(all(crossterm_winapi, not(feature = "crossterm_winapi")))] +compile_error!("Compiling on Windows with \"crossterm_winapi\" feature disabled. Feature \"crossterm_winapi\" should only be disabled when project will never be compiled on Windows."); + From ec79b4753d5fddd5f564a9fc822c09e0ad66916f Mon Sep 17 00:00:00 2001 From: Jimmy Hartzell Date: Tue, 28 Mar 2023 14:22:46 -0400 Subject: [PATCH 4/5] formatting fix --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 06f84ab88..d8d9f86be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -266,4 +266,3 @@ compile_error!("Compiling on Windows with \"winapi\" feature disabled. Feature \ #[cfg(all(crossterm_winapi, not(feature = "crossterm_winapi")))] compile_error!("Compiling on Windows with \"crossterm_winapi\" feature disabled. Feature \"crossterm_winapi\" should only be disabled when project will never be compiled on Windows."); - From fb81ceb71df0cb2781bedfadc513dd9d1b560cd7 Mon Sep 17 00:00:00 2001 From: Jimmy Hartzell Date: Wed, 29 Mar 2023 13:30:46 -0400 Subject: [PATCH 5/5] fix CI to match new situation --- .github/workflows/crossterm_test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/crossterm_test.yml b/.github/workflows/crossterm_test.yml index 8b2509fc2..2b04bc0c0 100644 --- a/.github/workflows/crossterm_test.yml +++ b/.github/workflows/crossterm_test.yml @@ -63,8 +63,12 @@ jobs: run: cargo test --all-features -- --nocapture --test-threads 1 continue-on-error: ${{ matrix.can-fail }} - name: Test no default features + if: matrix.os != 'windows-2019' run: cargo test --no-default-features -- --nocapture --test-threads 1 continue-on-error: ${{ matrix.can-fail }} + - name: Test no default features with windows feature enabled + if: matrix.os == 'windows-2019' + run: cargo test --no-default-features --features windows -- --nocapture --test-threads 1 - name: Test Packaging if: matrix.rust == 'stable' run: cargo package