From 14c792441dc5963d0d17cb2e7a6dc1b2f7665d9b Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 23 Jul 2019 01:46:36 -0700 Subject: [vcpkg] Revert accidental removal of powershell-core usage in bb3a9ddb6ec917f54 --- toolsrc/src/vcpkg/build.cpp | 17 ++++++++++++++++- toolsrc/src/vcpkg/tools.cpp | 45 ++++++++++++++++----------------------------- 2 files changed, 32 insertions(+), 30 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 02d4c4a71..5b93242a1 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -499,6 +499,14 @@ namespace vcpkg::Build const BuildPackageConfig& config) { auto& fs = paths.get_filesystem(); +#if defined(_WIN32) + const fs::path& powershell_exe_path = paths.get_tool_exe("powershell-core"); + if (!fs.exists(powershell_exe_path.parent_path() / "powershell.exe")) + { + fs.copy(powershell_exe_path, powershell_exe_path.parent_path() / "powershell.exe", fs::copy_options::none); + } +#endif + const Triplet& triplet = spec.triplet(); const auto& triplet_file_path = paths.get_triplet_file_path(spec.triplet()).u8string(); @@ -516,8 +524,12 @@ namespace vcpkg::Build std::string command = make_build_cmd(paths, pre_build_info, config, triplet); std::unordered_map env = make_env_passthrough(pre_build_info); +#if defined(_WIN32) + const int return_code = + System::cmd_execute_clean(command, env, powershell_exe_path.parent_path().u8string() + ";"); +#else const int return_code = System::cmd_execute_clean(command, env); - +#endif const auto buildtimeus = timer.microseconds(); const auto spec_string = spec.to_string(); @@ -597,6 +609,9 @@ namespace vcpkg::Build std::vector abi_tag_entries(dependency_abis.begin(), dependency_abis.end()); +#if defined(_WIN32) + abi_tag_entries.emplace_back(AbiEntry{"powershell", paths.get_tool_version("powershell-core")}); +#endif abi_tag_entries.emplace_back(AbiEntry{"cmake", paths.get_tool_version(Tools::CMAKE)}); // If there is an unusually large number of files in the port then diff --git a/toolsrc/src/vcpkg/tools.cpp b/toolsrc/src/vcpkg/tools.cpp index 4f4b23055..7d56854c6 100644 --- a/toolsrc/src/vcpkg/tools.cpp +++ b/toolsrc/src/vcpkg/tools.cpp @@ -294,20 +294,6 @@ CMake suite maintained and supported by Kitware (kitware.com/cmake). } }; - static fs::path get_7za_path(const VcpkgPaths& paths) - { -#if defined(_WIN32) - static const ToolData TOOL_DATA = parse_tool_data_from_xml(paths, "7zip").value_or_exit(VCPKG_LINE_INFO); - if (!paths.get_filesystem().exists(TOOL_DATA.exe_path)) - { - return fetch_tool(paths, "7zip", TOOL_DATA); - } - return TOOL_DATA.exe_path; -#else - Checks::exit_with_message(VCPKG_LINE_INFO, "Cannot download 7zip for non-Windows platforms."); -#endif - } - struct NinjaProvider : ToolProvider { std::string m_exe = "ninja"; @@ -443,31 +429,21 @@ git version 2.17.1.windows.2 virtual const fs::path& get_tool_path(const VcpkgPaths& paths, const std::string& tool) const override { return path_only_cache.get_lazy(tool, [&]() { - // First deal with specially handled tools. - // For these we may look in locations like Program Files, the PATH etc as well as the auto-downloaded - // location. - if (tool == Tools::SEVEN_ZIP) return get_7za_path(paths); - if (tool == Tools::CMAKE || tool == Tools::GIT || tool == Tools::NINJA || tool == Tools::NUGET || - tool == Tools::IFW_INSTALLER_BASE) - return get_tool_pathversion(paths, tool).path; if (tool == Tools::IFW_BINARYCREATOR) return get_tool_path(paths, Tools::IFW_INSTALLER_BASE).parent_path() / "binarycreator.exe"; if (tool == Tools::IFW_REPOGEN) return get_tool_path(paths, Tools::IFW_INSTALLER_BASE).parent_path() / "repogen.exe"; - // For other tools, we simply always auto-download them. - const ToolData tool_data = parse_tool_data_from_xml(paths, tool).value_or_exit(VCPKG_LINE_INFO); - if (paths.get_filesystem().exists(tool_data.exe_path)) - { - return tool_data.exe_path; - } - return fetch_tool(paths, tool, tool_data); + return get_tool_pathversion(paths, tool).path; }); } const PathAndVersion& get_tool_pathversion(const VcpkgPaths& paths, const std::string& tool) const { return path_version_cache.get_lazy(tool, [&]() -> PathAndVersion { + // First deal with specially handled tools. + // For these we may look in locations like Program Files, the PATH etc as well as the auto-downloaded + // location. if (tool == Tools::CMAKE) { if (System::get_environment_variable("VCPKG_FORCE_SYSTEM_BINARIES").has_value()) @@ -495,7 +471,18 @@ git version 2.17.1.windows.2 if (tool == Tools::NUGET) return get_path(paths, NuGetProvider()); if (tool == Tools::IFW_INSTALLER_BASE) return get_path(paths, IfwInstallerBaseProvider()); - Checks::exit_with_message(VCPKG_LINE_INFO, "Finding version for %s is not implemented yet.", tool); + // For other tools, we simply always auto-download them. + auto maybe_tool_data = parse_tool_data_from_xml(paths, tool); + if (auto p_tool_data = maybe_tool_data.get()) + { + if (paths.get_filesystem().exists(p_tool_data->exe_path)) + { + return {p_tool_data->exe_path, p_tool_data->sha512}; + } + return {fetch_tool(paths, tool, *p_tool_data), p_tool_data->sha512}; + } + + Checks::exit_with_message(VCPKG_LINE_INFO, "Unknown or unavailable tool: %s", tool); }); } -- cgit v1.2.3