Introduce Checks::exit_with_code() and exit_fail()/exit_success()

This commit is contained in:
Alexander Karatarakis 2017-03-22 17:08:59 -07:00
parent 5c504265f3
commit 197d471b42
2 changed files with 18 additions and 0 deletions

View File

@ -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);

View File

@ -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);