Skip to content

Commit

Permalink
Fixing non-Windows compile
Browse files Browse the repository at this point in the history
  • Loading branch information
haimgel committed Oct 18, 2021
1 parent 7bf1158 commit 1c53510
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/main.rs
Expand Up @@ -8,6 +8,8 @@
extern crate log;

use anyhow::Result;

#[cfg(target_os = "windows")]
use winapi::um::wincon::{AttachConsole, ATTACH_PARENT_PROCESS};

mod app;
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 1c53510

Please sign in to comment.