mirror of
https://bitbucket.org/theswgsource/src-1.2.git
synced 2026-01-15 23:04:24 -05:00
import our profiler related changes
This commit is contained in:
109
CMakeLists.txt
109
CMakeLists.txt
@@ -4,11 +4,11 @@ cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(stellabellum C CXX)
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/win32")
|
||||
elseif(UNIX)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux")
|
||||
endif()
|
||||
if (WIN32)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/win32")
|
||||
elseif (UNIX)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux")
|
||||
endif ()
|
||||
|
||||
set(SWG_ROOT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(SWG_ENGINE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/engine)
|
||||
@@ -45,67 +45,82 @@ set(CMAKE_CXX_FLAGS_MINSIZEREL "")
|
||||
|
||||
# I'll be honest, win32 is probably very very broken and won't build - it will need worked on so that MSVC uses
|
||||
# the vs2013+ STL instead of stlport, and probably will thus need removal/modification/addition of TONS of the ifdef blocks for WIN32
|
||||
if(WIN32)
|
||||
find_package(Iconv REQUIRED)
|
||||
|
||||
# Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:libc.lib /SAFESEH:NO")
|
||||
if (WIN32)
|
||||
find_package(Iconv REQUIRED)
|
||||
|
||||
# Do-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DWIN32 -Dwin32 -DUDP_LIBRARY -DDEBUG_LEVEL=0 \
|
||||
# -DPRODUCTION=1 /Oi /Ot /Oy /O2 /GF /Gy /Zi /MT -D_USE_32BIT_TIME_T=1 -D_MBCS \
|
||||
# -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS /MP /wd4244 /wd4996 /wd4018 /wd4351 \
|
||||
# /Zc:wchar_t- /Ob1 /FC")
|
||||
|
||||
# Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DWIN32 -Dwin32 -DUDP_LIBRARY -DDEBUG_LEVEL=0 -DPRODUCTION=1 \
|
||||
# Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:libc.lib /SAFESEH:NO")
|
||||
|
||||
# Do-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DWIN32 -Dwin32 -DUDP_LIBRARY -DDEBUG_LEVEL=0 \
|
||||
# -DPRODUCTION=1 /Oi /Ot /Oy /O2 /GF /Gy /Zi /MT -D_USE_32BIT_TIME_T=1 -D_MBCS \
|
||||
# -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS /MP /wd4244 /wd4996 /wd4018 /wd4351 \
|
||||
# /Zc:wchar_t- /Ob1 /FC")
|
||||
|
||||
# Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DWIN32 -Dwin32 -DUDP_LIBRARY -DDEBUG_LEVEL=0 -DPRODUCTION=1 \
|
||||
/Oi /Ot /Oy /O2 /GF /Gy /MT -D_USE_32BIT_TIME_T=1 -D_MBCS -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS \
|
||||
/MP /wd4244 /wd4996 /wd4018 /wd4351 /Zc:wchar_t- /Ob1 /FC")
|
||||
|
||||
# Standard DEBUG build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DWIN32 -Dwin32 -D_DEBUG -DUDP_LIBRARY -DDEBUG_LEVEL=2 -DPRODUCTION=0 /MTd \
|
||||
# Standard DEBUG build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DWIN32 -Dwin32 -D_DEBUG -DUDP_LIBRARY -DDEBUG_LEVEL=2 -DPRODUCTION=0 /MTd \
|
||||
-D_USE_32BIT_TIME_T=1 -D_MBCS -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS /MP /wd4244 /wd4996 /wd4018 /wd4351 \
|
||||
/Zc:wchar_t- /Ob1 /FC")
|
||||
elseif(UNIX)
|
||||
find_package(Curses REQUIRED)
|
||||
elseif (UNIX)
|
||||
find_package(Curses REQUIRED)
|
||||
|
||||
# linker flags
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic,-x,-s")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
# linker flags
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic,-x,-s")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
|
||||
# don't put anything too crazy in debug...and any common flags go into CMAKE_CXX_FLAGS
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -O0 -g3")
|
||||
|
||||
# release specific cflags - optimizations beyond the default for both types is mostly just -O flags
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-DDEBUG_LEVEL=0 -DPRODUCTION=1")
|
||||
# don't put anything too crazy in debug...and any common flags go into CMAKE_CXX_FLAGS
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -O0 -g3")
|
||||
|
||||
# Ofast doesn't work with gcc builds
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast \
|
||||
# release specific cflags - optimizations beyond the default for both types is mostly just -O flags
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-DDEBUG_LEVEL=0 -DPRODUCTION=1")
|
||||
|
||||
# Ofast doesn't work with gcc builds
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast \
|
||||
-fno-signed-zeros -freciprocal-math -ffp-contract=fast \
|
||||
-fno-threadsafe-statics -fslp-vectorize-aggressive -fslp-vectorize \
|
||||
-fno-stack-protector -fstrict-enums -fstrict-vtable-pointers \
|
||||
-fno-threadsafe-statics -fslp-vectorize-aggressive -fslp-vectorize \
|
||||
-fno-stack-protector -fstrict-enums -fstrict-vtable-pointers \
|
||||
-fno-coverage-mapping -fno-spell-checking -fshort-enums -finline-functions \
|
||||
-finline-hint-functions -fno-unroll-loops")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
# O3 and Ofast include one or more flags that cause java to crash when using gcc6
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-signed-zeros -freciprocal-math -fno-unroll-loops -fno-tree-loop-optimize")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb")
|
||||
|
||||
# our "always on" flags - build by default for the system we're on but include all instruction sets
|
||||
set(CMAKE_CXX_FLAGS "-m32 -pipe -march=native -mtune=native \
|
||||
# RELWITHDEBINFO is used for building profiled builds
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-instr-generate")
|
||||
|
||||
# MINSIZEREL is used for profiled, flto builds
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
# O3 and Ofast include one or more flags that cause java to crash when using gcc6
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-signed-zeros -freciprocal-math -fno-unroll-loops -fno-tree-loop-optimize")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
||||
endif ()
|
||||
|
||||
# our "always on" flags - build by default for the system we're on but include all instruction sets
|
||||
set(CMAKE_CXX_FLAGS "-m32 -pipe -march=native -mtune=native \
|
||||
-msse -msse2 -msse3 -mmmx -m3dnow \
|
||||
-Wformat -Wno-overloaded-virtual -Wno-missing-braces -Wno-format \
|
||||
-Wno-write-strings -Wno-unknown-pragmas \
|
||||
-Wno-uninitialized -Wno-reorder -Wno-tautological-constant-out-of-range-compare")
|
||||
|
||||
add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE)
|
||||
endif()
|
||||
add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE)
|
||||
|
||||
# release and debug are internal use only
|
||||
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||
add_definitions(-DSTELLA_INTERNAL)
|
||||
endif()
|
||||
|
||||
# this is so some profile specific stuff is turned on in the code
|
||||
if (${CMAKE_BUILD_TYPE} STREQUAL "RELWITHDEBINFO")
|
||||
add_definitions(-DENABLE_PROFILING)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
add_subdirectory(external)
|
||||
add_subdirectory(engine)
|
||||
|
||||
@@ -59,5 +59,9 @@ int main(int argc, char ** argv)
|
||||
NetworkHandler::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -39,5 +39,9 @@ int main(int argc, char ** argv)
|
||||
ChatServer::run();
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ int main(int argc, char **argv)
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,6 +154,10 @@ void LogServer::setDone(char const *reasonfmt, ...)
|
||||
va_end(ap);
|
||||
m_done = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
std::exit(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "LoginServer.h"
|
||||
|
||||
@@ -15,35 +19,49 @@
|
||||
|
||||
// ======================================================================
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
setupFoundationData.lpCmdLine = ConvertCommandLine(argc,argv);
|
||||
setupFoundationData.configFile = "loginServer.cfg";
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
if (ConfigFile::isEmpty())
|
||||
FATAL(true, ("No config file specified"));
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedRandom::install(static_cast<uint32>(time(nullptr))); //lint !e1924 !e64 // nullptr is a C-Style cast?
|
||||
|
||||
Os::setProgramName("LoginServer");
|
||||
//setup the server
|
||||
ConfigLoginServer::install();
|
||||
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(LoginServer::run);
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
#ifdef ENABLE_PROFILING
|
||||
inline void signalHandler(int s){
|
||||
printf("LoginServer terminating, signal %d\n",s);
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#ifdef ENABLE_PROFILING
|
||||
struct sigaction sigIntHandler;
|
||||
sigIntHandler.sa_handler = signalHandler;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
#endif
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
setupFoundationData.lpCmdLine = ConvertCommandLine(argc, argv);
|
||||
setupFoundationData.configFile = "loginServer.cfg";
|
||||
SetupSharedFoundation::install(setupFoundationData);
|
||||
|
||||
if (ConfigFile::isEmpty()) {
|
||||
FATAL(true, ("No config file specified"));
|
||||
}
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedRandom::install(static_cast<uint32>(time(nullptr))); //lint !e1924 !e64 // nullptr is a C-Style cast?
|
||||
|
||||
Os::setProgramName("LoginServer");
|
||||
//setup the server
|
||||
ConfigLoginServer::install();
|
||||
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(LoginServer::run);
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1509,6 +1509,10 @@ void PlanetServer::setDone(char const *reasonfmt, ...)
|
||||
va_end(ap);
|
||||
m_done = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
std::exit(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -41,5 +41,9 @@ int main(int argc, char ** argv)
|
||||
TaskManager::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user