Skip to content

Commit

Permalink
Merge pull request #89 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 66658ec + 309d6c6 commit 5909363
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ fn main() {
let out = Path::new(&out_dir).join("limit.mem");
fs::write(out, format!("{limit:?}\n")).unwrap();

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

println!("cargo:rerun-if-env-changed={CARGO_TALLY_MEMORY_LIMIT}");
println!("cargo:rustc-check-cfg=cfg(host_os, values(\"windows\"))");
}
4 changes: 4 additions & 0 deletions src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ static ALLOC: Allocator = Allocator {
peak: AtomicU64::new(0),
};

#[cfg(not(host_os = "windows"))]
const LIMIT: Option<u64> = include!(concat!(env!("OUT_DIR"), "/limit.mem"));

#[cfg(host_os = "windows")]
const LIMIT: Option<u64> = include!(concat!(env!("OUT_DIR"), "\\limit.mem"));

unsafe impl<A> GlobalAlloc for Allocator<A>
where
A: GlobalAlloc,
Expand Down

0 comments on commit 5909363

Please sign in to comment.