plain framework 商業版 開發總結2 項目管理器

任何事情都有三個階段,分析、製做、質檢的過程。在程序中就分爲設計、編碼、調試(測試)三個階段,其中設計最爲重要,設計的很差會致使編碼和調試重複,甚至最後又回到了設計的過程。爲了避免會重複返工,因此設計的時候須要考了全面,不然會致使資源上的浪費和佔用,甚至形成資源不足而終止。就像任何一個投資項目同樣,設計的很差,每每會致使人力資源的浪費,若是在項目進程中達不到預期的效果,這個項目生命週期就會縮短。app

一、項目管理器設計

  爲何要使用到項目管理器?若是這點都不明確,那麼這樣的功能需求是無效的,也就是說不須要這樣的功能。編譯的功能,之前在編譯的時候若是換了一個平臺或者VS的版本,就須要重寫編譯腳本。其實如今的CMAKE已經具有這樣的跨平臺功能,惋惜不能徹底知足PF項目的需求。因此須要使用項目管理器的一個功能就是生成不一樣平臺的編譯腳本,這樣項目管理器就是一個有效的需求了。其次大部分開源或是商業框架都使用到了自身的命令行或者管理器,如著名的虛幻引擎,也有本身的項目管理器。故而項目管理器,也是勢在必行的。框架

  項目管理器如今的主要功能是對現有的項目自動生成對應平臺的編譯腳本,Windows下面如今實現的是VC12的腳本,LINUX實現的是CMAKE腳本。編輯器

  如下是原型:測試

# This file generate by plain framework admin tool, date: 2015-05-07 19:42:16
SET(EXECUTABLE_OUTPUT_PATH ../../bin)

ADD_DEFINITIONS(-DPF_BUILD_AS_DLL)
ADD_DEFINITIONS(-D_DATABASE)
ADD_DEFINITIONS(-D__SERVER__)
SET(USE_32BITS 0)

IF(CMAKE_SYSTEM MATCHES Linux)
  ADD_DEFINITIONS(-D_REENTRANT)
  ADD_DEFINITIONS(-DDONT_TD_VOID)
  ADD_DEFINITIONS(-D_PF_NET_EPOLL)
ELSE(CMAKE_SYSTEM MATCHES Linux)
ENDIF(CMAKE_SYSTEM MATCHES Linux)

LINK_DIRECTORIES(
  "./"
  "./../../../pf/core/dll/"
  "./../../../pf/dependencies/dll/"
)

INCLUDE_DIRECTORIES(
  "../../../pf/core/include/"
  "../include/"
  "../../common/include/"
  "../../../pf/dependencies/lua/src/"
  "/usr/local/unixODBC/include/"
)

SET (COMMON_INCLUDE_COMMON_LIST
  ../../common/include/common/config.h
)

SET (COMMON_INCLUDE_COMMON_DEFINE_LIST
  ../../common/include/common/define/all.h
  ../../common/include/common/define/config.h
  ../../common/include/common/define/enum.h
  ../../common/include/common/define/file.h
  ../../common/include/common/define/log.h
  ../../common/include/common/define/macros.h
  ../../common/include/common/define/struct.h
)

SET (COMMON_INCLUDE_COMMON_DEFINE_NET_LIST
  ../../common/include/common/define/net/config.h
)

SET (COMMON_INCLUDE_COMMON_DEFINE_NET_PACKET_LIST
  ../../common/include/common/define/net/packet/config.h
)

SET (COMMON_INCLUDE_COMMON_DEFINE_NET_PACKET_ID_LIST
  ../../common/include/common/define/net/packet/id/all.h
  ../../common/include/common/define/net/packet/id/billinglogin.h
  ../../common/include/common/define/net/packet/id/clientlogin.h
  ../../common/include/common/define/net/packet/id/clientserver.h
  ../../common/include/common/define/net/packet/id/config.h
  ../../common/include/common/define/net/packet/id/logincenter.h
  ../../common/include/common/define/net/packet/id/servercenter.h
  ../../common/include/common/define/net/packet/id/serverserver.h
)

