From 197d471b42dcffa15e254ec38c654d33f1f050fe Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 22 Mar 2017 17:08:59 -0700 Subject: Introduce Checks::exit_with_code() and exit_fail()/exit_success() --- toolsrc/include/vcpkg_Checks.h | 12 ++++++++++++ toolsrc/src/vcpkg_Checks.cpp | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/toolsrc/include/vcpkg_Checks.h b/toolsrc/include/vcpkg_Checks.h index 47662637f..336462e54 100644 --- a/toolsrc/include/vcpkg_Checks.h +++ b/toolsrc/include/vcpkg_Checks.h @@ -7,6 +7,18 @@ namespace vcpkg::Checks { __declspec(noreturn) void unreachable(const LineInfo& line_info); + _declspec(noreturn) void exit_with_code(const LineInfo& line_info, const int exit_code); + + _declspec(noreturn) inline void exit_fail(const LineInfo& line_info) + { + return exit_with_code(line_info, EXIT_FAILURE); + } + + _declspec(noreturn) inline void exit_success(const LineInfo& line_info) + { + return exit_with_code(line_info, EXIT_SUCCESS); + } + // Part of the reason these exist is to not include extra headers in this one to avoid circular #includes. _declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessage); diff --git a/toolsrc/src/vcpkg_Checks.cpp b/toolsrc/src/vcpkg_Checks.cpp index 81e7d3825..4e0f9bfba 100644 --- a/toolsrc/src/vcpkg_Checks.cpp +++ b/toolsrc/src/vcpkg_Checks.cpp @@ -24,6 +24,12 @@ namespace vcpkg::Checks #endif } + void exit_with_code(const LineInfo& line_info, const int exit_code) + { + print_line_info_if_debug(line_info); + exit(exit_code); + } + __declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessage) { System::println(System::color::error, errorMessage); -- cgit v1.2.3