Added UtilsEngineTemplate

This commit is contained in:
Vladislav Khorev 2014-04-20 08:54:46 +00:00
parent e89f4e3dd3
commit e4a7822385
7 changed files with 351 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{086DBA7B-9D25-47EF-8371-0E4CE295FD3F}</ProjectGuid>
<RootNamespace>k_observer_srv</RootNamespace>
<ProjectName>UtilsEngineTemplate</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)\include;</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LibraryPath>$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration);</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)\include;</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration);</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;../../jni/network</AdditionalIncludeDirectories>
<PreprocessorDefinitions>UTILS_ENGINE;TARGET_WIN32;_WIN32_WINNT=0x0501;XO_SERVER</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\sqplus\lib</AdditionalLibraryDirectories>
<AdditionalDependencies>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)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;../../jni/network</AdditionalIncludeDirectories>
<PreprocessorDefinitions>UTILS_ENGINE;TARGET_WIN32;_WIN32_WINNT=0x0501;XO_SERVER</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\sqplus\lib</AdditionalLibraryDirectories>
<AdditionalDependencies>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)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="linux_stuff.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="linux_stuff.h" />
<ClInclude Include="main.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,57 @@
#ifndef _WIN32
#include "linux_stuff.h"
#include <iostream>
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"<<std::endl;
exit(EXIT_FAILURE);
}
/* If we got a good PID, then
we can exit the parent process. */
if (pid > 0) {
std::cout<<"pid > 0 exit process"<<std::endl;
exit(EXIT_SUCCESS);
}
/* Change the file mode mask */
umask(0);
/* Open any logs here */
/* Create a new SID for the child process */
sid = setsid();
if (sid < 0) {
/* Log the failure */
std::cout<<"sid < 0 exit process"<<std::endl;
exit(EXIT_FAILURE);
}
/* Change the current working directory */
if ((chdir("/")) < 0) {
/* Log the failure */
std::cout<<"(chdir(\"/\")) < 0 exit process"<<std::endl;
exit(EXIT_FAILURE);
}
/* Close out the standard file descriptors */
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
}
#endif

View File

@ -0,0 +1,25 @@
#ifndef LINUX_STUFF_H_INCLUDED
#define LINUX_STUFF_H_INCLUDED
#ifndef _WIN32
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>
void daemonize();
#endif
#endif

View File

@ -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;
}

View File

@ -0,0 +1,21 @@
#include <iostream>
#include <fstream>
#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;