From 8ee906b24b79b76969a62f044a247c888fc1c258 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 25 Dec 2021 18:42:52 -0300 Subject: [PATCH] Fixes #625 Support getting Windows SDK from the environment --- src/windows_registry.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/windows_registry.rs b/src/windows_registry.rs index 65cd5f15..f36561d6 100644 --- a/src/windows_registry.rs +++ b/src/windows_registry.rs @@ -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()?;