windows exception handler
Some checks failed
demo.yaml / windows exception handler (push) Failing after 0s

This commit is contained in:
Jorijn van der Graaf 2026-03-09 20:14:44 +01:00
commit 7a64859d24
18 changed files with 38 additions and 18 deletions

View file

@ -1,6 +1,6 @@
/*
Crafter.Build
Copyright (C) 2025 Catcrafts®
Copyright (C) 2026 Catcrafts®
Catcrafts.net
This library is free software; you can redistribute it and/or
@ -17,11 +17,31 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
#if defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_windows_msvc) || defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32)
#include <windows.h>
#endif
import Crafter.Build;
import std;
using namespace Crafter;
namespace fs = std::filesystem;
#if defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_windows_msvc) || defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32)
void terminateHandler() {
try {
if (auto e = std::current_exception()) {
std::rethrow_exception(e);
}
} catch (const std::exception& e) {
MessageBoxA(nullptr, e.what(), "Unhandled Exception", MB_ICONERROR | MB_OK);
}
std::abort();
}
#endif
int main(int argc, char* argv[]) {
#if defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_windows_msvc) || defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32)
std::set_terminate(terminateHandler);
#endif
if(std::string(argv[1]) == "--help" || std::string(argv[1]) == "help" ) {
std::println("Crafter.Build - A modern build system for C++ projects\n");
std::println("Usage: crafter-build [command] [options]");