From 9633c8c2b70d230ec0c0825e29f52722744afcb4 Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 28 Nov 2016 20:21:21 +0100 Subject: [PATCH] Core/Debugging: Partially revert e0fb4445cd2f5f4bb94ea23122548debddc41ba6, the cmake hack to build wheaty directly into executable is still needed as it is impossible to have it initialize before every other static variable when it resides in dll (dynamic linking only) --- src/CMakeLists.txt | 7 +++++++ src/common/CMakeLists.txt | 8 ++++++++ src/common/Debugging/WheatyExceptionReport.cpp | 5 ----- src/common/Debugging/WheatyExceptionReport.h | 3 --- src/server/CMakeLists.txt | 2 +- src/server/bnetserver/Main.cpp | 2 -- src/server/worldserver/Main.cpp | 2 -- src/tools/connection_patcher/CMakeLists.txt | 4 ++++ src/tools/connection_patcher/Program.cpp | 2 -- src/tools/map_extractor/CMakeLists.txt | 4 ++++ src/tools/mmaps_generator/CMakeLists.txt | 4 ++++ src/tools/mmaps_generator/PathGenerator.cpp | 2 -- src/tools/vmap4_assembler/CMakeLists.txt | 8 +++++++- src/tools/vmap4_assembler/VMapAssembler.cpp | 4 +--- src/tools/vmap4_extractor/CMakeLists.txt | 4 ++++ src/tools/vmap4_extractor/vmapexport.cpp | 2 -- 16 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7563d0e11c..11b89e8dc7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,6 +8,13 @@ # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +if(WIN32) + set(sources_windows + ${CMAKE_SOURCE_DIR}/src/common/Debugging/WheatyExceptionReport.cpp + ${CMAKE_SOURCE_DIR}/src/common/Debugging/WheatyExceptionReport.h + ) +endif(WIN32) + add_subdirectory(genrev) add_subdirectory(common) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 231951ed28..0428738f2d 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -12,9 +12,17 @@ CollectSourceFiles( ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE_SOURCES # Exclude + ${CMAKE_CURRENT_SOURCE_DIR}/Debugging ${CMAKE_CURRENT_SOURCE_DIR}/Platform ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders) +# Manually set sources for Debugging directory as we don't want to include WheatyExceptionReport in common project +# It needs to be included both in authserver and worldserver for the static global variable to be properly initialized +# and to handle crash logs on windows +list(APPEND PRIVATE_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/Debugging/Errors.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Debugging/Errors.h) + if (USE_COREPCH) set(PRIVATE_PCH_HEADER PrecompiledHeaders/commonPCH.h) set(PRIVATE_PCH_SOURCE PrecompiledHeaders/commonPCH.cpp) diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index 29d9a35af8..68226d9c3a 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -1463,8 +1463,3 @@ char* WheatyExceptionReport::PrintSymbolDetail(char* pszCurrBuffer) } #endif // _WIN32 - -void InitializeCrashHandler() -{ - // dummy call to make the linker not discard the compilation unit -} diff --git a/src/common/Debugging/WheatyExceptionReport.h b/src/common/Debugging/WheatyExceptionReport.h index de6b6f375e..34919b19e0 100644 --- a/src/common/Debugging/WheatyExceptionReport.h +++ b/src/common/Debugging/WheatyExceptionReport.h @@ -210,8 +210,5 @@ class WheatyExceptionReport extern WheatyExceptionReport g_WheatyExceptionReport; // global instance of class #endif // _WIN32 - -// dummy call to make the linker not discard the compilation unit -void InitializeCrashHandler(); #endif // _WHEATYEXCEPTIONREPORT_ diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index d600de2f35..6275219e15 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -17,7 +17,7 @@ if(CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW) endif() if(WIN32) - set(sources_windows + list(APPEND sources_windows ${CMAKE_SOURCE_DIR}/src/common/Platform/ServiceWin32.cpp ${CMAKE_SOURCE_DIR}/src/common/Platform/ServiceWin32.h ) diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp index a17872303d..56eff7c0c0 100644 --- a/src/server/bnetserver/Main.cpp +++ b/src/server/bnetserver/Main.cpp @@ -32,7 +32,6 @@ #include "SslContext.h" #include "DatabaseLoader.h" #include "LoginRESTService.h" -#include "WheatyExceptionReport.h" #include #include #include @@ -78,7 +77,6 @@ static uint32 _banExpiryCheckInterval; int main(int argc, char** argv) { - InitializeCrashHandler(); signal(SIGABRT, &Trinity::AbortHandler); auto configFile = fs::absolute(_TRINITY_BNET_CONFIG); diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 293afc4757..68c48853ba 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -47,7 +47,6 @@ #include "DatabaseLoader.h" #include "AppenderDB.h" #include "Metric.h" -#include "WheatyExceptionReport.h" #include #include #include @@ -100,7 +99,6 @@ variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, s /// Launch the Trinity server extern int main(int argc, char** argv) { - InitializeCrashHandler(); signal(SIGABRT, &Trinity::AbortHandler); auto configFile = fs::absolute(_TRINITY_CORE_CONFIG); diff --git a/src/tools/connection_patcher/CMakeLists.txt b/src/tools/connection_patcher/CMakeLists.txt index 3fad34fabb..7582cf8fb6 100644 --- a/src/tools/connection_patcher/CMakeLists.txt +++ b/src/tools/connection_patcher/CMakeLists.txt @@ -26,6 +26,10 @@ set(SRC_FILES Program.cpp ) +if (WIN32) + list(APPEND SRC_FILES ${sources_windows}) +endif() + add_executable(connection_patcher ${HEADER_FILES} ${SRC_FILES}) if (MSVC) diff --git a/src/tools/connection_patcher/Program.cpp b/src/tools/connection_patcher/Program.cpp index b19d4f1914..354cfa1719 100644 --- a/src/tools/connection_patcher/Program.cpp +++ b/src/tools/connection_patcher/Program.cpp @@ -27,7 +27,6 @@ #include "Banner.h" #include "CompilerDefs.h" -#include "WheatyExceptionReport.h" #include #include @@ -129,7 +128,6 @@ namespace Connection_Patcher int main(int argc, char** argv) { - InitializeCrashHandler(); using namespace Connection_Patcher; try diff --git a/src/tools/map_extractor/CMakeLists.txt b/src/tools/map_extractor/CMakeLists.txt index 656bee3d5a..09bb179265 100644 --- a/src/tools/map_extractor/CMakeLists.txt +++ b/src/tools/map_extractor/CMakeLists.txt @@ -13,6 +13,10 @@ CollectSourceFiles( ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE_SOURCES) +if (WIN32) + list(APPEND PRIVATE_SOURCES ${sources_windows}) +endif() + add_executable(mapextractor ${PRIVATE_SOURCES} ) diff --git a/src/tools/mmaps_generator/CMakeLists.txt b/src/tools/mmaps_generator/CMakeLists.txt index 7e34fea6ac..2efb42a2b8 100644 --- a/src/tools/mmaps_generator/CMakeLists.txt +++ b/src/tools/mmaps_generator/CMakeLists.txt @@ -12,6 +12,10 @@ CollectSourceFiles( ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE_SOURCES) +if (WIN32) + list(APPEND PRIVATE_SOURCES ${sources_windows}) +endif() + add_executable(mmaps_generator ${PRIVATE_SOURCES}) target_link_libraries(mmaps_generator diff --git a/src/tools/mmaps_generator/PathGenerator.cpp b/src/tools/mmaps_generator/PathGenerator.cpp index c2c0146eb1..b396bdf5a3 100644 --- a/src/tools/mmaps_generator/PathGenerator.cpp +++ b/src/tools/mmaps_generator/PathGenerator.cpp @@ -22,7 +22,6 @@ #include "MapBuilder.h" #include "Timer.h" #include "Banner.h" -#include "WheatyExceptionReport.h" using namespace MMAP; @@ -243,7 +242,6 @@ int finish(const char* message, int returnValue) int main(int argc, char** argv) { - InitializeCrashHandler(); Trinity::Banner::Show("MMAP generator", [](char const* text) { printf("%s\n", text); }, nullptr); int threads = 3, mapnum = -1; diff --git a/src/tools/vmap4_assembler/CMakeLists.txt b/src/tools/vmap4_assembler/CMakeLists.txt index 28e8b37414..311d16a831 100644 --- a/src/tools/vmap4_assembler/CMakeLists.txt +++ b/src/tools/vmap4_assembler/CMakeLists.txt @@ -9,7 +9,13 @@ # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -add_executable(vmap4assembler VMapAssembler.cpp) +set(PRIVATE_SOURCES VMapAssembler.cpp) + +if (WIN32) + list(APPEND PRIVATE_SOURCES ${sources_windows}) +endif() + +add_executable(vmap4assembler ${PRIVATE_SOURCES}) target_link_libraries(vmap4assembler common diff --git a/src/tools/vmap4_assembler/VMapAssembler.cpp b/src/tools/vmap4_assembler/VMapAssembler.cpp index ef5b93c25a..a407e80ff1 100644 --- a/src/tools/vmap4_assembler/VMapAssembler.cpp +++ b/src/tools/vmap4_assembler/VMapAssembler.cpp @@ -21,15 +21,13 @@ #include "TileAssembler.h" #include "Banner.h" -#include "WheatyExceptionReport.h" int main(int argc, char* argv[]) { - InitializeCrashHandler(); Trinity::Banner::Show("VMAP assembler", [](char const* text) { std::cout << text << std::endl; }, nullptr); std::string src = "Buildings"; - std::string dest = "vmaps"; + std::string dest = "vmaps"; if (argc > 3) { diff --git a/src/tools/vmap4_extractor/CMakeLists.txt b/src/tools/vmap4_extractor/CMakeLists.txt index feaf7ddb21..ff952649f9 100644 --- a/src/tools/vmap4_extractor/CMakeLists.txt +++ b/src/tools/vmap4_extractor/CMakeLists.txt @@ -13,6 +13,10 @@ CollectSourceFiles( ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE_SOURCES) +if (WIN32) + list(APPEND PRIVATE_SOURCES ${sources_windows}) +endif() + add_executable(vmap4extractor ${PRIVATE_SOURCES}) target_link_libraries(vmap4extractor diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp index 17ae93eb48..0e788dc4d4 100644 --- a/src/tools/vmap4_extractor/vmapexport.cpp +++ b/src/tools/vmap4_extractor/vmapexport.cpp @@ -50,7 +50,6 @@ #include "vmapexport.h" #include "Banner.h" -#include "WheatyExceptionReport.h" #include #include @@ -492,7 +491,6 @@ bool processArgv(int argc, char ** argv, const char *versionString) int main(int argc, char ** argv) { - InitializeCrashHandler(); Trinity::Banner::Show("VMAP data extractor", [](char const* text) { printf("%s\n", text); }, nullptr); bool success = true;