Skip to content
Open
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
15 changes: 13 additions & 2 deletions find-msvc-tools/src/find_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ mod impl_ {
instance_path: &Path,
env_getter: &dyn EnvGetter,
) -> Option<(PathBuf, PathBuf, PathBuf, PathBuf, Option<PathBuf>, PathBuf)> {
let version = vs15plus_vc_read_version(instance_path)?;
let version = vs15plus_vc_read_version(instance_path, env_getter)?;

let hosts = match host_arch() {
X86 => &["X86"],
Expand Down Expand Up @@ -843,7 +843,13 @@ mod impl_ {
))
}

fn vs15plus_vc_read_version(dir: &Path) -> Option<String> {
fn vs15plus_vc_read_version(dir: &Path, env_getter: &dyn EnvGetter) -> Option<String> {
if let Some(version) = env_getter.get_env("VCToolsVersion") {
// Restrict the search to a specific msvc version; if it doesn't exist then
// our caller will fail to find the tool for this instance and move on.
return version.to_str().map(|s| s.to_string());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return version.to_str().map(|s| s.to_string());
return version.to_str().map(ToString::to_string)

}

// Try to open the default version file.
let mut version_path: PathBuf =
dir.join(r"VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt");
Expand Down Expand Up @@ -919,6 +925,11 @@ mod impl_ {
target: TargetArch,
env_getter: &dyn EnvGetter,
) -> Option<Tool> {
if env_getter.get_env("VCToolsVersion").is_some() {
// VCToolsVersion is not set/supported for MSVC 14
return None;
}

let vcdir = get_vc_dir("14.0")?;
let sdk_info = get_sdks(target, env_getter)?;
let mut tool = get_tool(tool, &vcdir, target, &sdk_info)?;
Expand Down
Loading