SET (COMMON_INCLUDE_COMMON_NET_LIST
  ../../common/include/common/net/config.h
  ../../common/include/common/net/packetfactory.h
)

SET (COMMON_INCLUDE_COMMON_NET_PACKET_LIST
  ../../common/include/common/net/packet/config.h
)

SET (COMMON_INCLUDE_COMMON_NET_PACKET_SERVERSERVER_LIST
  ../../common/include/common/net/packet/serverserver/config.h
  ../../common/include/common/net/packet/serverserver/connect.h
  ../../common/include/common/net/packet/serverserver/dbquery.h
  ../../common/include/common/net/packet/serverserver/dbresult.h
  ../../common/include/common/net/packet/serverserver/config.h
  ../../common/include/common/net/packet/serverserver/connect.h
  ../../common/include/common/net/packet/serverserver/dbquery.h
  ../../common/include/common/net/packet/serverserver/dbresult.h
)
SET (INCLUDE_LIST
  ../include/main.h
)

SET (INCLUDE_APPLICATION_LIST
  ../include/application/config.h
)

SET (INCLUDE_ENGINE_LIST
  ../include/engine/config.h
  ../include/engine/system.h
)

SET (INCLUDE_THREAD_LIST
  ../include/thread/archive.h
  ../include/thread/archivemanager.h
  ../include/thread/config.h
)
SET (COMMON_SRC_DEFINE_LIST
  ../../common/src/define/struct.cc
)

SET (COMMON_SRC_LIST
  ../../common/src/setting.cc
)

SET (COMMON_SRC_NET_PACKET_SERVERSERVER_LIST
  ../../common/src/net/packet/serverserver/connect.cc
  ../../common/src/net/packet/serverserver/dbquery.cc
  ../../common/src/net/packet/serverserver/dbresult.cc
  ../../common/src/net/packet/serverserver/connect.cc
  ../../common/src/net/packet/serverserver/dbquery.cc
  ../../common/src/net/packet/serverserver/dbresult.cc
)

SET (COMMON_SRC_NET_LIST
  ../../common/src/net/packetfactory.cc
)
SET (SRC_LIST
  ../src/main.cc
)

SET (SRC_ENGINE_LIST
  ../src/engine/system.cc
)

SET (SRC_MESSAGE_HANDLER_SERVERSERVER_LIST
  ../src/message/handler/serverserver/connect.cc
  ../src/message/handler/serverserver/dbquery.cc
)

SET (SRC_THREAD_LIST
  ../src/thread/archive.cc
  ../src/thread/archivemanager.cc
)


ADD_EXECUTABLE(database
  ${SRC_LIST}
  ${SRC_ENGINE_LIST}
  ${SRC_MESSAGE_HANDLER_SERVERSERVER_LIST}
  ${SRC_THREAD_LIST}
  ${COMMON_SRC_DEFINE_LIST}
  ${COMMON_SRC_LIST}
  ${COMMON_SRC_NET_PACKET_SERVERSERVER_LIST}
  ${COMMON_SRC_NET_LIST}
)

if(USE_32BITS)
  SET(CMAKE_C_FLAGS "-Wall -ggdb -pipe -march=i386 -mtune=i686")
  SET(CMAKE_CXX_FLAGS "-Wall -ggdb -pipe -march=i386 -mtune=i686")
else()
  SET(CMAKE_C_FLAGS "-Wall -ggdb -pipe -march=x86-64 -mtune=i686")
  SET(CMAKE_CXX_FLAGS "-Wall -ggdb -pipe -march=x86-64 -mtune=i686")
endif(USE_32BITS)

if (WIN32)
TARGET_LINK_LIBRARIES(database ws2_32.lib odbc32.lib odbccp32.lib pf_core.lib lua.lib iconv.lib)
else()
TARGET_LINK_LIBRARIES(database odbc pf_core lua iconv)
  if(USE_32BITS)
    SET(CMAKE_C_FLAGS "-Wall -ggdb -pipe -march=i386 -mtune=i686")
    SET(CMAKE_CXX_FLAGS "-Wall -ggdb -pipe -march=i386 -mtune=i686")
  else()
    SET(CMAKE_C_FLAGS "-Wall -ggdb -pipe -march=x86-64 -mtune=i686")
    SET(CMAKE_CXX_FLAGS "-Wall -ggdb -pipe -march=x86-64 -mtune=i686")
  endif(USE_32BITS)
