From f7fb56decd9d03cf79a1d23f44daa3a23560b995 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Sat, 8 Feb 2020 22:45:36 -0800 Subject: [vcpkg] Use CreateProcess on Windows. Improve EnvVars manipulation and handling. (#9897) * [vcpkg] Rewrite process spawning on windows to always use CreateProcess, enabling better environment handling * [vcpkg] Use environment cache to avoid calling vcvars multiple times * [vcpkg] Increase buffer size while computing hashes * [vcpkg] Remove unneeded cmd.exe wrapper process on all CreateProcess calls * [vcpkg] Fix .vcxproj{,.filters} * [vcpkg] Upgrade Ctrl-C state machine to handle multiple background processes. * [vcpkg] Fix regression while launching metrics: 'start' can't be passed directly to CreateProcessW * [vcpkg] Fix typo on non-Windows * [vcpkg] Fix various uses of >NUL across the code * [vcpkg] Fix various uses of >NUL across the code --- toolsrc/include/vcpkg/base/checks.h | 3 +++ toolsrc/include/vcpkg/base/system.process.h | 28 +++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/checks.h b/toolsrc/include/vcpkg/base/checks.h index 3c0c073d2..519ca58f4 100644 --- a/toolsrc/include/vcpkg/base/checks.h +++ b/toolsrc/include/vcpkg/base/checks.h @@ -8,6 +8,9 @@ namespace vcpkg::Checks { void register_global_shutdown_handler(void (*func)()); + // Note: for internal use + [[noreturn]] void final_cleanup_and_exit(const int exit_code); + // Indicate that an internal error has occurred and exit the tool. This should be used when invariants have been // broken. [[noreturn]] void unreachable(const LineInfo& line_info); diff --git a/toolsrc/include/vcpkg/base/system.process.h b/toolsrc/include/vcpkg/base/system.process.h index 14e2eb109..b2e76ff74 100644 --- a/toolsrc/include/vcpkg/base/system.process.h +++ b/toolsrc/include/vcpkg/base/system.process.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -30,17 +31,34 @@ namespace vcpkg::System std::string output; }; - int cmd_execute_clean(const ZStringView cmd_line, - const std::unordered_map& extra_env = {}, - const std::string& prepend_to_path = {}); + struct Environment + { +#if defined(_WIN32) + std::wstring m_env_data; +#endif + }; - int cmd_execute(const ZStringView cmd_line); + const Environment& get_clean_environment(); + Environment get_modified_clean_environment(const std::unordered_map& extra_env, + const std::string& prepend_to_path = {}); + + int cmd_execute(const ZStringView cmd_line, const Environment& env = {}); + int cmd_execute_clean(const ZStringView cmd_line); #if defined(_WIN32) + Environment cmd_execute_modify_env(const ZStringView cmd_line, const Environment& env = {}); + void cmd_execute_no_wait(const StringView cmd_line); #endif - ExitCodeAndOutput cmd_execute_and_capture_output(const ZStringView cmd_line); + ExitCodeAndOutput cmd_execute_and_capture_output(const ZStringView cmd_line, const Environment& env = {}); + + int cmd_execute_and_stream_lines(const ZStringView cmd_line, + std::function per_line_cb, + const Environment& env = {}); + int cmd_execute_and_stream_data(const ZStringView cmd_line, + std::function data_cb, + const Environment& env = {}); void register_console_ctrl_handler(); } -- cgit v1.2.3