From 1c535101c03a2a20dcd026807f00fce9a4f97033 Mon Sep 17 00:00:00 2001 From: Haim Gelfenbeyn Date: Sun, 17 Oct 2021 20:17:58 -0400 Subject: [PATCH] Fixing non-Windows compile --- .github/workflows/build.yml | 4 ++-- src/main.rs | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c6804e2..2b775c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,10 +33,10 @@ jobs: key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Build - run: cargo build --verbose --release + run: cargo build --release - name: Run tests - run: cargo test --verbose + run: cargo test - name: Run executable run: ./target/release/display_switch || true # todo: --version or --help when those exist diff --git a/src/main.rs b/src/main.rs index 5668865..e7437c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,8 @@ extern crate log; use anyhow::Result; + +#[cfg(target_os = "windows")] use winapi::um::wincon::{AttachConsole, ATTACH_PARENT_PROCESS}; mod app; @@ -21,10 +23,9 @@ mod usb; /// On Windows, re-attach the console, if parent process has the console. This allows /// to see the log output when run from the command line. fn attach_console() { - if cfg!(windows) { - unsafe { - AttachConsole(ATTACH_PARENT_PROCESS); - } + #[cfg(target_os = "windows")] + unsafe { + AttachConsole(ATTACH_PARENT_PROCESS); } }