Commit f63a23c8 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add drmingw to the Windows build

That way we can more easily get backtraces on Windows. Patch by
Alvin Wong.
parent ac04c559
......@@ -119,3 +119,7 @@ add_subdirectory( ext_frameworks )
if (MSVC)
add_subdirectory( google-breakpad )
endif()
if (MSVC OR MINGW)
add_subdirectory( ext_drmingw )
endif (MSVC OR MINGW)
SET (PREFIX_ext_drmingw "${EXTPREFIX}")
if (MSVC OR MINGW)
if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
ExternalProject_Add(ext_drmingw
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://github.com/jrfonseca/drmingw/releases/download/0.8.1/drmingw-0.8.1-win64.7z
URL_HASH SHA1=8be29cc7efc0d611056c3b745e7f8de30d7c8baa
INSTALL_DIR ${PREFIX_ext_drmingw}
CONFIGURE_COMMAND ""
BUILD_COMMAND ${CMAKE_COMMAND} -E echo Deploying Dr. Mingw 64-bit binary and dependencies
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/bin/dbghelp.dll ${PREFIX_ext_drmingw}/bin/
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/bin/exchndl.dll ${PREFIX_ext_drmingw}/bin/
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/bin/mgwhelp.dll ${PREFIX_ext_drmingw}/bin/
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/bin/symsrv.dll ${PREFIX_ext_drmingw}/bin/
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/bin/symsrv.yes ${PREFIX_ext_drmingw}/bin/
UPDATE_COMMAND ""
ALWAYS 0
)
else ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
ExternalProject_Add(ext_drmingw
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://github.com/jrfonseca/drmingw/releases/download/0.8.1/drmingw-0.8.1-win32.7z
URL_HASH SHA1=5eefeefc392cae36afb891ca81e3756aa0d79644
INSTALL_DIR ${PREFIX_ext_drmingw}
CONFIGURE_COMMAND ""
BUILD_COMMAND ${CMAKE_COMMAND} -E echo Deploying Dr. Mingw 32-bit binary and dependencies
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/bin/dbghelp.dll ${PREFIX_ext_drmingw}/bin/
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/bin/exchndl.dll ${PREFIX_ext_drmingw}/bin/
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/bin/mgwhelp.dll ${PREFIX_ext_drmingw}/bin/
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/bin/symsrv.dll ${PREFIX_ext_drmingw}/bin/
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/bin/symsrv.yes ${PREFIX_ext_drmingw}/bin/
UPDATE_COMMAND ""
ALWAYS 0
)
endif ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
endif (MSVC OR MINGW)
......@@ -153,7 +153,8 @@ message(STATUS "Release build: ${RELEASE_BUILD}")
option(PACKAGERS_BUILD "Build support of multiple CPU architectures in one binary. Should be used by packagers only or Krita developers. Only switch off when you're an artist optimizing a build for your very own machine." ON)
if (WIN32)
option(USE_BREAKPAD "Build the crash handler for Krita (only on windows)" OFF)
option(USE_BREAKPAD "Build the Breakpad crash handler for Krita (only on windows)" OFF)
option(USE_DRMINGW "Support the Dr. Mingw crash handler (only on windows)" ON)
endif ()
option(HIDE_SAFE_ASSERTS "Don't show message box for \"safe\" asserts, just ignore them automatically and dump a message to the terminal." ON)
......
......@@ -28,9 +28,12 @@
#cmakedefine WORDS_BIGENDIAN ${CMAKE_WORDS_BIGENDIAN}
#endif
/* Defines if the krita crash handler is built */
/* Defines if the Breakpad krita crash handler is built */
#cmakedefine USE_BREAKPAD 1
/* Defines if the Dr. Mingw crash handler should be used */
#cmakedefine USE_DRMINGW 1
/* Number of bits in a file offset, on hosts where this is settable. */
#define _FILE_OFFSET_BITS 64
......
......@@ -59,9 +59,36 @@
#elif defined USE_BREAKPAD
#include "kis_crash_handler.h"
#elif defined USE_DRMINGW
namespace
{
void tryInitDrMingw()
{
wchar_t path[MAX_PATH];
QString pathStr = QCoreApplication::applicationDirPath().replace(L'/', L'\\') + QStringLiteral("\\exchndl.dll");
if (pathStr.size() > MAX_PATH - 1) {
return;
}
int pathLen = pathStr.toWCharArray(path);
path[pathLen] = L'\0'; // toWCharArray doesn't add NULL terminator
HMODULE hMod = LoadLibraryW(path);
if (!hMod) {
return;
}
// No need to call ExcHndlInit since the crash handler is installed on DllMain
auto myExcHndlSetLogFileNameA = reinterpret_cast<BOOL (APIENTRY *)(const char *)>(GetProcAddress(hMod, "ExcHndlSetLogFileNameA"));
if (!myExcHndlSetLogFileNameA) {
return;
}
// Set the log file path to %LocalAppData%\kritacrash.log
QString logFile = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation).replace(L'/', L'\\') + QStringLiteral("\\kritacrash.log");
myExcHndlSetLogFileNameA(logFile.toLocal8Bit());
}
} // namespace
#endif
extern "C" int main(int argc, char **argv)
{
/**
* Add a workaround for Qt 5.6, which implemented compression of the tablet events.
* Since Qt 5.6.1 there will be this hacky environment variable option. After that,
......@@ -168,6 +195,8 @@ extern "C" int main(int argc, char **argv)
qputenv("KDE_DEBUG", "1");
KisCrashHandler crashHandler;
Q_UNUSED(crashHandler);
#elif defined USE_DRMINGW
tryInitDrMingw();
#endif
// If we should clear the config, it has to be done as soon as possible after
......
......@@ -190,6 +190,8 @@ if exist filelist_bin_dll.txt (
)
endlocal
)
:: symsrv.yes for Dr. Mingw
copy %BUILDDIR_INSTALL%\bin\symsrv.yes %pkg_root%\bin
:: DLLs from lib/
if exist filelist_lib_dll.txt (
for /f %%F in (filelist_lib_dll.txt) do copy %BUILDDIR_INSTALL%\lib\%%F %pkg_root%\bin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment