From 03e6048dc950bd42feca8d1d51acc61969bf74de Mon Sep 17 00:00:00 2001 From: Chris Nixon Date: Tue, 30 Mar 2021 22:31:52 +0100 Subject: [PATCH] Check compile target at runtime in build --- build/Cargo.toml | 3 --- build/src/lib.rs | 17 ++++++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/build/Cargo.toml b/build/Cargo.toml index 3978f7cc..997ae113 100644 --- a/build/Cargo.toml +++ b/build/Cargo.toml @@ -10,7 +10,4 @@ repository = "https://github.com/napi-rs/napi-rs" version = "1.0.1" [dependencies] -cfg-if = "1" - -[target.'cfg(windows)'.dependencies] ureq = "2" diff --git a/build/src/lib.rs b/build/src/lib.rs index b3d387a0..72046f9d 100644 --- a/build/src/lib.rs +++ b/build/src/lib.rs @@ -1,11 +1,10 @@ -cfg_if::cfg_if! { - if #[cfg(windows)] { - mod windows; - pub use windows::setup; - } else if #[cfg(target_os = "macos")] { - mod macos; - pub use macos::setup; - } else { - pub fn setup() { } +mod macos; +mod windows; + +pub fn setup() { + match std::env::var("CARGO_CFG_TARGET_OS").as_deref() { + Ok("macos") => macos::setup(), + Ok("windows") => windows::setup(), + _ => {} } }