[vcpkg] Split toolset searches based on triplet's specification (don't pick v120 if it's blank).
MODIFY
include/VcpkgPaths.h
include/VcpkgPaths.h
@@ -73,5 +73,6 @@ namespace vcpkg
Lazy<fs::path> nuget_exe;
Lazy<std::vector<Toolset>> toolsets;
Lazy<std::vector<Toolset>> toolsets_vs2017_v140;
+ Lazy<std::vector<Toolset>> toolsets_vs2013;
};
}

MODIFY
src/PostBuildLint.cpp
src/PostBuildLint.cpp
@@ -40,26 +40,36 @@ namespace vcpkg::PostBuildLint
Span<const OutdatedDynamicCrt> get_outdated_dynamic_crts(CStringView toolset)
{
- static const std::vector<OutdatedDynamicCrt> V_NO_MSVCRT = {
+ static const std::vector<OutdatedDynamicCrt> V_NO_120 = {
{"msvcp100.dll", R"(msvcp100\.dll)"},
{"msvcp100d.dll", R"(msvcp100d\.dll)"},
{"msvcp110.dll", R"(msvcp110\.dll)"},
{"msvcp110_win.dll", R"(msvcp110_win\.dll)"},
- //{"msvcp120.dll", R"(msvcp120\.dll)"},
- //{"msvcp120_clr0400.dll", R"(msvcp120_clr0400\.dll)"},
{"msvcp60.dll", R"(msvcp60\.dll)"},
{"msvcp60.dll", R"(msvcp60\.dll)"},
+ {"msvcrt.dll", R"(msvcrt\.dll)"},
{"msvcr100.dll", R"(msvcr100\.dll)"},
{"msvcr100d.dll", R"(msvcr100d\.dll)"},
{"msvcr100_clr0400.dll", R"(msvcr100_clr0400\.dll)"},
{"msvcr110.dll", R"(msvcr110\.dll)"},
- //{"msvcr120.dll", R"(msvcr120\.dll)"},
- //{"msvcr120_clr0400.dll", R"(msvcr120_clr0400\.dll)"},
{"msvcrt20.dll", R"(msvcrt20\.dll)"},
- {"msvcrt40.dll", R"(msvcrt40\.dll)"}};
+ {"msvcrt40.dll", R"(msvcrt40\.dll)"},
+ };
+
+ static const std::vector<OutdatedDynamicCrt> V = [&]() {
+ auto ret = V_NO_120;
+ ret.push_back({"msvcp120.dll", R"(msvcp120\.dll)"});
+ ret.push_back({"msvcp120_clr0400.dll", R"(msvcp120_clr0400\.dll)"});
+ ret.push_back({"msvcr120.dll", R"(msvcr120\.dll)"});
+ ret.push_back({"msvcr120_clr0400.dll", R"(msvcr120_clr0400\.dll)"});
+ return ret;
+ }();
- return V_NO_MSVCRT;
+ if (toolset == "v120")
+ return V_NO_120;
+ else
+ return V;
}
static LintStatus check_for_files_in_include_directory(const Files::Filesystem& fs,
@@ -646,7 +656,8 @@ namespace vcpkg::PostBuildLint
static LintStatus check_outdated_crt_linkage_of_dlls(const std::vector<fs::path>& dlls,
const fs::path dumpbin_exe,
- const BuildInfo& build_info)
+ const BuildInfo& build_info,
+ const PreBuildInfo& pre_build_info)
{
if (build_info.policies.is_enabled(BuildPolicy::ALLOW_OBSOLETE_MSVCRT)) return LintStatus::SUCCESS;
@@ -662,7 +673,7 @@ namespace vcpkg::PostBuildLint
"Running command:\n %s\n failed",
Strings::to_utf8(cmd_line));
- for (const OutdatedDynamicCrt& outdated_crt : get_outdated_dynamic_crts("v141"))
+ for (const OutdatedDynamicCrt& outdated_crt : get_outdated_dynamic_crts(pre_build_info.platform_toolset))
{
if (std::regex_search(ec_data.output.cbegin(), ec_data.output.cend(), outdated_crt.regex))
{
@@ -788,7 +799,7 @@ namespace vcpkg::PostBuildLint
error_count += check_uwp_bit_of_dlls(pre_build_info.cmake_system_name, dlls, toolset.dumpbin);
error_count += check_dll_architecture(pre_build_info.target_architecture, dlls);
- error_count += check_outdated_crt_linkage_of_dlls(dlls, toolset.dumpbin, build_info);
+ error_count += check_outdated_crt_linkage_of_dlls(dlls, toolset.dumpbin, build_info, pre_build_info);
break;
}
case Build::LinkageType::STATIC:

MODIFY
src/VcpkgPaths.cpp
src/VcpkgPaths.cpp
@@ -278,47 +278,37 @@ namespace vcpkg
return nullopt;
}
- static Optional<fs::path> get_vs2013_installation_instance()
- {
- const Optional<std::wstring> vs2013_cmntools_optional = System::get_environment_variable(L"VS120COMNTOOLS");
- if (const auto v = vs2013_cmntools_optional.get())
- {
- const fs::path vs2013_cmntools = fs::path(*v).parent_path(); // The call to parent_path() is needed because
- // the env variable has a trailing backslash
- return vs2013_cmntools.parent_path().parent_path();
- }
-
- return nullopt;
- }
-
- static std::vector<Toolset> find_toolset_instances(const VcpkgPaths& paths)
+ static std::vector<Toolset> find_v120_toolset_instances(const Files::Filesystem& fs)
{
using CPU = System::CPUArchitecture;
- const auto& fs = paths.get_filesystem();
-
// Note: this will contain a mix of vcvarsall.bat locations and dumpbin.exe locations.
std::vector<fs::path> paths_examined;
std::vector<Toolset> found_toolsets;
// VS2013
- const Optional<fs::path> vs_2013_installation_instance = get_vs2013_installation_instance();
- if (const auto v = vs_2013_installation_instance.get())
+ const Optional<std::wstring> vs2013_cmntools_optional = System::get_environment_variable(L"VS120COMNTOOLS");
+ if (const auto vs120comntools = vs2013_cmntools_optional.get())
{
- const fs::path vs2013_vcvarsall_bat = *v / "VC" / "vcvarsall.bat";
+ const fs::path vs2013_cmntools =
+ fs::path(*vs120comntools).parent_path(); // The call to parent_path() is needed because
+ // the env variable has a trailing backslash
+ auto v = vs2013_cmntools.parent_path().parent_path();
+
+ const fs::path vs2013_vcvarsall_bat = v / "VC" / "vcvarsall.bat";
paths_examined.push_back(vs2013_vcvarsall_bat);
if (fs.exists(vs2013_vcvarsall_bat))
{
- const fs::path vs2013_dumpbin_exe = *v / "VC" / "bin" / "dumpbin.exe";
+ const fs::path vs2013_dumpbin_exe = v / "VC" / "bin" / "dumpbin.exe";
paths_examined.push_back(vs2013_dumpbin_exe);
const fs::path vs2013_bin_dir = vs2013_vcvarsall_bat.parent_path() / "bin";
std::vector<ToolsetArchOption> supported_architectures;
if (fs.exists(vs2013_bin_dir / "vcvars32.bat"))
supported_architectures.push_back({L"x86", CPU::X86, CPU::X86});
- if (fs.exists(3 / "amd64\\vcvars64.bat"))
+ if (fs.exists(vs2013_bin_dir / "amd64\\vcvars64.bat"))
supported_architectures.push_back({L"x64", CPU::X64, CPU::X64});
if (fs.exists(vs2013_bin_dir / "x86_amd64\\vcvarsx86_amd64.bat"))
supported_architectures.push_back({L"x86_amd64", CPU::X86, CPU::X64});
@@ -332,11 +322,36 @@ namespace vcpkg
if (fs.exists(vs2013_dumpbin_exe))
{
found_toolsets.push_back(
- {vs2013_dumpbin_exe, vs2013_vcvarsall_bat, L"v120", supported_architectures});
+ {vs2013_dumpbin_exe, vs2013_vcvarsall_bat, {}, V_120, supported_architectures});
}
}
}
+ if (found_toolsets.empty())
+ {
+ System::println(System::Color::error, "Could not locate a complete toolset.");
+ System::println("The following paths were examined:");
+ for (const fs::path& path : paths_examined)
+ {
+ System::println(" %s", path.u8string());
+ }
+ Checks::exit_fail(VCPKG_LINE_INFO);
+ }
+
+ return found_toolsets;
+ }
+
+ static std::vector<Toolset> find_toolset_instances(const VcpkgPaths& paths)
+ {
+ using CPU = System::CPUArchitecture;
+
+ const auto& fs = paths.get_filesystem();
+
+ // Note: this will contain a mix of vcvarsall.bat locations and dumpbin.exe locations.
+ std::vector<fs::path> paths_examined;
+
+ std::vector<Toolset> found_toolsets;
+
// VS2015
const Optional<fs::path> vs_2015_installation_instance = get_vs2015_installation_instance();
if (const auto v = vs_2015_installation_instance.get())
@@ -372,8 +387,6 @@ namespace vcpkg
}
}
- const std::vector<std::string> vs2017_installation_instances = get_vs2017_installation_instances(paths);
-
// VS2017
Optional<Toolset> vs2017_toolset;
const std::vector<std::string> vs2017_installation_instances = get_vs2017_installation_instances(paths);
@@ -476,6 +489,14 @@ namespace vcpkg
{
const std::wstring& w_toolset_version = Strings::to_utf16(toolset_version);
+ if (w_toolset_version == V_120)
+ {
+ const auto& v120_toolsets = this->toolsets_vs2013.get_lazy(
+ [this]() { return find_v120_toolset_instances(this->get_filesystem()); });
+ Checks::check_exit(VCPKG_LINE_INFO, v120_toolsets.size() > 0);
+ return v120_toolsets.back();
+ }
+
// Invariant: toolsets are non-empty and sorted with newest at back()
const std::vector<Toolset>& vs_toolsets =
this->toolsets.get_lazy([this]() { return find_toolset_instances(*this); });

[vcpkg] Split toolset searches based on triplet's specification (don't pick v120 if it's blank).