From bb004dc78c1c43567c6b3b0d2a273c3ed1150cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Tue, 6 Apr 2021 23:06:53 -0300 Subject: [PATCH] Fixing Windows build: no termion support --- Cargo.toml | 3 ++- src/utils.rs | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b161754..7441402 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ description = "A command-line utility for easily compressing and decompressing f [dependencies] colored = "2.0.0" -termion = "1.5.6" walkdir = "2.3.2" tar = "0.4.33" xz2 = "0.1.6" @@ -25,6 +24,8 @@ zip = "0.5.11" # Dependency from workspace oof = { path = "./oof" } +[target.'cfg(unix)'.dependencies] +termion = "1.5.6" [profile.release] lto = true codegen-units = 1 diff --git a/src/utils.rs b/src/utils.rs index 736628b..6446f1a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -126,7 +126,9 @@ pub struct Bytes { bytes: f64, } -#[allow(dead_code)] +/// Module with a list of bright colors. +#[allow(dead_code, non_upper_case_globals)] +#[cfg(target_family = "unix")] pub mod colors { use termion::color::*; @@ -158,6 +160,22 @@ pub mod colors { LightYellow.fg_str() } } +// Termion does not support Windows +#[cfg(not(target_family = "unix"))] +pub mod colors { + pub fn empty() -> &'static str { + "" + } + pub const reset: fn() -> &'static str = empty; + pub const black: fn() -> &'static str = empty; + pub const blue: fn() -> &'static str = empty; + pub const cyan: fn() -> &'static str = empty; + pub const green: fn() -> &'static str = empty; + pub const magenta: fn() -> &'static str = empty; + pub const red: fn() -> &'static str = empty; + pub const white: fn() -> &'static str = empty; + pub const yellow: fn() -> &'static str = empty; +} impl Bytes { const UNIT_PREFIXES: [&'static str; 6] = ["", "k", "M", "G", "T", "P"];