diff options
| author | mmazat <m.mazaheri.t@gmail.com> | 2017-06-07 21:02:57 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-07 21:02:57 -0400 |
| commit | ff52016d018c9d346cd402e9cc98d24dff39d900 (patch) | |
| tree | 217cdb8ba8e0011f8d88a56e19770009289661b6 /toolsrc/src/VcpkgPaths.cpp | |
| parent | 56b27d1d00b08af2cba16197cc7b5f5eed98bca0 (diff) | |
| parent | ab0b48927505103c4b8782f90a44336a2bb7791d (diff) | |
| download | vcpkg-ff52016d018c9d346cd402e9cc98d24dff39d900.tar.gz vcpkg-ff52016d018c9d346cd402e9cc98d24dff39d900.zip | |
Merge pull request #1 from Microsoft/master
pull changes from upstream
Diffstat (limited to 'toolsrc/src/VcpkgPaths.cpp')
| -rw-r--r-- | toolsrc/src/VcpkgPaths.cpp | 78 |
1 files changed, 54 insertions, 24 deletions
diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp index 3dd32de01..9068e3903 100644 --- a/toolsrc/src/VcpkgPaths.cpp +++ b/toolsrc/src/VcpkgPaths.cpp @@ -269,7 +269,7 @@ namespace vcpkg return nullopt; } - static Toolset find_toolset_instance(const VcpkgPaths& paths) + static std::vector<Toolset> find_toolset_instances(const VcpkgPaths& paths) { const auto& fs = paths.get_filesystem(); @@ -277,7 +277,28 @@ namespace vcpkg // 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 (auto v = vs_2015_installation_instance.get()) + { + const fs::path vs2015_vcvarsall_bat = *v / "VC" / "vcvarsall.bat"; + + paths_examined.push_back(vs2015_vcvarsall_bat); + if (fs.exists(vs2015_vcvarsall_bat)) + { + const fs::path vs2015_dumpbin_exe = *v / "VC" / "bin" / "dumpbin.exe"; + paths_examined.push_back(vs2015_dumpbin_exe); + if (fs.exists(vs2015_dumpbin_exe)) + { + found_toolsets.push_back({vs2015_dumpbin_exe, vs2015_vcvarsall_bat, L"v140"}); + } + } + } + // VS2017 + Optional<Toolset> vs2017_toolset; for (const fs::path& instance : vs2017_installation_instances) { const fs::path vc_dir = instance / "VC"; @@ -303,41 +324,50 @@ namespace vcpkg paths_examined.push_back(dumpbin_path); if (fs.exists(dumpbin_path)) { - return {dumpbin_path, vcvarsall_bat, L"v141"}; + vs2017_toolset = Toolset{dumpbin_path, vcvarsall_bat, L"v141"}; + break; } } + if (auto value = vs2017_toolset.get()) + { + found_toolsets.push_back(*value); + break; + } } - // VS2015 - const Optional<fs::path> vs_2015_installation_instance = get_VS2015_installation_instance(); - if (auto v = vs_2015_installation_instance.get()) + if (found_toolsets.empty()) { - const fs::path vs2015_vcvarsall_bat = *v / "VC" / "vcvarsall.bat"; - - paths_examined.push_back(vs2015_vcvarsall_bat); - if (fs.exists(vs2015_vcvarsall_bat)) + 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) { - const fs::path vs2015_dumpbin_exe = *v / "VC" / "bin" / "dumpbin.exe"; - paths_examined.push_back(vs2015_dumpbin_exe); - if (fs.exists(vs2015_dumpbin_exe)) - { - return {vs2015_dumpbin_exe, vs2015_vcvarsall_bat, L"v140"}; - } + System::println(" %s", path.u8string()); } + Checks::exit_fail(VCPKG_LINE_INFO); } - 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; } - const Toolset& VcpkgPaths::get_toolset() const + const Toolset& VcpkgPaths::get_toolset(const std::string& toolset_version) const { - return this->toolset.get_lazy([this]() { return find_toolset_instance(*this); }); + // Invariant: toolsets are non-empty and sorted with newest at back() + const auto& vs_toolsets = this->toolsets.get_lazy([this]() { return find_toolset_instances(*this); }); + + if (toolset_version.empty()) + { + return vs_toolsets.back(); + } + else + { + const auto toolset = Util::find_if(vs_toolsets, [&](const Toolset& toolset) { + return toolset_version == Strings::to_utf8(toolset.version); + }); + Checks::check_exit( + VCPKG_LINE_INFO, toolset != vs_toolsets.end(), "Could not find toolset '%s'", toolset_version); + return *toolset; + } } + Files::Filesystem& VcpkgPaths::get_filesystem() const { return Files::get_real_filesystem(); } } |
