From 030baede12f079793cc50d6f90b677b889c49fcd Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 4 Jan 2022 14:58:14 -0300 Subject: [PATCH] Fixes #625 Support getting Windows SDK from the environment (#646) --- src/windows_registry.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/windows_registry.rs b/src/windows_registry.rs index 7cb40eba..549082b3 100644 --- a/src/windows_registry.rs +++ b/src/windows_registry.rs @@ -669,7 +669,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()?;