add TDM-GCC64 build

Signed-off-by: yami-hack <yami-hack@foxmail.com>
This commit is contained in:
yami-hack 2016-06-03 23:13:54 +08:00
parent 8df4283b19
commit 7338463dd7
6 changed files with 127 additions and 18 deletions

View File

@ -69,8 +69,11 @@ if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
if (ARCHITECTURE_x86_64) if (ARCHITECTURE_x86_64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1") #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
#Some CPU do not support sse4.1
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3")
endif() endif()
else() else()
# Silence "deprecation" warnings # Silence "deprecation" warnings
@ -114,12 +117,17 @@ add_definitions(-DSINGLETHREADED)
set_property(DIRECTORY APPEND PROPERTY set_property(DIRECTORY APPEND PROPERTY
COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:NDEBUG>) COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:NDEBUG>)
option(ENABLE_SUPPORT_PNG "Disable the libpng support" OFF)
if(ENABLE_SUPPORT_PNG)
find_package(PNG QUIET) find_package(PNG QUIET)
if (PNG_FOUND) if (PNG_FOUND)
add_definitions(-DHAVE_PNG) add_definitions(-DHAVE_PNG)
else() else()
message(STATUS "libpng not found. Some debugging features have been disabled.") message(STATUS "libpng not found. Some debugging features have been disabled.")
endif() endif()
else()
endif()
find_package(Boost 1.57.0 QUIET) find_package(Boost 1.57.0 QUIET)
if (Boost_FOUND) if (Boost_FOUND)
@ -140,10 +148,17 @@ set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
if (ENABLE_SDL2) if (ENABLE_SDL2)
if (CITRA_USE_BUNDLED_SDL2) if (SDL2_PREFIX)
message(STATUS "SDL2_PATH = ${SDL2_PREFIX}")
set(SDL2_INCLUDE_DIR "${SDL2_PREFIX}/include" CACHE PATH "Path to SDL2 headers")
set(SDL2_LIBRARY "${SDL2_PREFIX}/x86_64-w64-mingw32/lib/libSDL2.dll.a" CACHE PATH "Path to SDL2 library")
set(SDL2_DLL_DIR "${SDL2_PREFIX}/x86_64-w64-mingw32/lib/" CACHE PATH "Path to SDL2.dll")
elseif (CITRA_USE_BUNDLED_SDL2)
# Detect toolchain and platform # Detect toolchain and platform
if (MSVC14 AND ARCHITECTURE_x86_64) if (MSVC14 AND ARCHITECTURE_x86_64)
set(SDL2_VER "SDL2-2.0.4") set(SDL2_VER "SDL2-2.0.4")
elseif(MINGW)
set(SDL2_VER "SDL2-2.0.4")
else() else()
message(FATAL_ERROR "No bundled SDL2 binaries for your toolchain. Disable CITRA_USE_BUNDLED_SDL2 and provide your own.") message(FATAL_ERROR "No bundled SDL2 binaries for your toolchain. Disable CITRA_USE_BUNDLED_SDL2 and provide your own.")
endif() endif()
@ -152,10 +167,17 @@ if (ENABLE_SDL2)
download_bundled_external("sdl2/" ${SDL2_VER} SDL2_PREFIX) download_bundled_external("sdl2/" ${SDL2_VER} SDL2_PREFIX)
endif() endif()
if (MSVC)
set(SDL2_FOUND YES) set(SDL2_FOUND YES)
set(SDL2_INCLUDE_DIR "${SDL2_PREFIX}/include" CACHE PATH "Path to SDL2 headers") set(SDL2_INCLUDE_DIR "${SDL2_PREFIX}/include" CACHE PATH "Path to SDL2 headers")
set(SDL2_LIBRARY "${SDL2_PREFIX}/lib/x64/SDL2.lib" CACHE PATH "Path to SDL2 library") set(SDL2_LIBRARY "${SDL2_PREFIX}/lib/x64/SDL2.lib" CACHE PATH "Path to SDL2 library")
set(SDL2_DLL_DIR "${SDL2_PREFIX}/lib/x64/" CACHE PATH "Path to SDL2.dll") set(SDL2_DLL_DIR "${SDL2_PREFIX}/lib/x64/" CACHE PATH "Path to SDL2.dll")
elseif (MINGW)
set(SDL2_FOUND YES)
set(SDL2_INCLUDE_DIR "${SDL2_PREFIX}/include" CACHE PATH "Path to SDL2 headers")
set(SDL2_LIBRARY "${SDL2_PREFIX}/x86_64-w64-mingw32/lib/libSDL2.dll.a" CACHE PATH "Path to SDL2 library")
set(SDL2_DLL_DIR "${SDL2_PREFIX}/x86_64-w64-mingw32/lib/" CACHE PATH "Path to SDL2.dll")
endif()
else() else()
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
endif() endif()
@ -172,7 +194,9 @@ IF (APPLE)
ELSEIF(MINGW) ELSEIF(MINGW)
# GCC does not support codecvt, so use iconv instead # GCC does not support codecvt, so use iconv instead
# PSAPI is the Process Status API # PSAPI is the Process Status API
set(PLATFORM_LIBRARIES winmm ws2_32 psapi iconv) # TDM-GCC64 not support iconv
# set(PLATFORM_LIBRARIES winmm ws2_32 psapi iconv)
set(PLATFORM_LIBRARIES winmm ws2_32 psapi)
# WSAPoll functionality doesn't exist before WinNT 6.x (Vista and up) # WSAPoll functionality doesn't exist before WinNT 6.x (Vista and up)
add_definitions(-D_WIN32_WINNT=0x0600) add_definitions(-D_WIN32_WINNT=0x0600)

13
TDMGCC64_SDL2_build.md Normal file
View File

@ -0,0 +1,13 @@
TDM-GCC64 build
bash
git clone --recursive https://github.com/yami-hack/citra.git
mkdir build
cd build
cmake ../citra -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
-DENABLE_QT=OFF \
-DMINGW_HOME=/h/TDM-GCC64/ \
-DSDL2_PATH="G:/src/citra160603/build/externals/SDL2-2.0.4"

View File

@ -923,15 +923,18 @@ void MicroProfileThreadJoin(MicroProfileThread* pThread)
} }
#elif defined(_WIN32) #elif defined(_WIN32)
typedef HANDLE MicroProfileThread; typedef HANDLE MicroProfileThread;
DWORD _stdcall ThreadTrampoline(void* pFunc) DWORD __stdcall ThreadTrampoline(void* pFunc)
{ {
MicroProfileThreadFunc F = (MicroProfileThreadFunc)pFunc; MicroProfileThreadFunc F = (MicroProfileThreadFunc)pFunc;
return (uint32_t)F(0); //return (uint32_t)F(0);
void *ret = F(0);
return *(uint32_t*)&ret;
} }
void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func) void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func)
{ {
*pThread = CreateThread(0, 0, ThreadTrampoline, Func, 0, 0); //*pThread = CreateThread(0, 0, ThreadTrampoline, Func, 0, 0);
*pThread = CreateThread(0, 0, ThreadTrampoline, (void*)Func, 0, 0);
} }
void MicroProfileThreadJoin(MicroProfileThread* pThread) void MicroProfileThreadJoin(MicroProfileThread* pThread)
{ {

View File

@ -8,6 +8,13 @@
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#if defined(__MINGW64__)
#include <sec_api/io_s.h>
#endif
#if defined(__MINGW64__)
#include <sec_api/io_s.h>
#endif
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#include <shlobj.h> // for SHGetFolderPath #include <shlobj.h> // for SHGetFolderPath
@ -926,7 +933,7 @@ void IOFile::Swap(IOFile& other)
bool IOFile::Open(const std::string& filename, const char openmode[]) bool IOFile::Open(const std::string& filename, const char openmode[])
{ {
Close(); Close();
#ifdef _WIN32 #if defined(_WIN32) && !defined(__MINGW64__)
_wfopen_s(&m_file, Common::UTF8ToUTF16W(filename).c_str(), Common::UTF8ToUTF16W(openmode).c_str()); _wfopen_s(&m_file, Common::UTF8ToUTF16W(filename).c_str(), Common::UTF8ToUTF16W(openmode).c_str());
#else #else
m_file = fopen(filename.c_str(), openmode); m_file = fopen(filename.c_str(), openmode);
@ -980,6 +987,9 @@ bool IOFile::Flush()
bool IOFile::Resize(u64 size) bool IOFile::Resize(u64 size)
{ {
if (!IsOpen() || 0 != if (!IsOpen() || 0 !=
#if defined(__MINGW64__)
chsize(_fileno(m_file), size)
#else
#ifdef _WIN32 #ifdef _WIN32
// ector: _chsize sucks, not 64-bit safe // ector: _chsize sucks, not 64-bit safe
// F|RES: changed to _chsize_s. i think it is 64-bit safe // F|RES: changed to _chsize_s. i think it is 64-bit safe
@ -987,6 +997,7 @@ bool IOFile::Resize(u64 size)
#else #else
// TODO: handle 64bit and growing // TODO: handle 64bit and growing
ftruncate(fileno(m_file), size) ftruncate(fileno(m_file), size)
#endif
#endif #endif
) )
m_good = false; m_good = false;

View File

@ -13,6 +13,18 @@
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/string_util.h" #include "common/string_util.h"
#if defined(__MINGW64__)
//TDM-GCC64
#include <Windows.h>
#include <codecvt>
#include "common/common_funcs.h"
#else
#if defined(__MINGW32__)
//MINGW32
#include <Windows.h>
#include <iconv.h>
#include "common/common_funcs.h"
#else
#ifdef _MSC_VER #ifdef _MSC_VER
#include <Windows.h> #include <Windows.h>
#include <codecvt> #include <codecvt>
@ -20,6 +32,8 @@
#else #else
#include <iconv.h> #include <iconv.h>
#endif #endif
#endif
#endif
namespace Common { namespace Common {
@ -52,7 +66,7 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
{ {
int writtenCount; int writtenCount;
#ifdef _MSC_VER #if defined(_MSC_VER) || !defined(__MINGW64__)
// You would think *printf are simple, right? Iterate on each character, // You would think *printf are simple, right? Iterate on each character,
// if it's a format specifier handle it properly, etc. // if it's a format specifier handle it properly, etc.
// //
@ -292,7 +306,7 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
return result; return result;
} }
#ifdef _MSC_VER #if defined(_MSC_VER) || !defined(__MINGW32__) || defined(__MINGW64__)
std::string UTF16ToUTF8(const std::u16string& input) std::string UTF16ToUTF8(const std::u16string& input)
{ {
@ -363,6 +377,41 @@ std::string CP1252ToUTF8(const std::string& input)
#else #else
#if defined(__MINGW32__)
// MINGW32 and TDM-GCC64
static std::wstring CPToUTF16(u32 code_page, const std::string& input)
{
auto const size = MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0);
std::wstring output;
output.resize(size);
if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size())))
output.clear();
return output;
}
std::wstring UTF8ToUTF16W(const std::string &input)
{
return CPToUTF16(CP_UTF8, input);
}
std::string UTF16ToUTF8(const std::wstring& input){
auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr);
std::string output;
output.resize(size);
if (size == 0 || size != WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size()), nullptr, nullptr))
output.clear();
return output;
}
#endif
template <typename T> template <typename T>
static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>& input) static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>& input)
{ {

View File

@ -14,6 +14,14 @@
#include <map> #include <map>
#include <numeric> #include <numeric>
#ifdef _WIN32
#include <WinSock2.h>
#include <ws2tcpip.h>
#include <common/x64/abi.h>
#include <io.h>
#include <iphlpapi.h>
#define SHUT_RDWR 2
#else
#ifdef _MSC_VER #ifdef _MSC_VER
#include <WinSock2.h> #include <WinSock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
@ -28,6 +36,7 @@
#include <sys/un.h> #include <sys/un.h>
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#endif
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/string_util.h" #include "common/string_util.h"