diff --git a/build.rs b/build.rs index 0a1e301..4e261a3 100644 --- a/build.rs +++ b/build.rs @@ -23,6 +23,7 @@ macro_rules! host { fn main() { println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rustc-check-cfg=cfg(host_os, values(\"windows\"))"); let target = env_var("TARGET"); let host = env_var("HOST"); @@ -32,6 +33,10 @@ fn main() { .replace("{TARGET}", &target.escape_debug().to_string()) .replace("{HOST}", &host.escape_debug().to_string()); fs::write(out, macros).unwrap(); + + if let Some("windows") = host.split('-').nth(2) { + println!("cargo:rustc-cfg=host_os=\"windows\""); + } } fn env_var(key: &str) -> String { diff --git a/src/lib.rs b/src/lib.rs index de74d52..30179fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,8 +6,12 @@ #![doc(html_root_url = "https://docs.rs/target-triple/0.1.2")] +#[cfg(not(host_os = "windows"))] include!(concat!(env!("OUT_DIR"), "/macros.rs")); +#[cfg(host_os = "windows")] +include!(concat!(env!("OUT_DIR"), "\\macros.rs")); + /// The target triple that is being compiled for. pub const TARGET: &str = target!();