diff --git a/build/Cargo.toml b/build/Cargo.toml index 3978f7cc..c0d0c837 100644 --- a/build/Cargo.toml +++ b/build/Cargo.toml @@ -12,5 +12,5 @@ version = "1.0.1" [dependencies] cfg-if = "1" -[target.'cfg(windows)'.dependencies] +[target.'cfg(not(target_env = "musl"))'.dependencies] ureq = "2" diff --git a/build/src/lib.rs b/build/src/lib.rs index b3d387a0..7a4e51b1 100644 --- a/build/src/lib.rs +++ b/build/src/lib.rs @@ -1,11 +1,23 @@ +mod macos; + cfg_if::cfg_if! { - if #[cfg(windows)] { + if #[cfg(not(target_env = "musl"))] { mod windows; - pub use windows::setup; - } else if #[cfg(target_os = "macos")] { - mod macos; - pub use macos::setup; - } else { - pub fn setup() { } + } +} + +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 { + eprintln!("Cross compiling to windows-msvc is not supported from *-musl hosts") + } + } + } + _ => {} } }