From 7a64859d243c82a194e0ebe21241520f5526a986 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Mon, 9 Mar 2026 20:14:44 +0100 Subject: [PATCH] windows exception handler --- implementations/Crafter.Build-Command.cpp | 2 +- .../Crafter.Build-Configuration.cpp | 2 +- .../Crafter.Build-Implementation.cpp | 2 +- implementations/Crafter.Build-Module.cpp | 2 +- implementations/Crafter.Build-Project.cpp | 2 +- implementations/Crafter.Build-Shader.cpp | 2 +- implementations/Crafter.Build-Test.cpp | 2 +- implementations/main.cpp | 22 ++++++++++++++++++- interfaces/Crafter.Build-Command.cppm | 2 +- interfaces/Crafter.Build-CompileStatus.cppm | 2 +- interfaces/Crafter.Build-Configuration.cppm | 2 +- interfaces/Crafter.Build-Implementation.cppm | 2 +- interfaces/Crafter.Build-Module.cppm | 2 +- interfaces/Crafter.Build-Project.cppm | 2 +- interfaces/Crafter.Build-Shader.cppm | 2 +- interfaces/Crafter.Build-Test.cppm | 2 +- interfaces/Crafter.Build.cppm | 2 +- tests/ShouldCompile.cpp | 2 +- 18 files changed, 38 insertions(+), 18 deletions(-) diff --git a/implementations/Crafter.Build-Command.cpp b/implementations/Crafter.Build-Command.cpp index c1c77ee..69beeb9 100644 --- a/implementations/Crafter.Build-Command.cpp +++ b/implementations/Crafter.Build-Command.cpp @@ -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 diff --git a/implementations/Crafter.Build-Configuration.cpp b/implementations/Crafter.Build-Configuration.cpp index d3d1a4e..54a6347 100644 --- a/implementations/Crafter.Build-Configuration.cpp +++ b/implementations/Crafter.Build-Configuration.cpp @@ -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 diff --git a/implementations/Crafter.Build-Implementation.cpp b/implementations/Crafter.Build-Implementation.cpp index 8c6ed17..0026eeb 100644 --- a/implementations/Crafter.Build-Implementation.cpp +++ b/implementations/Crafter.Build-Implementation.cpp @@ -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 diff --git a/implementations/Crafter.Build-Module.cpp b/implementations/Crafter.Build-Module.cpp index 53bbcb5..83bd202 100644 --- a/implementations/Crafter.Build-Module.cpp +++ b/implementations/Crafter.Build-Module.cpp @@ -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 diff --git a/implementations/Crafter.Build-Project.cpp b/implementations/Crafter.Build-Project.cpp index 470471f..5161dec 100644 --- a/implementations/Crafter.Build-Project.cpp +++ b/implementations/Crafter.Build-Project.cpp @@ -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 diff --git a/implementations/Crafter.Build-Shader.cpp b/implementations/Crafter.Build-Shader.cpp index 4e92450..9d8eff4 100644 --- a/implementations/Crafter.Build-Shader.cpp +++ b/implementations/Crafter.Build-Shader.cpp @@ -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 diff --git a/implementations/Crafter.Build-Test.cpp b/implementations/Crafter.Build-Test.cpp index 9fcace9..4a93de4 100644 --- a/implementations/Crafter.Build-Test.cpp +++ b/implementations/Crafter.Build-Test.cpp @@ -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 diff --git a/implementations/main.cpp b/implementations/main.cpp index 43c35ce..259f897 100644 --- a/implementations/main.cpp +++ b/implementations/main.cpp @@ -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 +#if defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_windows_msvc) || defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32) +#include +#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]"); diff --git a/interfaces/Crafter.Build-Command.cppm b/interfaces/Crafter.Build-Command.cppm index bc127d0..48f3670 100644 --- a/interfaces/Crafter.Build-Command.cppm +++ b/interfaces/Crafter.Build-Command.cppm @@ -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 diff --git a/interfaces/Crafter.Build-CompileStatus.cppm b/interfaces/Crafter.Build-CompileStatus.cppm index b2d694a..af38f88 100644 --- a/interfaces/Crafter.Build-CompileStatus.cppm +++ b/interfaces/Crafter.Build-CompileStatus.cppm @@ -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 diff --git a/interfaces/Crafter.Build-Configuration.cppm b/interfaces/Crafter.Build-Configuration.cppm index 65f9866..aad83d6 100644 --- a/interfaces/Crafter.Build-Configuration.cppm +++ b/interfaces/Crafter.Build-Configuration.cppm @@ -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 diff --git a/interfaces/Crafter.Build-Implementation.cppm b/interfaces/Crafter.Build-Implementation.cppm index a6eb448..06a3cf3 100644 --- a/interfaces/Crafter.Build-Implementation.cppm +++ b/interfaces/Crafter.Build-Implementation.cppm @@ -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 diff --git a/interfaces/Crafter.Build-Module.cppm b/interfaces/Crafter.Build-Module.cppm index f5f2331..daefafd 100644 --- a/interfaces/Crafter.Build-Module.cppm +++ b/interfaces/Crafter.Build-Module.cppm @@ -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 diff --git a/interfaces/Crafter.Build-Project.cppm b/interfaces/Crafter.Build-Project.cppm index a072d0e..4ee2522 100644 --- a/interfaces/Crafter.Build-Project.cppm +++ b/interfaces/Crafter.Build-Project.cppm @@ -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 diff --git a/interfaces/Crafter.Build-Shader.cppm b/interfaces/Crafter.Build-Shader.cppm index 25cbcaf..134c514 100644 --- a/interfaces/Crafter.Build-Shader.cppm +++ b/interfaces/Crafter.Build-Shader.cppm @@ -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 diff --git a/interfaces/Crafter.Build-Test.cppm b/interfaces/Crafter.Build-Test.cppm index 5f94437..84566d7 100644 --- a/interfaces/Crafter.Build-Test.cppm +++ b/interfaces/Crafter.Build-Test.cppm @@ -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 diff --git a/interfaces/Crafter.Build.cppm b/interfaces/Crafter.Build.cppm index 01df9da..1751335 100644 --- a/interfaces/Crafter.Build.cppm +++ b/interfaces/Crafter.Build.cppm @@ -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 diff --git a/tests/ShouldCompile.cpp b/tests/ShouldCompile.cpp index cab62ba..46daab0 100644 --- a/tests/ShouldCompile.cpp +++ b/tests/ShouldCompile.cpp @@ -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