Check compile target at runtime in build

This commit is contained in:
Chris Nixon 2021-03-30 22:31:52 +01:00
parent 81af1674a8
commit 03e6048dc9
No known key found for this signature in database
GPG key ID: 6F4189ED88C00543
2 changed files with 8 additions and 12 deletions

View file

@ -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"

View file

@ -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(),
_ => {}
}
}