endif(WIN32)
<?xml version="1.0" encoding="utf-8"?>
<!-- This file generate by plain framework admin tool, date: 2015-05-07 21:21:36 -->
<Project DefaultTargets="Build" ToolsVersion="12.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="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>

  <ItemGroup>
    <ClCompile Include="..\..\common\include\common\config.h" />
    <ClCompile Include="..\..\common\include\common\define\all.h" />
    <ClCompile Include="..\..\common\include\common\define\config.h" />
    <ClCompile Include="..\..\common\include\common\define\enum.h" />
    <ClCompile Include="..\..\common\include\common\define\file.h" />
    <ClCompile Include="..\..\common\include\common\define\log.h" />
    <ClCompile Include="..\..\common\include\common\define\macros.h" />
    <ClCompile Include="..\..\common\include\common\define\struct.h" />
    <ClCompile Include="..\..\common\include\common\define\net\config.h" />
    <ClCompile Include="..\..\common\include\common\define\net\packet\config.h" />
    <ClCompile Include="..\..\common\include\common\define\net\packet\id\all.h" />
    <ClCompile Include="..\..\common\include\common\define\net\packet\id\billinglogin.h" />
    <ClCompile Include="..\..\common\include\common\define\net\packet\id\clientlogin.h" />
    <ClCompile Include="..\..\common\include\common\define\net\packet\id\clientserver.h" />
    <ClCompile Include="..\..\common\include\common\define\net\packet\id\config.h" />
    <ClCompile Include="..\..\common\include\common\define\net\packet\id\logincenter.h" />
    <ClCompile Include="..\..\common\include\common\define\net\packet\id\servercenter.h" />
    <ClCompile Include="..\..\common\include\common\define\net\packet\id\serverserver.h" />
    <ClCompile Include="..\..\common\include\common\net\config.h" />
    <ClCompile Include="..\..\common\include\common\net\packetfactory.h" />
    <ClCompile Include="..\..\common\include\common\net\packet\config.h" />
    <ClCompile Include="..\..\common\include\common\net\packet\serverserver\config.h" />
    <ClCompile Include="..\..\common\include\common\net\packet\serverserver\connect.h" />
    <ClCompile Include="..\..\common\include\common\net\packet\serverserver\dbquery.h" />
    <ClCompile Include="..\..\common\include\common\net\packet\serverserver\dbresult.h" />
    <ClCompile Include="..\..\common\include\common\net\packet\serverserver\config.h" />
    <ClCompile Include="..\..\common\include\common\net\packet\serverserver\connect.h" />
    <ClCompile Include="..\..\common\include\common\net\packet\serverserver\dbquery.h" />
    <ClCompile Include="..\..\common\include\common\net\packet\serverserver\dbresult.h" />
    <ClInclude Include="..\include\main.h" />
    <ClInclude Include="..\include\application\config.h" />
    <ClInclude Include="..\include\engine\config.h" />
    <ClInclude Include="..\include\engine\system.h" />
    <ClInclude Include="..\include\thread\archive.h" />
    <ClInclude Include="..\include\thread\archivemanager.h" />
    <ClInclude Include="..\include\thread\config.h" />
    <ClInclude Include="resource.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="..\..\common\src\define\applications_common_define_struct.cc" />
    <ClCompile Include="..\..\common\src\applications_common_src_setting.cc" />
    <ClCompile Include="..\..\common\src\net\packet\serverserver\applications_common_net_packet_serverserver_connect.cc" />
    <ClCompile Include="..\..\common\src\net\packet\serverserver\applications_common_net_packet_serverserver_dbquery.cc" />
    <ClCompile Include="..\..\common\src\net\packet\serverserver\applications_common_net_packet_serverserver_dbresult.cc" />
    <ClCompile Include="..\..\common\src\net\packet\serverserver\applications_common_net_packet_serverserver_connect.cc" />
    <ClCompile Include="..\..\common\src\net\packet\serverserver\applications_common_net_packet_serverserver_dbquery.cc" />
    <ClCompile Include="..\..\common\src\net\packet\serverserver\applications_common_net_packet_serverserver_dbresult.cc" />
    <ClCompile Include="..\..\common\src\net\applications_common_net_packetfactory.cc" />
    <ClCompile Include="..\src\applications_database_src_main.cc" />
    <ClCompile Include="..\src\engine\applications_database_engine_system.cc" />
    <ClCompile Include="..\src\thread\applications_database_thread_archive.cc" />
    <ClCompile Include="..\src\thread\applications_database_thread_archivemanager.cc" />
    <ClCompile Include="..\src\message\handler\serverserver\applications_database_message_handler_serverserver_connect.cc" />
    <ClCompile Include="..\src\message\handler\serverserver\applications_database_message_handler_serverserver_dbquery.cc" />
  </ItemGroup>
  <ItemGroup>
    <ResourceCompile Include="database.rc" />
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{88F6D0EC-8597-40CE-9BA5-6A2813C82C3A}</ProjectGuid>
    <Keyword>Win32Proj</Keyword>
    <RootNamespace>${project_name}</RootNamespace>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v120</PlatformToolset>
    <CharacterSet>MultiByte</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v120</PlatformToolset>
    <CharacterSet>MultiByte</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v120</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>MultiByte</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v120</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>MultiByte</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 Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
    <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>
  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
    <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'">
    <LinkIncremental>true</LinkIncremental>
    <OutDir>./../bin/$(PlatformName)/$(Configuration)/</OutDir>
    <IntDir>$(ProjectName).dir/$(PlatformName)/$(Configuration)/</IntDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <LinkIncremental>true</LinkIncremental>
    <OutDir>./../bin/$(PlatformName)/$(Configuration)/</OutDir>
    <IntDir>$(ProjectName).dir/$(PlatformName)/$(Configuration)/</IntDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <LinkIncremental>false</LinkIncremental>
    <OutDir>./../bin/$(PlatformName)/$(Configuration)/</OutDir>
    <IntDir>$(ProjectName).dir/$(PlatformName)/$(Configuration)/</IntDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <LinkIncremental>false</LinkIncremental>
    <OutDir>./../bin/$(PlatformName)/$(Configuration)/</OutDir>
    <IntDir>$(ProjectName).dir/$(PlatformName)/$(Configuration)/</IntDir>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <WarningLevel>Level4</WarningLevel>
      <Optimization>Disabled</Optimization>
      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;PF_BUILD_AS_DLL;_DATABASE;__SERVER__;PF_BUILD_AS_DLL;ICONV_BUILD_AS_DLL;CHARSET_BUILD_AS_DLL;LUA_BUILD_AS_DLL;ZLIB_DLL;PF_PLUGIN_BUILD_AS_DLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>../../../pf/core/include/;../include/;../../common/include/;../../../pf/dependencies/lua/src/;/usr/local/unixODBC/include/;</AdditionalIncludeDirectories>
      <DisableSpecificWarnings>4819;</DisableSpecificWarnings>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
       <Version>1.00</Version>
      <AdditionalLibraryDirectories>./$(PlatformName)/$(Configuration)/;./../../../pf/core/dll/$(PlatformName)/$(Configuration)/;./../../../pf/dependencies/dll/$(PlatformName)/$(Configuration)/;</AdditionalLibraryDirectories>
      <AdditionalDependencies>ws2_32.lib;pf_core.lib;lua.lib;iconv.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <WarningLevel>Level4</WarningLevel>
      <Optimization>Disabled</Optimization>
      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;PF_BUILD_AS_DLL;_DATABASE;__SERVER__;PF_BUILD_AS_DLL;ICONV_BUILD_AS_DLL;CHARSET_BUILD_AS_DLL;LUA_BUILD_AS_DLL;ZLIB_DLL;PF_PLUGIN_BUILD_AS_DLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>../../../pf/core/include/;../include/;../../common/include/;../../../pf/dependencies/lua/src/;/usr/local/unixODBC/include/;</AdditionalIncludeDirectories>
      <DisableSpecificWarnings>4819;</DisableSpecificWarnings>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
       <Version>1.00</Version>
      <AdditionalLibraryDirectories>./$(PlatformName)/$(Configuration)/;./../../../pf/core/dll/$(PlatformName)/$(Configuration)/;./../../../pf/dependencies/dll/$(PlatformName)/$(Configuration)/;</AdditionalLibraryDirectories>
      <AdditionalDependencies>ws2_32.lib;pf_core.lib;lua.lib;iconv.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;PF_BUILD_AS_DLL;_DATABASE;__SERVER__;PF_BUILD_AS_DLL;ICONV_BUILD_AS_DLL;CHARSET_BUILD_AS_DLL;LUA_BUILD_AS_DLL;ZLIB_DLL;PF_PLUGIN_BUILD_AS_DLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>../../../pf/core/include/;../include/;../../common/include/;../../../pf/dependencies/lua/src/;/usr/local/unixODBC/include/;</AdditionalIncludeDirectories>
      <DisableSpecificWarnings>4819;</DisableSpecificWarnings>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
       <Version>1.00</Version>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <AdditionalLibraryDirectories>./$(PlatformName)/$(Configuration)/;./../../../pf/core/dll/$(PlatformName)/$(Configuration)/;./../../../pf/dependencies/dll/$(PlatformName)/$(Configuration)/;</AdditionalLibraryDirectories>
      <AdditionalDependencies>ws2_32.lib;pf_core.lib;lua.lib;iconv.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;PF_BUILD_AS_DLL;_DATABASE;__SERVER__;PF_BUILD_AS_DLL;ICONV_BUILD_AS_DLL;CHARSET_BUILD_AS_DLL;LUA_BUILD_AS_DLL;ZLIB_DLL;PF_PLUGIN_BUILD_AS_DLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>../../../pf/core/include/;../include/;../../common/include/;../../../pf/dependencies/lua/src/;/usr/local/unixODBC/include/;</AdditionalIncludeDirectories>
      <DisableSpecificWarnings>4819;</DisableSpecificWarnings>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
       <Version>1.00</Version>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <AdditionalLibraryDirectories>./$(PlatformName)/$(Configuration)/;./../../../pf/core/dll/$(PlatformName)/$(Configuration)/;./../../../pf/dependencies/dll/$(PlatformName)/$(Configuration)/;</AdditionalLibraryDirectories>
      <AdditionalDependencies>ws2_32.lib;pf_core.lib;lua.lib;iconv.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>

  功能需求很明確,就是要怎樣生成這兩種腳本。要生成這兩種腳本,必要的就是這兩種文件的結構。要寫一個CMAKE其實不太難,而VS腳本直接用VS編輯器生成便可。可是咱們如今知道的是源碼所在的目錄,或者一些散亂的源碼文件,那麼怎樣生成這兩種文件?ui

  要生成文件,咱們就要知道文件的內容是怎樣的,其組成又是怎樣的。本次是以CMAKE2.6和VS2013做爲基礎,那麼咱們就看下這兩種編譯腳本的結構是怎麼樣的吧。編碼

  分析不一樣平臺的異同,因而我將之總結爲如下字段,造成項目管理的基本文件。lua

