Merge pull request #519 from c-nixon/check-CARGO_CFG_TARGET_OS-in-build

This commit is contained in:
LongYinan 2021-04-02 17:16:25 +08:00 committed by GitHub
commit e4753b7c1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions

View file

@ -12,5 +12,5 @@ version = "1.0.1"
[dependencies] [dependencies]
cfg-if = "1" cfg-if = "1"
[target.'cfg(windows)'.dependencies] [target.'cfg(not(target_env = "musl"))'.dependencies]
ureq = "2" ureq = "2"

View file

@ -1,11 +1,23 @@
cfg_if::cfg_if! {
if #[cfg(windows)] {
mod windows;
pub use windows::setup;
} else if #[cfg(target_os = "macos")] {
mod macos; mod macos;
pub use macos::setup;
cfg_if::cfg_if! {
if #[cfg(not(target_env = "musl"))] {
mod windows;
}
}
pub fn setup() {
match std::env::var("CARGO_CFG_TARGET_OS").as_deref() {
Ok("macos") => macos::setup(),
Ok("windows") => {
cfg_if::cfg_if! {
if #[cfg(not(target_env = "musl"))] {
windows::setup()
} else { } else {
pub fn setup() { } eprintln!("Cross compiling to windows-msvc is not supported from *-musl hosts")
}
}
}
_ => {}
} }
} }