Skip to content

Commit

Permalink
Support OUT_DIR located in \\?\ path on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 14, 2024
1 parent 2f17770 commit 6062d45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -45,6 +48,11 @@ fn compress_man() {
add_files(Path::new("src/doc/man/generated_txt"), OsStr::new("txt"));
let encoder = ar.into_inner().unwrap();
encoder.finish().unwrap();

let host = std::env::var("HOST").unwrap();
if let Some("windows") = host.split('-').nth(2) {
println!("cargo:rustc-cfg=host_os=\"windows\"");
}
}

struct CommitInfo {
Expand Down
4 changes: 4 additions & 0 deletions src/bin/cargo/commands/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 6062d45

Please sign in to comment.