diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index 01d5859a..5bbfe635 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -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}) diff --git a/src/framework/cmake/FindEGL.cmake b/src/framework/cmake/FindEGL.cmake index 931420bc..72165a69 100644 --- a/src/framework/cmake/FindEGL.cmake +++ b/src/framework/cmake/FindEGL.cmake @@ -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) \ No newline at end of file +MARK_AS_ADVANCED(EGL_LIBRARY EGL_INCLUDE_DIR) diff --git a/src/framework/cmake/FindOpenGLES2.cmake b/src/framework/cmake/FindOpenGLES2.cmake index b2cf080c..60caf68e 100644 --- a/src/framework/cmake/FindOpenGLES2.cmake +++ b/src/framework/cmake/FindOpenGLES2.cmake @@ -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) \ No newline at end of file +MARK_AS_ADVANCED(OPENGLES2_LIBRARY OPENGLES2_INCLUDE_DIR) diff --git a/src/framework/graphics/glutil.h b/src/framework/graphics/glutil.h index 7650477d..d3c1a262 100644 --- a/src/framework/graphics/glutil.h +++ b/src/framework/graphics/glutil.h @@ -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 #endif diff --git a/src/framework/platform/win32crashhandler.cpp b/src/framework/platform/win32crashhandler.cpp index 2a31ff04..7ba91261 100644 --- a/src/framework/platform/win32crashhandler.cpp +++ b/src/framework/platform/win32crashhandler.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -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"; diff --git a/src/framework/platform/win32platform.cpp b/src/framework/platform/win32platform.cpp index c8398468..e00b84a1 100644 --- a/src/framework/platform/win32platform.cpp +++ b/src/framework/platform/win32platform.cpp @@ -23,6 +23,7 @@ #ifdef WIN32 #include "platform.h" +#include #include #include #include @@ -55,7 +56,7 @@ bool Platform::spawnProcess(std::string process, const std::vector& 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() { diff --git a/src/framework/platform/win32window.h b/src/framework/platform/win32window.h index b324a00c..f0b81efe 100644 --- a/src/framework/platform/win32window.h +++ b/src/framework/platform/win32window.h @@ -25,6 +25,7 @@ #include "platformwindow.h" +#include #include #ifdef OPENGL_ES diff --git a/src/framework/stdext/compiler.h b/src/framework/stdext/compiler.h index 8d401890..0d30aafb 100644 --- a/src/framework/stdext/compiler.h +++ b/src/framework/stdext/compiler.h @@ -23,6 +23,10 @@ #ifndef STDEXT_COMPILER_H #define STDEXT_COMPILER_H +#ifdef WIN32 +#include +#endif + #ifdef __clang__ // clang is supported #define BUILD_COMPILER "clang " __VERSION__ diff --git a/src/framework/stdext/demangle.cpp b/src/framework/stdext/demangle.cpp index 3a26a7a9..eca466eb 100644 --- a/src/framework/stdext/demangle.cpp +++ b/src/framework/stdext/demangle.cpp @@ -23,6 +23,7 @@ #include "demangle.h" #ifdef _MSC_VER +#include #include #include #else diff --git a/src/framework/stdext/string.cpp b/src/framework/stdext/string.cpp index 452e2ad5..81e92f7c 100644 --- a/src/framework/stdext/string.cpp +++ b/src/framework/stdext/string.cpp @@ -178,6 +178,7 @@ std::string latin1_to_utf8(const std::string& src) } #ifdef WIN32 +#include #include std::wstring utf8_to_utf16(const std::string& src) { diff --git a/tools/make_snapshot.sh b/tools/make_snapshot.sh index 554f539c..b3ccb316 100755 --- a/tools/make_snapshot.sh +++ b/tools/make_snapshot.sh @@ -43,52 +43,103 @@ revision=`git rev-list --all | wc -l` commit=`git describe --always` version=`cat CMakeLists.txt | grep "set(VERSION" | sed 's/.*"\([^"]*\)".*/\1/'` -# build for i686 -export CFLAGS="-march=i686 -m32" -export CXXFLAGS="-march=i686 -m32" -export LDFLAGS="-march=i686 -m32" - -LIBPATH=/usr/lib -if [ -d /usr/lib32 ]; then - LIBPATH=/usr/lib32 -fi 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 - cmake -DCMAKE_TOOLCHAIN_FILE=$workdir/otclient/src/framework/cmake/${mingwplatform}_toolchain.cmake \ + 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 win32 +# 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 - cmake -DCMAKE_TOOLCHAIN_FILE=$workdir/otclient/src/framework/cmake/${mingwplatform}_toolchain.cmake \ + 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" + +LIBPATH=/usr/lib +if [ -d /usr/lib32 ]; then + LIBPATH=/usr/lib32 +fi + 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