/**
  Plain framework project file.
  Version:              The project current version.
  Type:                 Project type [library|executable].
  LinkDirectories:      Link directories as the Dependencies directories.
  IncludeDirectories:   Include directories.
  ExtraSources:         Extra source file or directories.
  SourceFilters:        Source directory or filename filter(not active).
  OutputPath:           The project output path.
  Definitions:          Macros definitions.
  Dependencies:         Dependencies library.
**/
{
  "Version": "1.0.1",
  "Type": "executable",
  "LinkDirectories": [
    "./",
    "./../../../pf/core/dll",
    "./../../../pf/dependencies/dll"
  ],
  "IncludeDirectories": [
    "../../../pf/core/include",
    "../include",
    "../../common/include",
    "../../../pf/dependencies/lua/src",
    "/usr/local/unixODBC/include"
  ],
  "ExtraSources": [
   /* static common settings { */
    "../common/include/common/config.h",
    "../common/include/common/define/",
    "../common/include/common/net/config.h",
    "../common/include/common/net/packet/config.h",
    "../common/include/common/net/packetfactory.h",
    "../common/include/common/net/packet/serverserver",
    "../common/src/define",
    "../common/src/setting.cc",
    "../common/src/net/packet/serverserver/",
    "../common/src/net/packetfactory.cc"
  /* static common settings } */ /* projcet only { */ /* } projcet only */ ], "SourceFilters": [ "CMakeFiles" ], "DisableSpecificWarnings": "4819;", "OutputPath": "../../bin", "Definitions": [ "PF_BUILD_AS_DLL", "_DATABASE", "__SERVER__" ], "Dependencies": [ "pf_core", "lua", "iconv" ]

二、項目管理器編碼

  有不少的數據不須要咱們改變,此時聯想到的就是模板。到了這裏,不少人可能不明白模板是什麼。我就簡單用一句話歸納,模板是生產通用的模型。可能這句話難以理解,不過能夠本身查找一下,如C++中的模板、PHP等腳本框架中的smart模板等等。spa

  模板就是要把固定和可變的部分分離出來,固定的部分咱們直接放在模板中不用動,可變的部分咱們用一種叫模板變量的東西關聯起來。那麼在使用過程當中,模板變量又是如何操做的?簡言之,模板變量就是值替換的過程。命令行

  項目管理基本文件中的配置,就有這些模板變量,在編碼的時候咱們就須要考慮怎樣將這些變量替換到模板中。其中比較複雜的就是文件列表,這部分能夠本身找尋一些目錄遍歷。設計

  CMAKE模板:

# This file generate by plain framework admin tool, date: ${time}
${outputpath}
${definitions}
${basebit}

IF(CMAKE_SYSTEM MATCHES Linux)
  ADD_DEFINITIONS(-D_REENTRANT)
  ADD_DEFINITIONS(-DDONT_TD_VOID)
  ADD_DEFINITIONS(-D_PF_NET_EPOLL)
ELSE(CMAKE_SYSTEM MATCHES Linux)
ENDIF(CMAKE_SYSTEM MATCHES Linux)

LINK_DIRECTORIES(
${link_directories}
)

INCLUDE_DIRECTORIES(
${include_directories}
)

${sources_list}

${type_auto}
${sources_group_list}
)

