From e4a7822385e38cad8010bcbae29400463702eb24 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Sun, 20 Apr 2014 08:54:46 +0000 Subject: [PATCH] Added UtilsEngineTemplate --- .../UtilsEngineTemplateSln.sln | 26 ++++ Templates/UtilsEngineTemplate/linux/makefile | 114 ++++++++++++++++++ .../src/UtilsEngineTemplate.vcxproj | 93 ++++++++++++++ .../UtilsEngineTemplate/src/linux_stuff.cpp | 57 +++++++++ .../UtilsEngineTemplate/src/linux_stuff.h | 25 ++++ Templates/UtilsEngineTemplate/src/main.cpp | 15 +++ Templates/UtilsEngineTemplate/src/main.h | 21 ++++ 7 files changed, 351 insertions(+) create mode 100644 Templates/UtilsEngineTemplate/UtilsEngineTemplateSln.sln create mode 100644 Templates/UtilsEngineTemplate/linux/makefile create mode 100644 Templates/UtilsEngineTemplate/src/UtilsEngineTemplate.vcxproj create mode 100644 Templates/UtilsEngineTemplate/src/linux_stuff.cpp create mode 100644 Templates/UtilsEngineTemplate/src/linux_stuff.h create mode 100644 Templates/UtilsEngineTemplate/src/main.cpp create mode 100644 Templates/UtilsEngineTemplate/src/main.h diff --git a/Templates/UtilsEngineTemplate/UtilsEngineTemplateSln.sln b/Templates/UtilsEngineTemplate/UtilsEngineTemplateSln.sln new file mode 100644 index 0000000..ad1158e --- /dev/null +++ b/Templates/UtilsEngineTemplate/UtilsEngineTemplateSln.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UtilsEngineTemplate", "src\UtilsEngineTemplate.vcxproj", "{086DBA7B-9D25-47EF-8371-0E4CE295FD3F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UtilsEngine", "..\..\engine\UtilsEngine\UtilsEngine.vcxproj", "{C29A7BA8-207A-46B8-AAAF-368AED22EC2A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {086DBA7B-9D25-47EF-8371-0E4CE295FD3F}.Debug|Win32.ActiveCfg = Debug|Win32 + {086DBA7B-9D25-47EF-8371-0E4CE295FD3F}.Debug|Win32.Build.0 = Debug|Win32 + {086DBA7B-9D25-47EF-8371-0E4CE295FD3F}.Release|Win32.ActiveCfg = Release|Win32 + {086DBA7B-9D25-47EF-8371-0E4CE295FD3F}.Release|Win32.Build.0 = Release|Win32 + {C29A7BA8-207A-46B8-AAAF-368AED22EC2A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C29A7BA8-207A-46B8-AAAF-368AED22EC2A}.Debug|Win32.Build.0 = Debug|Win32 + {C29A7BA8-207A-46B8-AAAF-368AED22EC2A}.Release|Win32.ActiveCfg = Release|Win32 + {C29A7BA8-207A-46B8-AAAF-368AED22EC2A}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Templates/UtilsEngineTemplate/linux/makefile b/Templates/UtilsEngineTemplate/linux/makefile new file mode 100644 index 0000000..99ae1fe --- /dev/null +++ b/Templates/UtilsEngineTemplate/linux/makefile @@ -0,0 +1,114 @@ +CC=g++-4.7 +CFLAGS=-Wall -O3 -std=gnu++0x +LDFLAGS= -lpthread + + +#====================================================== +#====================== BOOST ========================= +#====================================================== + +CFLAGS += -I$(LibsPath)/boost_1_52_0 + +#thread +LOCAL_SRC_FILES := $(LibsPath)/boost_1_52_0/libs/thread/src/pthread/thread.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/thread/src/pthread/once.cpp + +#signals +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/signals/src/connection.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/signals/src/named_slot_map.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/signals/src/signal_base.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/signals/src/slot.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/signals/src/trackable.cpp + +#system +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/system/src/error_code.cpp + +#regex +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/c_regex_traits.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/cpp_regex_traits.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/cregex.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/fileiter.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/icu.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/instances.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/posix_api.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/regex.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/regex_debug.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/regex_raw_buffer.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/regex_traits_defaults.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/static_mutex.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/usinstances.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/w32_regex_traits.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/wc_regex_traits.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/wide_posix_api.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/regex/src/winstances.cpp + +#date_time +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/date_time/src/gregorian/greg_month.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/date_time/src/gregorian/greg_weekday.cpp +LOCAL_SRC_FILES += $(LibsPath)/boost_1_52_0/libs/date_time/src/gregorian/date_generators.cpp + + +#====================================================== +#==================== Squirrel ======================== +#====================================================== + +CFLAGS += -I$(LibsPath)/sqplus/include -I$(LibsPath)/sqplus/sqplus -I$(LibsPath)/sqplus/squirrel -I$(LibsPath)/sqplus/sqstdlib + +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqapi.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqbaselib.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqclass.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqcompiler.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqdebug.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqfuncstate.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqlexer.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqmem.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqobject.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqstate.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqtable.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/squirrel/sqvm.cpp + +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqplus/SqPlus.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqplus/SqPlusOCharBuf.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqplus/SqPlusUtf8.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqplus/SquirrelBindingsUtils.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqplus/SquirrelObject.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqplus/SquirrelVM.cpp + +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqstdlib/sqstdblob.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqstdlib/sqstdio.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqstdlib/sqstdmath.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqstdlib/sqstdrex.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqstdlib/sqstdstream.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqstdlib/sqstdstring.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqstdlib/sqstdsystem.cpp +LOCAL_SRC_FILES += $(LibsPath)/sqplus/sqstdlib/sqstdaux.cpp + +#====================================================== +#==================== ENGINE ========================== +#====================================================== + +CFLAGS += -DUTILS_ENGINE -DTARGET_LINUX + +CFLAGS += -I$(SalmonEnginePath) + +LOCAL_SRC_FILES += $(SalmonEnginePath)/src/Utils/DataTypes/DataTypes.cpp +LOCAL_SRC_FILES += $(SalmonEnginePath)/src/Utils/DataTypes/NewDataTypes.cpp +LOCAL_SRC_FILES += $(SalmonEnginePath)/src/Utils/FileUtils/FileUtils.cpp +LOCAL_SRC_FILES += $(SalmonEnginePath)/src/Utils/Console/Console.cpp +LOCAL_SRC_FILES += $(SalmonEnginePath)/src/Utils/SerializeInterface/SerializeInterface.cpp +LOCAL_SRC_FILES += $(SalmonEnginePath)/src/Utils/Network/Server.cpp +LOCAL_SRC_FILES += $(SalmonEnginePath)/src/Utils/Network/Network.cpp +LOCAL_SRC_FILES += $(SalmonEnginePath)/src/Utils/SimpleTimer.cpp +LOCAL_SRC_FILES += $(SalmonEnginePath)/src/Utils/ThreadUtils.cpp + +#====================================================== +#====================== GAME ========================== +#====================================================== + +CFLAGS += -I../UtilsEngineTemplate + +LOCAL_SRC_FILES += ../XO-game_srv/main.cpp +LOCAL_SRC_FILES += ../XO-game_srv/linux_stuff.cpp + +all: + $(CC) $(LOCAL_SRC_FILES) $(CFLAGS) $(LDFLAGS) -o UtilsEngineTemplate \ No newline at end of file diff --git a/Templates/UtilsEngineTemplate/src/UtilsEngineTemplate.vcxproj b/Templates/UtilsEngineTemplate/src/UtilsEngineTemplate.vcxproj new file mode 100644 index 0000000..28492fa --- /dev/null +++ b/Templates/UtilsEngineTemplate/src/UtilsEngineTemplate.vcxproj @@ -0,0 +1,93 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {086DBA7B-9D25-47EF-8371-0E4CE295FD3F} + k_observer_srv + UtilsEngineTemplate + + + + Application + true + NotSet + + + Application + false + true + NotSet + + + + + + + + + + + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)\include; + + + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration); + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)\include; + + + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration); + + + + Level3 + Disabled + $(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;../../jni/network + UTILS_ENGINE;TARGET_WIN32;_WIN32_WINNT=0x0501;XO_SERVER + + + true + $(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\sqplus\lib + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;UtilsEngine.lib;sqplusD.lib;squirrelD.lib;sqdbglibD.lib;sqstdlibD.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + $(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;../../jni/network + UTILS_ENGINE;TARGET_WIN32;_WIN32_WINNT=0x0501;XO_SERVER + + + true + true + true + $(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\sqplus\lib + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;UtilsEngine.lib;sqplus.lib;squirrel.lib;sqdbglib.lib;sqstdlib.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Templates/UtilsEngineTemplate/src/linux_stuff.cpp b/Templates/UtilsEngineTemplate/src/linux_stuff.cpp new file mode 100644 index 0000000..c6e517a --- /dev/null +++ b/Templates/UtilsEngineTemplate/src/linux_stuff.cpp @@ -0,0 +1,57 @@ +#ifndef _WIN32 + +#include "linux_stuff.h" +#include + +void daemonize() +{ + /* Our process ID and Session ID */ + pid_t pid, sid; + + /* Fork off the parent process */ + pid = fork(); + if (pid < 0) + { + std::cout<<"error, pid < 0"< 0) { + std::cout<<"pid > 0 exit process"< +#include +#include +#include +#include +#include +#include +#include +#include + + + +void daemonize(); + + + +#endif + + + +#endif \ No newline at end of file diff --git a/Templates/UtilsEngineTemplate/src/main.cpp b/Templates/UtilsEngineTemplate/src/main.cpp new file mode 100644 index 0000000..5deebe5 --- /dev/null +++ b/Templates/UtilsEngineTemplate/src/main.cpp @@ -0,0 +1,15 @@ +#include "main.h" + +#include "boost/foreach.hpp" +#include "boost/lexical_cast.hpp" +#include "boost/random.hpp" + +int main(int argc, char *argv[]) +{ + #ifndef _WIN32 + daemonize(); + #endif + + return 0; +} + diff --git a/Templates/UtilsEngineTemplate/src/main.h b/Templates/UtilsEngineTemplate/src/main.h new file mode 100644 index 0000000..3f5dc17 --- /dev/null +++ b/Templates/UtilsEngineTemplate/src/main.h @@ -0,0 +1,21 @@ +#include +#include + + +#include "boost/asio.hpp" +#include "boost/bind.hpp" +#include "boost/shared_ptr.hpp" +#include "boost/array.hpp" +#include "boost/enable_shared_from_this.hpp" +#include "boost/signal.hpp" +#include "boost/thread.hpp" +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/property_tree/ptree.hpp" +#include "boost/property_tree/xml_parser.hpp" + +#include "linux_stuff.h" + +#include "include/Utils/Utils.h" + +using namespace SE; +