Skip to content

Commit 52bc4eb

Browse files
authored
Add fn get_ucrt_dir for find-msvc-tools (#1546)
* Add fn get_ucrt_dir for find-msvc-tools Fixed #1545 * Fix find_tools.rs
1 parent 4d2d2f6 commit 52bc4eb

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

find-msvc-tools/src/find_tools.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,16 @@ pub fn find_vs_version() -> Result<VsVers, String> {
256256
}
257257
}
258258

259+
/// To find the Universal CRT we look in a specific registry key for where
260+
/// all the Universal CRTs are located and then sort them asciibetically to
261+
/// find the newest version. While this sort of sorting isn't ideal, it is
262+
/// what vcvars does so that's good enough for us.
263+
///
264+
/// Returns a pair of (root, version) for the ucrt dir if found
265+
pub fn get_ucrt_dir() -> Option<(PathBuf, String)> {
266+
impl_::get_ucrt_dir()
267+
}
268+
259269
/// Windows Implementation.
260270
#[cfg(windows)]
261271
mod impl_ {
@@ -997,7 +1007,7 @@ mod impl_ {
9971007
// what vcvars does so that's good enough for us.
9981008
//
9991009
// Returns a pair of (root, version) for the ucrt dir if found
1000-
fn get_ucrt_dir() -> Option<(PathBuf, String)> {
1010+
pub(super) fn get_ucrt_dir() -> Option<(PathBuf, String)> {
10011011
let key = r"SOFTWARE\Microsoft\Windows Kits\Installed Roots";
10021012
let key = LOCAL_MACHINE.open(key.as_ref()).ok()?;
10031013
let root = key.query_str("KitsRoot10").ok()?;
@@ -1400,7 +1410,7 @@ mod impl_ {
14001410
/// Non-Windows Implementation.
14011411
#[cfg(not(windows))]
14021412
mod impl_ {
1403-
use std::{env, ffi::OsStr};
1413+
use std::{env, ffi::OsStr, path::PathBuf};
14041414

14051415
use super::{EnvGetter, TargetArch};
14061416
use crate::Tool;
@@ -1488,4 +1498,9 @@ mod impl_ {
14881498
pub(super) fn has_msbuild_version(_version: &str, _: &dyn EnvGetter) -> bool {
14891499
false
14901500
}
1501+
1502+
#[inline(always)]
1503+
pub(super) fn get_ucrt_dir() -> Option<(PathBuf, String)> {
1504+
None
1505+
}
14911506
}

0 commit comments

Comments
 (0)