From 789315bb4a7a2a5701b40c4ee004336395bd452f Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Tue, 22 Nov 2016 21:22:39 -0500 Subject: [PATCH] - Fixed build with MinGW-w64 (TDM-GCC 5.1). Note that the resulting binary will crash under -O3 until the alignment violation is taken care of in FRemapTable::Alloc. - It appears that CMake added native support for building rc files with MinGW at some point so removed manual rc compiling code. --- src/CMakeLists.txt | 10 +----- src/i_module.cpp | 2 +- src/v_video.cpp | 2 +- src/win32/i_crash.cpp | 48 ----------------------------- src/win32/i_keyboard.cpp | 5 +++ src/win32/i_rawps2.cpp | 2 +- src/win32/i_specialpaths.cpp | 1 + src/win32/i_xinput.cpp | 11 +++++++ tools/updaterevision/CMakeLists.txt | 17 +++------- 9 files changed, 26 insertions(+), 72 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 04e6087ea..7d532ca9c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -728,15 +728,7 @@ if( WIN32 ) set( SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ) set( OTHER_SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} ${PLAT_UNIX_SOURCES} ) - if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) - # CMake is not set up to compile and link rc files with GCC. :( - add_custom_command( OUTPUT zdoom-rc.o - COMMAND windres -o zdoom-rc.o -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zdoom.rc - DEPENDS win32/zdoom.rc ) - set( SYSTEM_SOURCES ${SYSTEM_SOURCES} zdoom-rc.o ) - else() - set( SYSTEM_SOURCES ${SYSTEM_SOURCES} win32/zdoom.rc ) - endif() + set( SYSTEM_SOURCES ${SYSTEM_SOURCES} win32/zdoom.rc ) elseif( APPLE ) if( OSX_COCOA_BACKEND ) set( SYSTEM_SOURCES_DIR posix posix/cocoa ) diff --git a/src/i_module.cpp b/src/i_module.cpp index 1ed40310f..a82963ec5 100644 --- a/src/i_module.cpp +++ b/src/i_module.cpp @@ -97,5 +97,5 @@ bool FModule::Open(const char* lib) void *FModule::GetSym(const char* name) { - return GetProcAddress((HMODULE)handle, name); + return (void *)GetProcAddress((HMODULE)handle, name); } diff --git a/src/v_video.cpp b/src/v_video.cpp index 37cfdd480..32e1a54d3 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -72,7 +72,7 @@ FRenderer *Renderer; IMPLEMENT_ABSTRACT_CLASS (DCanvas) IMPLEMENT_ABSTRACT_CLASS (DFrameBuffer) -#if defined(_DEBUG) && defined(_M_IX86) +#if defined(_DEBUG) && defined(_M_IX86) && !defined(__MINGW32__) #define DBGBREAK { __asm int 3 } #else #define DBGBREAK diff --git a/src/win32/i_crash.cpp b/src/win32/i_crash.cpp index d4804ec0e..4a0a1b160 100644 --- a/src/win32/i_crash.cpp +++ b/src/win32/i_crash.cpp @@ -75,54 +75,6 @@ #include #include -#if defined(_WIN64) && defined(__GNUC__) -struct KNONVOLATILE_CONTEXT_POINTERS { - union { - PDWORD64 IntegerContext[16]; - struct { - PDWORD64 Rax; - PDWORD64 Rcx; - PDWORD64 Rdx; - PDWORD64 Rbx; - PDWORD64 Rsp; - PDWORD64 Rbp; - PDWORD64 Rsi; - PDWORD64 Rdi; - PDWORD64 R8; - PDWORD64 R9; - PDWORD64 R10; - PDWORD64 R11; - PDWORD64 R12; - PDWORD64 R13; - PDWORD64 R14; - PDWORD64 R15; - }; - }; -}; -typedef -EXCEPTION_DISPOSITION -NTAPI -EXCEPTION_ROUTINE ( - struct _EXCEPTION_RECORD *ExceptionRecord, - PVOID EstablisherFrame, - struct _CONTEXT *ContextRecord, - PVOID DispatcherContext - ); -NTSYSAPI -EXCEPTION_ROUTINE * -NTAPI -RtlVirtualUnwind ( - DWORD HandlerType, - DWORD64 ImageBase, - DWORD64 ControlPc, - PRUNTIME_FUNCTION FunctionEntry, - PCONTEXT ContextRecord, - PVOID *HandlerData, - PDWORD64 EstablisherFrame, - KNONVOLATILE_CONTEXT_POINTERS *ContextPointers - ); -#endif - // MACROS ------------------------------------------------------------------ #define REMOTE_HOST "localhost" diff --git a/src/win32/i_keyboard.cpp b/src/win32/i_keyboard.cpp index cdcf9d8d8..e62942e8d 100644 --- a/src/win32/i_keyboard.cpp +++ b/src/win32/i_keyboard.cpp @@ -21,6 +21,11 @@ #define DINPUT_BUFFERSIZE 32 +// MinGW-w64 (TDM5.1 - 2016/11/21) +#ifndef DIK_PREVTRACK +#define DIK_PREVTRACK DIK_CIRCUMFLEX +#endif + // TYPES ------------------------------------------------------------------- class FDInputKeyboard : public FKeyboard diff --git a/src/win32/i_rawps2.cpp b/src/win32/i_rawps2.cpp index 50de1d0f4..940ef4bb1 100644 --- a/src/win32/i_rawps2.cpp +++ b/src/win32/i_rawps2.cpp @@ -389,7 +389,7 @@ bool FRawPS2Controller::ProcessInput(RAWHID *raw, int code) { // w32api has an incompatible definition of bRawData. // (But the version that comes with MinGW64 is fine.) -#if defined(__GNUC__) && !defined(_WIN64) +#if defined(__GNUC__) && !defined(__MINGW64_VERSION_MAJOR) BYTE *rawdata = &raw->bRawData; #else BYTE *rawdata = raw->bRawData; diff --git a/src/win32/i_specialpaths.cpp b/src/win32/i_specialpaths.cpp index 6d4890ea9..745c12f12 100644 --- a/src/win32/i_specialpaths.cpp +++ b/src/win32/i_specialpaths.cpp @@ -33,6 +33,7 @@ ** */ +#define _WIN32_WINNT 0x0601 #include #include #include diff --git a/src/win32/i_xinput.cpp b/src/win32/i_xinput.cpp index 1180f9f32..22c2dd714 100644 --- a/src/win32/i_xinput.cpp +++ b/src/win32/i_xinput.cpp @@ -33,6 +33,17 @@ #define XUSER_MAX_COUNT 4 #endif +// MinGW +#ifndef XINPUT_DLL +#define XINPUT_DLL_A "xinput1_3.dll" +#define XINPUT_DLL_W L"xinput1_3.dll" +#ifdef UNICODE + #define XINPUT_DLL XINPUT_DLL_W +#else + #define XINPUT_DLL XINPUT_DLL_A +#endif +#endif + // TYPES ------------------------------------------------------------------- typedef DWORD (WINAPI *XInputGetStateType)(DWORD index, XINPUT_STATE *state); diff --git a/tools/updaterevision/CMakeLists.txt b/tools/updaterevision/CMakeLists.txt index 22890472a..db99ab812 100644 --- a/tools/updaterevision/CMakeLists.txt +++ b/tools/updaterevision/CMakeLists.txt @@ -1,19 +1,12 @@ cmake_minimum_required( VERSION 2.8.7 ) if( WIN32 ) - if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE OR ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) - add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/trustinfo.o - COMMAND windres -o ${CMAKE_CURRENT_BINARY_DIR}/trustinfo.o -i ${CMAKE_CURRENT_SOURCE_DIR}/trustinfo.rc - DEPENDS trustinfo.rc ) - set( TRUSTINFO trustinfo.o ) + if( MSVC_VERSION GREATER 1399 ) + # VC 8+ adds a manifest automatically to the executable. We need to + # merge ours with it. + set( MT_MERGE ON ) else() - if( MSVC_VERSION GREATER 1399 ) - # VC 8+ adds a manifest automatically to the executable. We need to - # merge ours with it. - set( MT_MERGE ON ) - else( MSVC_VERSION GREATER 1399 ) - set( TRUSTINFO trustinfo.rc ) - endif( MSVC_VERSION GREATER 1399 ) + set( TRUSTINFO trustinfo.rc ) endif() else( WIN32 ) set( TRUSTINFO "" )