Skip to content

Commit

Permalink
Fixes rust-lang#625 Support getting Windows SDK from the environment
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Dec 25, 2021
1 parent 795a12d commit 8ee906b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/windows_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,15 @@ mod impl_ {
// only need to bother checking x64, making this code a tiny bit simpler.
// Like we do for the Universal CRT, we sort the possibilities
// asciibetically to find the newest one as that is what vcvars does.
// Before doing that, we check the "WindowsSdkDir" and "WindowsSDKVersion"
// environment variables set by vcvars to use the environment sdk version
// if one is already configured.
fn get_sdk10_dir() -> Option<(PathBuf, String)> {
if let (Ok(root), Ok(version)) = (env::var("WindowsSdkDir"), env::var("WindowsSDKVersion"))
{
return Some((root.into(), version.trim_end_matches('\\').to_string()));
}

let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0";
let key = LOCAL_MACHINE.open(key.as_ref()).ok()?;
let root = key.query_str("InstallationFolder").ok()?;
Expand Down

0 comments on commit 8ee906b

Please sign in to comment.