if(USE_32BITS)
  SET(CMAKE_C_FLAGS "-Wall -ggdb -pipe -march=i386 -mtune=i686")
  SET(CMAKE_CXX_FLAGS "-Wall -ggdb -pipe -march=i386 -mtune=i686")
else()
  SET(CMAKE_C_FLAGS "-Wall -ggdb -pipe -march=x86-64 -mtune=i686")
  SET(CMAKE_CXX_FLAGS "-Wall -ggdb -pipe -march=x86-64 -mtune=i686")
endif(USE_32BITS)

if (WIN32)
TARGET_LINK_LIBRARIES(${project_name} ws2_32.lib ${odbc_dependencies_w} ${dependencies_w})
else()
TARGET_LINK_LIBRARIES(${project_name} ${odbc_dependencies} ${dependencies})
  if(USE_32BITS)
    SET(CMAKE_C_FLAGS "-Wall -ggdb -pipe -march=i386 -mtune=i686")
    SET(CMAKE_CXX_FLAGS "-Wall -ggdb -pipe -march=i386 -mtune=i686")
  else()
    SET(CMAKE_C_FLAGS "-Wall -ggdb -pipe -march=x86-64 -mtune=i686")
    SET(CMAKE_CXX_FLAGS "-Wall -ggdb -pipe -march=x86-64 -mtune=i686")
  endif(USE_32BITS)
endif(WIN32)

三、項目管理器調試

  首先生成的腳本在LINUX上使用CMAKE運行,其次再使用VS打開編譯腳本進行編譯。若是編譯經過,那麼初次測試就算經過了。

 

相關文章
相關標籤/搜索