Changes to compile for Win64

This commit is contained in:
Eduardo Bart 2013-11-13 13:55:34 -02:00
parent 0d44942e8e
commit b07a77f705
11 changed files with 155 additions and 63 deletions

View File

@ -270,7 +270,7 @@ endif()
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads")
set(framework_DEFINITIONS ${framework_DEFINITIONS} -D_WIN32_WINNT=0x0501)
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--large-address-aware") # strip all debug information
#set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--large-address-aware") # strip all debug information
set(SYSTEM_LIBRARIES "")
else()
if(APPLE)
@ -546,6 +546,10 @@ if(FRAMEWORK_SQL)
set(framework_DEFINITIONS ${framework_DEFINITIONS} -DFW_SQL)
endif()
if(EXTRA_LIBS)
set(framework_LIBRARIES ${framework_LIBRARIES} ${EXTRA_LIBS})
endif()
include_directories(${framework_INCLUDE_DIRS})
add_definitions(${framework_DEFINITIONS})

View File

@ -4,7 +4,13 @@
# EGL_LIBRARY - the EGL library
FIND_PATH(EGL_INCLUDE_DIR NAMES EGL/egl.h)
FIND_LIBRARY(EGL_LIBRARY NAMES EGL.dll EGL)
SET(_EGL_STATIC_LIBS libEGL.a)
SET(_EGL_SHARED_LIBS libEGL.dll.a EGL)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(EGL_LIBRARY NAMES ${_EGL_STATIC_LIBS} ${_EGL_SHARED_LIBS})
ELSE()
FIND_LIBRARY(EGL_LIBRARY NAMES ${_EGL_SHARED_LIBS} ${_EGL_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR)
MARK_AS_ADVANCED(EGL_LIBRARY EGL_INCLUDE_DIR)
MARK_AS_ADVANCED(EGL_LIBRARY EGL_INCLUDE_DIR)

View File

@ -4,7 +4,13 @@
# OPENGLES2_LIBRARY - the OpenGL ES 2.0 library
FIND_PATH(OPENGLES2_INCLUDE_DIR NAMES GLES2/gl2.h)
FIND_LIBRARY(OPENGLES2_LIBRARY NAMES GLESv2.dll GLESv2)
SET(_OPENGLES2_STATIC_LIBS libGLESv2.a)
SET(_OPENGLES2_SHARED_LIBS libGLESv2.dll.a GLESv2)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(OPENGLES2_LIBRARY NAMES ${_OPENGLES2_STATIC_LIBS} ${_OPENGLES2_SHARED_LIBS})
ELSE()
FIND_LIBRARY(OPENGLES2_LIBRARY NAMES ${_OPENGLES2_SHARED_LIBS} ${_OPENGLES2_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGLES2 DEFAULT_MSG OPENGLES2_LIBRARY OPENGLES2_INCLUDE_DIR)
MARK_AS_ADVANCED(OPENGLES2_LIBRARY OPENGLES2_INCLUDE_DIR)
MARK_AS_ADVANCED(OPENGLES2_LIBRARY OPENGLES2_INCLUDE_DIR)

View File

@ -103,7 +103,9 @@ inline void glEnableVertexAttribArray (GLuint index) { }
inline void glDisableVertexAttribArray (GLuint index) { }
#else
//#define GLEW_STATIC
#ifndef _MSC_VER
#define GLEW_STATIC
#endif
#include <GL/glew.h>
#endif

View File

@ -26,6 +26,7 @@
#include <framework/global.h>
#include <framework/core/application.h>
#include <winsock2.h>
#include <windows.h>
#include <process.h>
#include <imagehlp.h>
@ -64,17 +65,28 @@ void Stacktrace(LPEXCEPTION_POINTERS e, std::stringstream& ss)
PIMAGEHLP_SYMBOL pSym;
STACKFRAME sf;
HANDLE process, thread;
DWORD dwModBase, Disp;
ULONG_PTR dwModBase, Disp;
BOOL more = FALSE;
DWORD machineType;
int count = 0;
char modname[MAX_PATH];
char symBuffer[sizeof(IMAGEHLP_SYMBOL) + 255];
pSym = (PIMAGEHLP_SYMBOL)GlobalAlloc(GMEM_FIXED, 16384);
pSym = (PIMAGEHLP_SYMBOL)symBuffer;
ZeroMemory(&sf, sizeof(sf));
#ifdef __WIN64__
sf.AddrPC.Offset = e->ContextRecord->Rip;
sf.AddrStack.Offset = e->ContextRecord->Rsp;
sf.AddrFrame.Offset = e->ContextRecord->Rbp;
machineType = IMAGE_FILE_MACHINE_AMD64;
#else
sf.AddrPC.Offset = e->ContextRecord->Eip;
sf.AddrStack.Offset = e->ContextRecord->Esp;
sf.AddrFrame.Offset = e->ContextRecord->Ebp;
machineType = IMAGE_FILE_MACHINE_I386;
#endif
sf.AddrPC.Mode = AddrModeFlat;
sf.AddrStack.Mode = AddrModeFlat;
sf.AddrFrame.Mode = AddrModeFlat;
@ -83,7 +95,7 @@ void Stacktrace(LPEXCEPTION_POINTERS e, std::stringstream& ss)
thread = GetCurrentThread();
while(1) {
more = StackWalk(IMAGE_FILE_MACHINE_I386, process, thread, &sf, e->ContextRecord, NULL, SymFunctionTableAccess, SymGetModuleBase, NULL);
more = StackWalk(machineType, process, thread, &sf, e->ContextRecord, NULL, SymFunctionTableAccess, SymGetModuleBase, NULL);
if(!more || sf.AddrFrame.Offset == 0)
break;
@ -93,13 +105,14 @@ void Stacktrace(LPEXCEPTION_POINTERS e, std::stringstream& ss)
else
strcpy(modname, "Unknown");
pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL);
pSym->MaxNameLength = MAX_PATH;
Disp = 0;
pSym->SizeOfStruct = sizeof(symBuffer);
pSym->MaxNameLength = 254;
if(SymGetSymFromAddr(process, sf.AddrPC.Offset, &Disp, pSym))
ss << stdext::format(" %d: %s(%s+%#0lx) [0x%08lX]\n", count, modname, pSym->Name, Disp, sf.AddrPC.Offset);
ss << stdext::format(" %d: %s(%s+%#0lx) [0x%016lX]\n", count, modname, pSym->Name, Disp, sf.AddrPC.Offset);
else
ss << stdext::format(" %d: %s [0x%08lX]\n", count, modname, sf.AddrPC.Offset);
ss << stdext::format(" %d: %s [0x%016lX]\n", count, modname, sf.AddrPC.Offset);
++count;
}
GlobalFree(pSym);
@ -119,7 +132,7 @@ LONG CALLBACK ExceptionHandler(LPEXCEPTION_POINTERS e)
ss << stdext::format("build revision: %s (%s)\n", BUILD_REVISION, BUILD_COMMIT);
ss << stdext::format("crash date: %s\n", stdext::date_time_string());
ss << stdext::format("exception: %s (0x%08lx)\n", getExceptionName(e->ExceptionRecord->ExceptionCode), e->ExceptionRecord->ExceptionCode);
ss << stdext::format("exception address: 0x%08lx\n", (long unsigned int)e->ExceptionRecord->ExceptionAddress);
ss << stdext::format("exception address: 0x%08lx\n", (size_t)e->ExceptionRecord->ExceptionAddress);
ss << stdext::format(" backtrace:\n");
Stacktrace(e, ss);
ss << "\n";

View File

@ -23,6 +23,7 @@
#ifdef WIN32
#include "platform.h"
#include <winsock2.h>
#include <windows.h>
#include <framework/stdext/stdext.h>
#include <boost/algorithm/string.hpp>
@ -55,7 +56,7 @@ bool Platform::spawnProcess(std::string process, const std::vector<std::string>&
std::wstring wfile = stdext::utf8_to_utf16(process);
std::wstring wcommandLine = stdext::utf8_to_utf16(commandLine);
if((int)ShellExecuteW(NULL, L"open", wfile.c_str(), wcommandLine.c_str(), NULL, SW_SHOWNORMAL) > 32)
if((size_t)ShellExecuteW(NULL, L"open", wfile.c_str(), wcommandLine.c_str(), NULL, SW_SHOWNORMAL) > 32)
return true;
return false;
}
@ -172,6 +173,7 @@ double Platform::getTotalSystemMemory()
return status.ullTotalPhys;
}
#ifndef PRODUCT_PROFESSIONAL
#define PRODUCT_PROFESSIONAL 0x00000030
#define VER_SUITE_WH_SERVER 0x00008000
#define VER_PLATFORM_WIN32s 0
@ -228,6 +230,7 @@ double Platform::getTotalSystemMemory()
#define PRODUCT_PROFESSIONAL 0x00000030
#define PRODUCT_PROFESSIONAL_N 0x00000031
#define PRODUCT_SB_SOLUTION_SERVER 0x00000032
#endif
std::string Platform::getOSName()
{

View File

@ -25,6 +25,7 @@
#include "platformwindow.h"
#include <winsock2.h>
#include <windows.h>
#ifdef OPENGL_ES

View File

@ -23,6 +23,10 @@
#ifndef STDEXT_COMPILER_H
#define STDEXT_COMPILER_H
#ifdef WIN32
#include <winsock2.h>
#endif
#ifdef __clang__
// clang is supported
#define BUILD_COMPILER "clang " __VERSION__

View File

@ -23,6 +23,7 @@
#include "demangle.h"
#ifdef _MSC_VER
#include <winsock2.h>
#include <windows.h>
#include <dbghelp.h>
#else

View File

@ -178,6 +178,7 @@ std::string latin1_to_utf8(const std::string& src)
}
#ifdef WIN32
#include <winsock2.h>
#include <windows.h>
std::wstring utf8_to_utf16(const std::string& src)
{

View File

@ -43,7 +43,94 @@ revision=`git rev-list --all | wc -l`
commit=`git describe --always`
version=`cat CMakeLists.txt | grep "set(VERSION" | sed 's/.*"\([^"]*\)".*/\1/'`
# build for i686
if $rebuild; then
rm -rf build.win32
rm -rf build.win64
rm -rf build.win32dx9
rm -rf build.win64dx9
rm -rf build.linux32
#rm -rf build.linux64
fi
WIN32_EXTRA_LIBS="-Wl,-Bstatic -lgcc -lstdc++ -lpthread"
# compile for win64
mkdir -p build.win64
cd build.win64
if $rebuild; then
x86_64-w64-mingw32-cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBOT_PROTECTION=OFF \
-DBUILD_REVISION=$revision \
-DBUILD_COMMIT=$commit \
-DEXTRA_LIBS="$WIN32_EXTRA_LIBS" \
.. || exit
fi
make -j$makejobs || exit
cd ..
# compile for win32
mkdir -p build.win32
cd build.win32
if $rebuild; then
i686-w64-mingw32-cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBOT_PROTECTION=OFF \
-DBUILD_REVISION=$revision \
-DBUILD_COMMIT=$commit \
-DEXTRA_LIBS="$WIN32_EXTRA_LIBS" \
.. || exit
fi
make -j$makejobs || exit
cd ..
# compile for win64dx9
mkdir -p build.win64
cd build.win64
if $rebuild; then
x86_64-w64-mingw32-cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBOT_PROTECTION=OFF \
-DOPENGLES=2.0 \
-DBUILD_REVISION=$revision \
-DBUILD_COMMIT=$commit \
-DEXTRA_LIBS="$WIN32_EXTRA_LIBS" \
.. || exit
fi
make -j$makejobs || exit
cd ..
# compile for win32dx9
mkdir -p build.win32dx9
cd build.win32dx9
if $rebuild; then
i686-w64-mingw32-cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBOT_PROTECTION=OFF \
-DOPENGLES=2.0 \
-DBUILD_REVISION=$revision \
-DBUILD_COMMIT=$commit \
-DEXTRA_LIBS="$WIN32_EXTRA_LIBS" \
.. || exit
fi
make -j$makejobs || exit
cd ..
# compile for linux64
mkdir -p build.linux64
cd build.linux64
if $rebuild; then
cmake -DCMAKE_BUILD_TYPE=Release \
-DBOT_PROTECTION=OFF \
-DBUILD_REVISION=$revision \
-DBUILD_COMMIT=$commit \
.. || exit
fi
make -j$makejobs || exit
cd ..
# compile for linux32
export CFLAGS="-march=i686 -m32"
export CXXFLAGS="-march=i686 -m32"
export LDFLAGS="-march=i686 -m32"
@ -53,42 +140,6 @@ if [ -d /usr/lib32 ]; then
LIBPATH=/usr/lib32
fi
if $rebuild; then
rm -rf build.win32
rm -rf build.win32dx9
rm -rf build.linux32
fi
# compile for win32
mkdir -p build.win32
cd build.win32
if $rebuild; then
cmake -DCMAKE_TOOLCHAIN_FILE=$workdir/otclient/src/framework/cmake/${mingwplatform}_toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBOT_PROTECTION=OFF \
-DBUILD_REVISION=$revision \
-DBUILD_COMMIT=$commit \
.. || exit
fi
make -j$makejobs || exit
cd ..
# compile for win32
mkdir -p build.win32dx9
cd build.win32dx9
if $rebuild; then
cmake -DCMAKE_TOOLCHAIN_FILE=$workdir/otclient/src/framework/cmake/${mingwplatform}_toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBOT_PROTECTION=OFF \
-DOPENGLES=2.0 \
-DBUILD_REVISION=$revision \
-DBUILD_COMMIT=$commit \
.. || exit
fi
make -j$makejobs || exit
cd ..
# compile for linux32
mkdir -p build.linux32
cd build.linux32
if $rebuild; then
@ -117,8 +168,8 @@ mkdir mods
cp $workdir/otclient/mods/README.txt mods/
cp -R $workdir/otclient/modules .
cp -R $workdir/otclient/data .
cp $workdir/otclient/build.linux32/otclient .
cp $workdir/otclient/build.linux32/otclient.map .
cp $workdir/otclient/build.linux32/otclient otclient-32
cp $workdir/otclient/build.linux64/otclient otclient-64
cp $workdir/otclient/init.lua .
cp $workdir/otclient/otclientrc.lua .
cp $workdir/otclient/BUGS .
@ -163,15 +214,15 @@ mkdir mods
cp $workdir/otclient/mods/README.txt mods/
cp -R $workdir/otclient/modules .
cp -R $workdir/otclient/data .
cp $mingwbin/libEGL.dll .
cp $mingwbin/libGLESv2.dll .
cp $mingwbin/d3dcompiler_43.dll .
cp $mingwbin/d3dx9_43.dll .
cp $mingwbin/wrap_oal.dll .
cp $workdir/otclient/build.win32/otclient.exe .
cp $workdir/otclient/build.win32/otclient.map .
cp $workdir/otclient/build.win32dx9/otclient.exe otclient_dx9.exe
cp $workdir/otclient/build.win32dx9/otclient.map otclient_dx9.map
#cp $mingwbin/libEGL.dll .
#cp $mingwbin/libGLESv2.dll .
#cp $mingwbin/d3dcompiler_43.dll .
#cp $mingwbin/d3dx9_43.dll .
#cp $mingwbin/wrap_oal.dll .
cp $workdir/otclient/build.win32/otclient.exe otclient-32.exe
cp $workdir/otclient/build.win32dx9/otclient.exe otclient_dx9-32.exe
cp $workdir/otclient/build.win64/otclient.exe otclient-64.exe
cp $workdir/otclient/build.winw64dx9/otclient.exe otclient_dx9-64.exe
cp $workdir/otclient/init.lua .
cp $workdir/otclient/otclientrc.lua .
cp $workdir/otclient/AUTHORS AUTHORS.txt