Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support OUT_DIR located in \\?\ path on Windows #13914

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 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,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 {
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