Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions find-msvc-tools/src/find_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ pub fn find_vs_version() -> Result<VsVers, String> {
}
}

/// To find the Universal CRT we look in a specific registry key for where
/// all the Universal CRTs are located and then sort them asciibetically to
/// find the newest version. While this sort of sorting isn't ideal, it is
/// what vcvars does so that's good enough for us.
///
/// Returns a pair of (root, version) for the ucrt dir if found
pub fn get_ucrt_dir() -> Option<(PathBuf, String)> {
impl_::get_ucrt_dir()
}

/// Windows Implementation.
#[cfg(windows)]
mod impl_ {
Expand Down Expand Up @@ -997,7 +1007,7 @@ mod impl_ {
// what vcvars does so that's good enough for us.
//
// Returns a pair of (root, version) for the ucrt dir if found
fn get_ucrt_dir() -> Option<(PathBuf, String)> {
pub(super) fn get_ucrt_dir() -> Option<(PathBuf, String)> {
let key = r"SOFTWARE\Microsoft\Windows Kits\Installed Roots";
let key = LOCAL_MACHINE.open(key.as_ref()).ok()?;
let root = key.query_str("KitsRoot10").ok()?;
Expand Down Expand Up @@ -1400,7 +1410,7 @@ mod impl_ {
/// Non-Windows Implementation.
#[cfg(not(windows))]
mod impl_ {
use std::{env, ffi::OsStr};
use std::{env, ffi::OsStr, path::PathBuf};

use super::{EnvGetter, TargetArch};
use crate::Tool;
Expand Down Expand Up @@ -1488,4 +1498,9 @@ mod impl_ {
pub(super) fn has_msbuild_version(_version: &str, _: &dyn EnvGetter) -> bool {
false
}

#[inline(always)]
pub(super) fn get_ucrt_dir() -> Option<(PathBuf, String)> {
None
}
}
Loading