diff --git a/build.rs b/build.rs index 9b1e2662eaf..ebc44fbc9f4 100644 --- a/build.rs +++ b/build.rs @@ -5,9 +5,12 @@ use std::path::Path; use std::process::Command; fn main() { + println!("cargo:rustc-check-cfg=cfg(host_os, values(\"windows\"))"); + commit_info(); compress_man(); windows_manifest(); + // ALLOWED: Accessing environment during build time shouldn't be prohibited. #[allow(clippy::disallowed_methods)] let target = std::env::var("TARGET").unwrap(); @@ -45,6 +48,13 @@ fn compress_man() { add_files(Path::new("src/doc/man/generated_txt"), OsStr::new("txt")); let encoder = ar.into_inner().unwrap(); encoder.finish().unwrap(); + + // ALLOWED: Accessing environment during build time shouldn't be prohibited. + #[allow(clippy::disallowed_methods)] + let host = std::env::var("HOST").unwrap(); + if let Some("windows") = host.split('-').nth(2) { + println!("cargo:rustc-cfg=host_os=\"windows\""); + } } struct CommitInfo { diff --git a/src/bin/cargo/commands/help.rs b/src/bin/cargo/commands/help.rs index a92f5d140bc..a5cdba1139d 100644 --- a/src/bin/cargo/commands/help.rs +++ b/src/bin/cargo/commands/help.rs @@ -10,8 +10,12 @@ use std::io::Read; use std::io::Write; use std::path::Path; +#[cfg(not(host_os = "windows"))] const COMPRESSED_MAN: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/man.tgz")); +#[cfg(host_os = "windows")] +const COMPRESSED_MAN: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "\\man.tgz")); + pub fn cli() -> Command { subcommand("help") .about("Displays help for a cargo subcommand")