diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2019-07-06 13:29:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-06 13:29:46 -0700 |
| commit | 2b8e225b2ea83a3138d4b7345f104c1bd9a129dd (patch) | |
| tree | 531f1a62e608c7751b87a121da7507da13f1a476 /toolsrc/src | |
| parent | 17b5841bc36a13f950af8b052335b2ea56b05db5 (diff) | |
| download | vcpkg-2b8e225b2ea83a3138d4b7345f104c1bd9a129dd.tar.gz vcpkg-2b8e225b2ea83a3138d4b7345f104c1bd9a129dd.zip | |
[vcpkg] Fix powershell font corruption bug (#7094)
* [vcpkg] Fix font corruption bug on Windows by downloading Powershell Core
* [vcpkg] Rename subtool to powershell-core
* [vcpkg] Add missing includes to project files
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg/base/system.cpp | 21 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/build.cpp | 23 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/commands.integrate.cpp | 11 |
3 files changed, 31 insertions, 24 deletions
diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp index c5ff050f0..3d5c60088 100644 --- a/toolsrc/src/vcpkg/base/system.cpp +++ b/toolsrc/src/vcpkg/base/system.cpp @@ -188,12 +188,17 @@ namespace vcpkg } #if defined(_WIN32) - static std::wstring compute_clean_environment(const std::unordered_map<std::string, std::string>& extra_env) + static std::wstring compute_clean_environment(const std::unordered_map<std::string, std::string>& extra_env, + const std::string& prepend_to_path) { static const std::string SYSTEM_ROOT = get_environment_variable("SystemRoot").value_or_exit(VCPKG_LINE_INFO); static const std::string SYSTEM_32 = SYSTEM_ROOT + R"(\system32)"; - std::string new_path = Strings::format( - R"(Path=%s;%s;%s\Wbem;%s\WindowsPowerShell\v1.0\)", SYSTEM_32, SYSTEM_ROOT, SYSTEM_32, SYSTEM_32); + std::string new_path = Strings::format(R"(Path=%s%s;%s;%s\Wbem;%s\WindowsPowerShell\v1.0\)", + prepend_to_path, + SYSTEM_32, + SYSTEM_ROOT, + SYSTEM_32, + SYSTEM_32); std::vector<std::wstring> env_wstrings = { L"ALLUSERSPROFILE", @@ -348,7 +353,8 @@ namespace vcpkg #endif int System::cmd_execute_clean(const ZStringView cmd_line, - const std::unordered_map<std::string, std::string>& extra_env) + const std::unordered_map<std::string, std::string>& extra_env, + const std::string& prepend_to_path) { auto timer = Chrono::ElapsedTimer::create_started(); #if defined(_WIN32) @@ -357,7 +363,7 @@ namespace vcpkg memset(&process_info, 0, sizeof(PROCESS_INFORMATION)); g_ctrl_c_state.transition_to_spawn_process(); - auto clean_env = compute_clean_environment(extra_env); + auto clean_env = compute_clean_environment(extra_env, prepend_to_path); windows_create_process(cmd_line, clean_env.data(), process_info, NULL); CloseHandle(process_info.hThread); @@ -608,10 +614,7 @@ namespace vcpkg void System::register_console_ctrl_handler() {} #endif - int System::get_num_logical_cores() - { - return std::thread::hardware_concurrency(); - } + int System::get_num_logical_cores() { return std::thread::hardware_concurrency(); } } namespace vcpkg::Debug diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 1975d3aaf..68df1f965 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -363,13 +363,11 @@ namespace vcpkg::Build const Triplet& triplet = spec.triplet();
const auto& triplet_file_path = paths.get_triplet_file_path(spec.triplet()).u8string();
- if (!Strings::case_insensitive_ascii_starts_with(triplet_file_path,
- paths.triplets.u8string()))
+ if (!Strings::case_insensitive_ascii_starts_with(triplet_file_path, paths.triplets.u8string()))
{
System::printf("-- Loading triplet configuration from: %s\n", triplet_file_path);
}
- if (!Strings::case_insensitive_ascii_starts_with(config.port_dir.u8string(),
- paths.ports.u8string()))
+ if (!Strings::case_insensitive_ascii_starts_with(config.port_dir.u8string(), paths.ports.u8string()))
{
System::printf("-- Installing port from location: %s\n", config.port_dir.u8string());
}
@@ -382,6 +380,13 @@ namespace vcpkg::Build const fs::path& cmake_exe_path = paths.get_tool_exe(Tools::CMAKE);
const fs::path& git_exe_path = paths.get_tool_exe(Tools::GIT);
+#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
std::string all_features;
for (auto& feature : config.scf.feature_paragraphs)
@@ -425,8 +430,14 @@ namespace vcpkg::Build }
command.append(cmd_launch_cmake);
const auto timer = Chrono::ElapsedTimer::create_started();
-
- const int return_code = System::cmd_execute_clean(command);
+ const int return_code = System::cmd_execute_clean(
+ command,
+ {}
+#ifdef _WIN32
+ ,
+ powershell_exe_path.parent_path().u8string() + ";"
+#endif
+ );
const auto buildtimeus = timer.microseconds();
const auto spec_string = spec.to_string();
diff --git a/toolsrc/src/vcpkg/commands.integrate.cpp b/toolsrc/src/vcpkg/commands.integrate.cpp index fda9e2b11..8b2b377bf 100644 --- a/toolsrc/src/vcpkg/commands.integrate.cpp +++ b/toolsrc/src/vcpkg/commands.integrate.cpp @@ -380,17 +380,10 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console static constexpr StringLiteral TITLE = "PowerShell Tab-Completion"; const fs::path script_path = paths.scripts / "addPoshVcpkgToPowershellProfile.ps1"; - // Console font corruption workaround - SetConsoleCP(437); - SetConsoleOutputCP(437); - + const auto& ps = paths.get_tool_exe("powershell-core"); const std::string cmd = Strings::format( - R"(powershell -NoProfile -ExecutionPolicy Bypass -Command "& {& '%s' %s}")", script_path.u8string(), ""); + R"("%s" -NoProfile -ExecutionPolicy Bypass -Command "& {& '%s' }")", ps.u8string(), script_path.u8string()); const int rc = System::cmd_execute(cmd); - - SetConsoleCP(CP_UTF8); - SetConsoleOutputCP(CP_UTF8); - if (rc) { System::printf(System::Color::error, |
