Skip to content

Commit

Permalink
Merge pull request #1 from dtolnay/windows
Browse files Browse the repository at this point in the history
Support OUT_DIR located in `\\?\` path on Windows
  • Loading branch information
dtolnay authored May 14, 2024
2 parents 3ad3530 + 689436f commit 9f73d5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();

Expand Down

0 comments on commit 9f73d5c

Please sign in to comment.