diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2020-02-08 22:45:36 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-08 22:45:36 -0800 |
| commit | f7fb56decd9d03cf79a1d23f44daa3a23560b995 (patch) | |
| tree | 3ab3d78aa90da2d368a16b65ae624e263e26d19e /toolsrc/include | |
| parent | b20c6d3b89b9fa22a19e3609e6df2fcfc20f968f (diff) | |
| download | vcpkg-f7fb56decd9d03cf79a1d23f44daa3a23560b995.tar.gz vcpkg-f7fb56decd9d03cf79a1d23f44daa3a23560b995.zip | |
[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
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/vcpkg/base/checks.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/system.process.h | 28 |
2 files changed, 26 insertions, 5 deletions
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 <vcpkg/base/files.h> #include <vcpkg/base/zstringview.h> +#include <functional> #include <string> #include <unordered_map> #include <vector> @@ -30,17 +31,34 @@ namespace vcpkg::System std::string output; }; - int cmd_execute_clean(const ZStringView cmd_line, - const std::unordered_map<std::string, std::string>& 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<std::string, std::string>& 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<void(const std::string&)> per_line_cb, + const Environment& env = {}); + int cmd_execute_and_stream_data(const ZStringView cmd_line, + std::function<void(StringView)> data_cb, + const Environment& env = {}); void register_console_ctrl_handler(); } |
