diff options
| author | Albert Ziegenhagel <albert.ziegenhagel@outlook.com> | 2017-06-02 18:13:12 +0200 |
|---|---|---|
| committer | Albert Ziegenhagel <albert.ziegenhagel@outlook.com> | 2017-06-02 18:13:12 +0200 |
| commit | 1253b875195590e528d8a28e12a798264603ba43 (patch) | |
| tree | 1437afe08ae54110f42c442bcb0d8a487cd01367 /toolsrc/src | |
| parent | 3ebcdd384b58ff5d5f92996a6eb2e9fed0be1710 (diff) | |
| download | vcpkg-1253b875195590e528d8a28e12a798264603ba43.tar.gz vcpkg-1253b875195590e528d8a28e12a798264603ba43.zip | |
Implement support to request a specific toolset version via the variable `VCPKG_PLATFORM_TOOLSET` in the triplet file
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/PostBuildLint.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/VcpkgPaths.cpp | 63 | ||||
| -rw-r--r-- | toolsrc/src/commands_env.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Build.cpp | 2 |
4 files changed, 56 insertions, 13 deletions
diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp index bcad27032..363346ab6 100644 --- a/toolsrc/src/PostBuildLint.cpp +++ b/toolsrc/src/PostBuildLint.cpp @@ -733,7 +733,7 @@ namespace vcpkg::PostBuildLint const auto& fs = paths.get_filesystem(); // for dumpbin - const Toolset& toolset = paths.get_toolset(); + const Toolset& toolset = paths.get_toolset(pre_build_info.platform_toolset); const fs::path package_dir = paths.package_dir(spec); size_t error_count = 0; diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp index 3dd32de01..acd847b5f 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,10 @@ 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; + // VS2017 + Optional<Toolset> vs2017_toolset; for (const fs::path& instance : vs2017_installation_instances) { const fs::path vc_dir = instance / "VC"; @@ -303,9 +306,15 @@ 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(vs2017_toolset) break; + } + if(auto value = vs2017_toolset.get()) + { + found_toolsets.push_back(*value); } // VS2015 @@ -321,23 +330,57 @@ namespace vcpkg paths_examined.push_back(vs2015_dumpbin_exe); if (fs.exists(vs2015_dumpbin_exe)) { - return {vs2015_dumpbin_exe, vs2015_vcvarsall_bat, L"v140"}; + found_toolsets.push_back({vs2015_dumpbin_exe, vs2015_vcvarsall_bat, L"v140"}); } } } - 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) + std::sort(found_toolsets.begin(), + found_toolsets.end(), + [](const Toolset& left, const Toolset& right) { return left.version > right.version; }); + + if(found_toolsets.empty()) { - System::println(" %s", path.u8string()); + 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); } - Checks::exit_fail(VCPKG_LINE_INFO); + + return found_toolsets; + } + + const std::vector<Toolset>& VcpkgPaths::get_toolsets() const + { + return this->toolsets.get_lazy([this]() { return find_toolset_instances(*this); }); } - const Toolset& VcpkgPaths::get_toolset() const + const Toolset& VcpkgPaths::get_latest_toolset() const { - return this->toolset.get_lazy([this]() { return find_toolset_instance(*this); }); + // Invariant: toolsets are non-empty and sorted + return get_toolsets().back(); } + const Toolset& VcpkgPaths::get_toolset(const std::string& toolset_version) const + { + if(toolset_version.empty()) + { + return this->get_latest_toolset(); + } + else + { + const auto& vs_toolsets = this->get_toolsets(); + + const auto toolset = Util::find_if(vs_toolsets, [&](const Toolset& toolset) { return toolset_version == Strings::to_utf8(toolset.version); }); + if(toolset == vs_toolsets.end()) + { + Checks::exit_with_message(VCPKG_LINE_INFO, Strings::format("Could not find toolset %s", toolset_version)); + } + return *toolset; + } + } + Files::Filesystem& VcpkgPaths::get_filesystem() const { return Files::get_real_filesystem(); } } diff --git a/toolsrc/src/commands_env.cpp b/toolsrc/src/commands_env.cpp index 5e1ecc5e7..dd7172b89 100644 --- a/toolsrc/src/commands_env.cpp +++ b/toolsrc/src/commands_env.cpp @@ -13,7 +13,7 @@ namespace vcpkg::Commands::Env args.check_and_get_optional_command_arguments({}); auto pre_build_info = Build::PreBuildInfo::from_triplet_file(paths, default_triplet); - System::cmd_execute_clean(Build::make_build_env_cmd(pre_build_info, paths.get_toolset()) + L" && cmd"); + System::cmd_execute_clean(Build::make_build_env_cmd(pre_build_info, paths.get_toolset(pre_build_info.platform_toolset)) + L" && cmd"); Checks::exit_success(VCPKG_LINE_INFO); } diff --git a/toolsrc/src/vcpkg_Build.cpp b/toolsrc/src/vcpkg_Build.cpp index d44a673fc..817febe2f 100644 --- a/toolsrc/src/vcpkg_Build.cpp +++ b/toolsrc/src/vcpkg_Build.cpp @@ -128,8 +128,8 @@ namespace vcpkg::Build const fs::path& git_exe_path = paths.get_git_exe(); const fs::path ports_cmake_script_path = paths.ports_cmake; - const Toolset& toolset = paths.get_toolset(); auto pre_build_info = PreBuildInfo::from_triplet_file(paths, triplet); + const Toolset& toolset = paths.get_toolset(pre_build_info.platform_toolset); const auto cmd_set_environment = make_build_env_cmd(pre_build_info, toolset); const std::wstring cmd_launch_cmake = |
