Core/Scripts: Split script subdirectories into independent modules

* Makes it possible to define the linkage for every module
* Move the ScriptPCH into the root directory
* Changes the SCRIPTS cmake variable to a string type:
  -> -DSCRIPTS=0 is -DSCRIPTS="minimal-static" now
     (builds commands and spells statically)
  -> -DSCRIPTS=1 is -DSCRIPTS="static" now
     (builds all modules statically)
  -> -DSCRIPTS="dynamic"
     (builds all modules dynamically)
  -> Also the default value which is provided by the SCRIPTS
     variable is overwriteable through the SCRIPTS_COMMANDS,
     SCRIPTS_SPELLS... variable.
This commit is contained in:
Naios
2016-03-24 18:19:56 +01:00
parent 4710b1c8fe
commit 848b8a4136
15 changed files with 399 additions and 118 deletions

View File

@@ -23,7 +23,7 @@ install:
- mysql -uroot -e 'create database test_mysql;'
- mkdir bin
- cd bin
- cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS=1 -DSERVERS=1 -DNOJEM=1 -DWITH_DYNAMIC_LINKING=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_INSTALL_PREFIX=check_install
- cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS="dynamic" -DSERVERS=1 -DNOJEM=1 -DWITH_DYNAMIC_LINKING=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_INSTALL_PREFIX=check_install
- cd ..
- sudo chmod +x contrib/check_updates.sh

View File

@@ -44,6 +44,7 @@ endif()
include(CheckCXXSourceRuns)
include(CheckIncludeFiles)
include(ConfigureScripts)
# set default buildoptions and print them
include(cmake/options.cmake)

View File

@@ -19,7 +19,7 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-narrowing -Wno-deprecated-register")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1")
if (WITH_DYNAMIC_LINKING)
if (BUILD_SHARED_LIBS)
# -fPIC is needed to allow static linking in shared libs.
# -fvisibility=hidden sets the default visibility to hidden to prevent exporting of all symbols.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fvisibility=hidden")

View File

@@ -35,7 +35,7 @@ if( WITH_COREDEBUG )
message(STATUS "GCC: Debug-flags set (-g3)")
endif()
if (WITH_DYNAMIC_LINKING)
if (BUILD_SHARED_LIBS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fvisibility=hidden -Wno-attributes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fvisibility=hidden -Wno-attributes")

View File

@@ -42,7 +42,7 @@ endif()
# multithreaded compiling on VS
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
if((PLATFORM EQUAL 64) OR (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0) OR WITH_DYNAMIC_LINKING)
if((PLATFORM EQUAL 64) OR (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0) OR BUILD_SHARED_LIBS)
# Enable extended object support
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
message(STATUS "MSVC: Enabled increased number of sections in object files")
@@ -81,7 +81,7 @@ if(NOT WITH_WARNINGS)
message(STATUS "MSVC: Disabled generic compiletime warnings")
endif()
if (WITH_DYNAMIC_LINKING)
if (BUILD_SHARED_LIBS)
# C4251: needs to have dll-interface to be used by clients of class '...'
# C4275: non dll-interface class ...' used as base for dll-interface class '...'
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251 /wd4275")

View File

@@ -0,0 +1,83 @@
# Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# Stores the project name of the given module in the variable
function(GetProjectNameOfScriptModule module variable)
string(TOLOWER "scripts_${SCRIPT_MODULE}" GENERATED_NAME)
set(${variable} "${GENERATED_NAME}" PARENT_SCOPE)
endfunction()
# Creates a list of all script modules
# and stores it in the given variable.
function(GetScriptModuleList variable)
GetPathToScriptModule("" BASE_PATH)
file(GLOB LOCALE_SCRIPT_MODULE_LIST RELATIVE
${BASE_PATH}
${BASE_PATH}/*)
set(${variable})
foreach(SCRIPT_MODULE ${LOCALE_SCRIPT_MODULE_LIST})
GetPathToScriptModule(${SCRIPT_MODULE} SCRIPT_MODULE_PATH)
if (IS_DIRECTORY ${SCRIPT_MODULE_PATH})
list(APPEND ${variable} ${SCRIPT_MODULE})
endif()
endforeach()
set(${variable} ${${variable}} PARENT_SCOPE)
endfunction()
# Converts the given script module name into it's
# variable name which holds the linkage type.
function(ScriptModuleNameToVariable module variable)
string(TOUPPER ${module} ${variable})
set(${variable} "SCRIPTS_${${variable}}")
set(${variable} ${${variable}} PARENT_SCOPE)
endfunction()
# Stores in the given variable whether dynamic linking is required
function(IsDynamicLinkingRequired variable)
if(SCRIPTS MATCHES "dynamic")
set(IS_DEFAULT_VALUE_DYNAMIC ON)
endif()
GetScriptModuleList(SCRIPT_MODULE_LIST)
set(IS_REQUIRED OFF)
foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
ScriptModuleNameToVariable(${SCRIPT_MODULE} SCRIPT_MODULE_VARIABLE)
if ((${SCRIPT_MODULE_VARIABLE} STREQUAL "dynamic") OR
(${SCRIPT_MODULE_VARIABLE} STREQUAL "default" AND IS_DEFAULT_VALUE_DYNAMIC))
set(IS_REQUIRED ON)
break()
endif()
endforeach()
set(${variable} ${IS_REQUIRED} PARENT_SCOPE)
endfunction()
# Stores the absolut path of the given module in the variable
function(GetPathToScriptModule module variable)
set(${variable} "${CMAKE_SOURCE_DIR}/src/server/scripts/${module}" PARENT_SCOPE)
endfunction()
# Stores the native variable name
function(GetNativeSharedLibraryName module variable)
if(WIN32)
set(${variable} "${module}.dll" PARENT_SCOPE)
else()
set(${variable} "lib${module}.so" PARENT_SCOPE)
endif()
endfunction()
# Stores the native install path in the variable
function(GetInstallOffset variable)
if(WIN32)
set(${variable} "${CMAKE_INSTALL_PREFIX}/scripts" PARENT_SCOPE)
else()
set(${variable} "${CMAKE_INSTALL_PREFIX}/bin/scripts" PARENT_SCOPE)
endif()
endfunction()

View File

@@ -9,11 +9,30 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
option(SERVERS "Build worldserver and bnetserver" 1)
option(SCRIPTS "Build core with scripts included" 1)
set(SCRIPTS "static" CACHE STRING "Build core with scripts")
set_property(CACHE SCRIPTS PROPERTY STRINGS none static dynamic minimal-static minimal-dynamic)
# Build a list of all script modules when -DSCRIPT="custom" is selected
GetScriptModuleList(SCRIPT_MODULE_LIST)
foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
ScriptModuleNameToVariable(${SCRIPT_MODULE} SCRIPT_MODULE_VARIABLE)
set(${SCRIPT_MODULE_VARIABLE} "default" CACHE STRING "Build type of the ${SCRIPT_MODULE} module.")
set_property(CACHE ${SCRIPT_MODULE_VARIABLE} PROPERTY STRINGS default disabled static dynamic)
endforeach()
option(TOOLS "Build map/vmap/mmap extraction/assembler tools" 0)
option(USE_SCRIPTPCH "Use precompiled headers when compiling scripts" 1)
option(USE_COREPCH "Use precompiled headers when compiling servers" 1)
option(WITH_DYNAMIC_LINKING "Enable dynamic library linking." 0)
IsDynamicLinkingRequired(WITH_DYNAMIC_LINKING_FORCED)
if (WITH_DYNAMIC_LINKING AND WITH_DYNAMIC_LINKING_FORCED)
set(WITH_DYNAMIC_LINKING_FORCED OFF)
endif()
if (WITH_DYNAMIC_LINKING OR WITH_DYNAMIC_LINKING_FORCED)
set(BUILD_SHARED_LIBS ON)
else()
set(BUILD_SHARED_LIBS OFF)
endif()
option(WITH_WARNINGS "Show all warnings during compile" 0)
option(WITH_COREDEBUG "Include additional debug-code in core" 0)
set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for IDE's.")

View File

@@ -23,9 +23,8 @@ else()
message("* Build world/bnetserver : No")
endif()
if( SCRIPTS )
message("* Build with scripts : Yes (default)")
add_definitions(-DSCRIPTS)
if(SCRIPTS AND (NOT SCRIPTS STREQUAL "none"))
message("* Build with scripts : Yes (${SCRIPTS})")
else()
message("* Build with scripts : No")
endif()
@@ -70,7 +69,7 @@ else()
endif()
if( NOT WITH_SOURCE_TREE STREQUAL "no" )
message("* Show source tree : Yes - \"${WITH_SOURCE_TREE}\"")
message("* Show source tree : Yes (${WITH_SOURCE_TREE})")
else()
message("* Show source tree : No")
endif()
@@ -87,7 +86,7 @@ if ( WITHOUT_GIT )
message(" *** version of git for the revision-hash to work, and be allowede to ask for")
message(" *** support if needed.")
else()
message("* Use GIT revision hash : Yes")
message("* Use GIT revision hash : Yes (default)")
endif()
if ( NOJEM )
@@ -113,15 +112,16 @@ if ( HELGRIND )
add_definitions(-DHELGRIND)
endif()
if (WITH_DYNAMIC_LINKING)
if (BUILD_SHARED_LIBS)
message("")
message(" *** WITH_DYNAMIC_LINKING - INFO!")
message(" *** Will link against shared libraries!")
message(" *** Please note that this is an experimental feature!")
if (WITH_DYNAMIC_LINKING_FORCED)
message("")
message(" *** Dynamic linking was enforced through a dynamic script module!")
endif()
add_definitions(-DTRINITY_API_USE_DYNAMIC_LINKING)
set(BUILD_SHARED_LIBS ON)
else()
set(BUILD_SHARED_LIBS OFF)
endif()
message("")

View File

@@ -1,4 +1,4 @@
if (WITH_DYNAMIC_LINKING)
if (BUILD_SHARED_LIBS)
set(SRCS
src/efsw/DirectorySnapshot.cpp
src/efsw/DirectorySnapshotDiff.cpp
@@ -81,5 +81,5 @@ if (WITH_DYNAMIC_LINKING)
FOLDER
"dep")
else()
add_library(efsw INTERFACE)
add_library(efsw INTERFACE IMPORTED GLOBAL)
endif()

View File

@@ -8,70 +8,232 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# Enable precompiled headers when using the GCC compiler.
message(STATUS "SCRIPT PREPARATIONS")
macro(PrepareScripts name out)
file(GLOB_RECURSE found
${name}/*.h
${name}/*.cpp
)
list(APPEND ${out} ${found})
message(STATUS " -> Prepared: ${name}")
endmacro(PrepareScripts)
PrepareScripts(Spells PRIVATE_SOURCES)
PrepareScripts(Commands PRIVATE_SOURCES)
if(SCRIPTS)
PrepareScripts(Custom PRIVATE_SOURCES)
PrepareScripts(World PRIVATE_SOURCES)
PrepareScripts(OutdoorPvP PRIVATE_SOURCES)
PrepareScripts(EasternKingdoms PRIVATE_SOURCES)
PrepareScripts(Kalimdor PRIVATE_SOURCES)
PrepareScripts(Outland PRIVATE_SOURCES)
PrepareScripts(Northrend PRIVATE_SOURCES)
PrepareScripts(Maelstrom PRIVATE_SOURCES)
PrepareScripts(Events PRIVATE_SOURCES)
PrepareScripts(Pet PRIVATE_SOURCES)
endif()
message(STATUS "SCRIPT PREPARATION COMPLETE")
message("")
list(APPEND PRIVATE_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/ScriptLoader.h
${CMAKE_CURRENT_SOURCE_DIR}/ScriptLoader.cpp)
# Make the script module list available in the current scope
GetScriptModuleList(SCRIPT_MODULE_LIST)
# Make the native install offset available in this scope
GetInstallOffset(INSTALL_OFFSET)
# Sets the SCRIPTS_${SCRIPT_MODULE} variables
# when using predefined templates for script building
# like dynamic, static, minimal-static...
# Sets SCRIPTS_DEFAULT_LINKAGE
if (SCRIPTS MATCHES "dynamic")
set(SCRIPTS_DEFAULT_LINKAGE "dynamic")
elseif(SCRIPTS MATCHES "static")
set(SCRIPTS_DEFAULT_LINKAGE "static")
else()
set(SCRIPTS_DEFAULT_LINKAGE "disabled")
endif()
# Sets SCRIPTS_USE_WHITELIST
# Sets SCRIPTS_WHITELIST
if (SCRIPTS MATCHES "minimal")
set(SCRIPTS_USE_WHITELIST ON)
# Whitelist which is used when minimal is selected
list(APPEND SCRIPTS_WHITELIST Commands Spells)
endif()
# Set the SCRIPTS_${SCRIPT_MODULE} variables from the
# variables set above
foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
ScriptModuleNameToVariable(${SCRIPT_MODULE} SCRIPT_MODULE_VARIABLE)
if (${SCRIPT_MODULE_VARIABLE} STREQUAL "default")
if(SCRIPTS_USE_WHITELIST)
list(FIND SCRIPTS_WHITELIST "${SCRIPT_MODULE}" INDEX)
if (${INDEX} GREATER -1)
set(${SCRIPT_MODULE_VARIABLE} ${SCRIPTS_DEFAULT_LINKAGE})
else()
set(${SCRIPT_MODULE_VARIABLE} "disabled")
endif()
else()
set(${SCRIPT_MODULE_VARIABLE} ${SCRIPTS_DEFAULT_LINKAGE})
endif()
endif()
# Build the Graph values
if (${SCRIPT_MODULE_VARIABLE} MATCHES "dynamic")
GetProjectNameOfScriptModule(${SCRIPT_MODULE} SCRIPT_MODULE_PROJECT_NAME)
GetNativeSharedLibraryName(${SCRIPT_MODULE_PROJECT_NAME} SCRIPT_PROJECT_LIBRARY)
list(APPEND GRAPH_KEYS ${SCRIPT_MODULE_PROJECT_NAME})
set(GRAPH_VALUE_DISPLAY_${SCRIPT_MODULE_PROJECT_NAME} ${SCRIPT_PROJECT_LIBRARY})
list(APPEND GRAPH_VALUE_CONTAINS_MODULES_${SCRIPT_MODULE_PROJECT_NAME} ${SCRIPT_MODULE})
elseif(${SCRIPT_MODULE_VARIABLE} MATCHES "static")
list(APPEND GRAPH_KEYS worldserver)
set(GRAPH_VALUE_DISPLAY_worldserver worldserver)
list(APPEND GRAPH_VALUE_CONTAINS_MODULES_worldserver ${SCRIPT_MODULE})
else()
list(APPEND GRAPH_KEYS disabled)
set(GRAPH_VALUE_DISPLAY_disabled disabled)
list(APPEND GRAPH_VALUE_CONTAINS_MODULES_disabled ${SCRIPT_MODULE})
endif()
endforeach()
list(SORT GRAPH_KEYS)
list(REMOVE_DUPLICATES GRAPH_KEYS)
# Display the script graph
message("* Script configuration (${SCRIPTS}):
|")
foreach(GRAPH_KEY ${GRAPH_KEYS})
if (NOT GRAPH_KEY STREQUAL "disabled")
message(" +- ${GRAPH_VALUE_DISPLAY_${GRAPH_KEY}}")
else()
message(" | ${GRAPH_VALUE_DISPLAY_${GRAPH_KEY}}")
endif()
foreach(GRAPH_PROJECT_ENTRY ${GRAPH_VALUE_CONTAINS_MODULES_${GRAPH_KEY}})
message(" | +- ${GRAPH_PROJECT_ENTRY}")
endforeach()
message(" |")
endforeach()
# Base sources which are used by every script project
if (USE_SCRIPTPCH)
set(PRIVATE_PCH_HEADER PrecompiledHeaders/ScriptPCH.h)
set(PRIVATE_PCH_SOURCE PrecompiledHeaders/ScriptPCH.cpp)
set(PRIVATE_PCH_HEADER ScriptPCH.h)
set(PRIVATE_PCH_SOURCE ScriptPCH.cpp)
endif ()
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
add_library(scripts STATIC
${PRIVATE_PCH_SOURCE}
${PRIVATE_SOURCES}
)
# Configures the scriptloader with the given name and stores the output in the LOADER_OUT variable.
# It is possible to expose multiple subdirectories from the same scriptloader through passing
# it to the variable arguments
function(ConfigureScriptLoader SCRIPTLOADER_NAME LOADER_OUT IS_DYNAMIC_SCRIPTLOADER)
# Deduces following variables which are referenced by thge template:
# TRINITY_IS_DYNAMIC_SCRIPTLOADER
# TRINITY_SCRIPTS_FORWARD_DECL
# TRINITY_SCRIPTS_INVOKE
# TRINITY_CURRENT_SCRIPT_PROJECT
target_include_directories(scripts
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR})
# To generate export macros
set(TRINITY_IS_DYNAMIC_SCRIPTLOADER ${IS_DYNAMIC_SCRIPTLOADER})
# To generate forward declarations of the loading functions
unset(TRINITY_SCRIPTS_FORWARD_DECL)
unset(TRINITY_SCRIPTS_INVOKE)
# The current script project which is built in
set(TRINITY_CURRENT_SCRIPT_PROJECT ${SCRIPTLOADER_NAME})
foreach(LOCALE_SCRIPT_MODULE ${ARGN})
# Determine the loader function ("Add##${NameOfDirectory}##Scripts()")
set(LOADER_FUNCTION
"Add${LOCALE_SCRIPT_MODULE}Scripts()")
# Generate the funciton call and the forward declarations
set(TRINITY_SCRIPTS_FORWARD_DECL
"${TRINITY_SCRIPTS_FORWARD_DECL}void ${LOADER_FUNCTION};\n")
set(TRINITY_SCRIPTS_INVOKE
"${TRINITY_SCRIPTS_INVOKE} ${LOADER_FUNCTION};\n")
endforeach()
set(GENERATED_LOADER ${CMAKE_CURRENT_BINARY_DIR}/gen_scriptloader/${SCRIPTLOADER_NAME}/ScriptLoader.cpp)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ScriptLoader.cpp.in.cmake ${GENERATED_LOADER})
set(${LOADER_OUT} ${GENERATED_LOADER} PARENT_SCOPE)
endfunction()
# Generates the actual script projects
# Fills the STATIC_SCRIPT_MODULES and DYNAMIC_SCRIPT_MODULE_PROJECTS variables
# which contain the names which scripts are linked statically/dynamically and
# adds the sources of the static modules to the PRIVATE_SOURCES variable.
foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
GetPathToScriptModule(${SCRIPT_MODULE} SCRIPT_MODULE_PATH)
ScriptModuleNameToVariable(${SCRIPT_MODULE} SCRIPT_MODULE_VARIABLE)
if ((${SCRIPT_MODULE_VARIABLE} STREQUAL "disabled") OR
(${SCRIPT_MODULE_VARIABLE} STREQUAL "static"))
# Uninstall disabled modules
GetProjectNameOfScriptModule(${SCRIPT_MODULE} SCRIPT_MODULE_PROJECT_NAME)
GetNativeSharedLibraryName(${SCRIPT_MODULE_PROJECT_NAME} SCRIPT_MODULE_OUTPUT_NAME)
list(APPEND DISABLED_SCRIPT_MODULE_PROJECTS ${INSTALL_OFFSET}/${SCRIPT_MODULE_OUTPUT_NAME})
if (${SCRIPT_MODULE_VARIABLE} STREQUAL "static")
# Add the module name to STATIC_SCRIPT_MODULES
list(APPEND STATIC_SCRIPT_MODULES ${SCRIPT_MODULE})
# Add the module content to the whole static module
CollectSourceFiles(${SCRIPT_MODULE_PATH} PRIVATE_SOURCES)
endif()
elseif(${SCRIPT_MODULE_VARIABLE} STREQUAL "dynamic")
# Generate an own dynamic module which is loadable on runtime
# Add the module content to the whole static module
unset(SCRIPT_MODULE_PRIVATE_SOURCES)
CollectSourceFiles(${SCRIPT_MODULE_PATH} SCRIPT_MODULE_PRIVATE_SOURCES)
# Configure the scriptloader
ConfigureScriptLoader(${SCRIPT_MODULE} SCRIPT_MODULE_PRIVATE_SCRIPTLOADER ON ${SCRIPT_MODULE})
GetProjectNameOfScriptModule(${SCRIPT_MODULE} SCRIPT_MODULE_PROJECT_NAME)
# Add the module name to DYNAMIC_SCRIPT_MODULES
list(APPEND DYNAMIC_SCRIPT_MODULE_PROJECTS ${SCRIPT_MODULE_PROJECT_NAME})
# Create the script module project
add_library(${SCRIPT_MODULE_PROJECT_NAME} SHARED
${PRIVATE_PCH_SOURCE}
${SCRIPT_MODULE_PRIVATE_SOURCES}
${SCRIPT_MODULE_PRIVATE_SCRIPTLOADER})
target_link_libraries(${SCRIPT_MODULE_PROJECT_NAME}
PUBLIC
game)
set_target_properties(${SCRIPT_MODULE_PROJECT_NAME}
PROPERTIES
FOLDER
"scripts")
if(UNIX)
install(TARGETS ${SCRIPT_MODULE_PROJECT_NAME}
DESTINATION ${INSTALL_OFFSET}
COMPONENT ${SCRIPT_MODULE_PROJECT_NAME})
elseif(WIN32)
install(TARGETS ${SCRIPT_MODULE_PROJECT_NAME}
RUNTIME DESTINATION ${INSTALL_OFFSET}
COMPONENT ${SCRIPT_MODULE_PROJECT_NAME})
if(MSVC)
# Place the script modules in the script subdirectory
set_target_properties(${SCRIPT_MODULE_PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin/Debug/scripts
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin/Release/scripts
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/bin/RelWithDebInfo/scripts
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/bin/MinSizeRel/scripts)
endif()
endif()
else()
message(FATAL_ERROR "Unknown value \"${${SCRIPT_MODULE_VARIABLE}}\"!")
endif()
endforeach()
# Add the dynamic script modules to the worldserver as dependency
set(WORLDSERVER_DYNAMIC_SCRIPT_MODULES_DEPENDENCIES ${DYNAMIC_SCRIPT_MODULE_PROJECTS} PARENT_SCOPE)
ConfigureScriptLoader("static" SCRIPT_MODULE_PRIVATE_SCRIPTLOADER OFF ${STATIC_SCRIPT_MODULES})
add_library(scripts STATIC
ScriptLoader.h
${PRIVATE_PCH_SOURCE}
${SCRIPT_MODULE_PRIVATE_SCRIPTLOADER}
${PRIVATE_SOURCES})
target_link_libraries(scripts
PUBLIC
game)
target_include_directories(scripts
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(scripts
PROPERTIES
FOLDER
"server")
PROPERTIES
FOLDER
"scripts")
# Generate precompiled header
if (USE_SCRIPTPCH)
add_cxx_pch(scripts ${PRIVATE_PCH_HEADER} ${PRIVATE_PCH_SOURCE})
list(APPEND ALL_SCRIPT_PROJECTS scripts ${DYNAMIC_SCRIPT_MODULE_PROJECTS})
add_cxx_pch("${ALL_SCRIPT_PROJECTS}" ${PRIVATE_PCH_HEADER} ${PRIVATE_PCH_SOURCE})
endif()
# Remove all shared libraries in the installl directory which
# are contained in the static library already.
if (DISABLED_SCRIPT_MODULE_PROJECTS)
install(CODE "
foreach(SCRIPT_TO_UNINSTALL ${DISABLED_SCRIPT_MODULE_PROJECTS})
if (EXISTS \"\${SCRIPT_TO_UNINSTALL}\")
message(STATUS \"Uninstalling: \${SCRIPT_TO_UNINSTALL}\")
file(REMOVE \"\${SCRIPT_TO_UNINSTALL}\")
endif()
endforeach()
")
endif()
message("")

View File

@@ -1,53 +0,0 @@
/*
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptLoader.h"
#include "World.h"
void AddSpellsScripts();
void AddCommandsScripts();
#ifdef SCRIPTS
void AddWorldScripts();
void AddEasternKingdomsScripts();
void AddKalimdorScripts();
void AddOutlandScripts();
void AddNorthrendScripts();
void AddMaelstromScripts();
void AddEventsScripts();
void AddPetScripts();
void AddOutdoorPvPScripts();
void AddCustomScripts();
#endif
void AddScripts()
{
AddSpellsScripts();
AddCommandsScripts();
#ifdef SCRIPTS
AddWorldScripts();
AddEasternKingdomsScripts();
AddKalimdorScripts();
AddOutlandScripts();
AddNorthrendScripts();
AddMaelstromScripts();
AddEventsScripts();
AddPetScripts();
AddOutdoorPvPScripts();
AddCustomScripts();
#endif
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// This file was created automatically from your script configuration!
// Use CMake to reconfigure this file, never change it on your own!
#cmakedefine TRINITY_IS_DYNAMIC_SCRIPTLOADER
#include "Define.h"
#include <vector>
#include <string>
@TRINITY_SCRIPTS_FORWARD_DECL@
#ifdef TRINITY_IS_DYNAMIC_SCRIPTLOADER
# include "revision_data.h"
# define TC_SCRIPT_API TC_API_EXPORT
extern "C" {
/// Exposed in script modules to return the script module revision hash.
TC_SCRIPT_API char const* GetScriptModuleRevisionHash()
{
return _HASH;
}
/// Exposed in script module to return the name of the script module
/// contained in this shared library.
TC_SCRIPT_API char const* GetScriptModule()
{
return "@TRINITY_CURRENT_SCRIPT_PROJECT@";
}
#else
# include "ScriptLoader.h"
# define TC_SCRIPT_API
#endif
/// Exposed in script modules to register all scripts to the ScriptMgr.
TC_SCRIPT_API void AddScripts()
{
@TRINITY_SCRIPTS_INVOKE@}
/// Exposed in script modules to get the build directive of the module.
TC_SCRIPT_API char const* GetBuildDirective()
{
return _BUILD_DIRECTIVE;
}
#ifdef TRINITY_IS_DYNAMIC_SCRIPTLOADER
} // extern "C"
#endif

View File

@@ -67,6 +67,11 @@ set_target_properties(worldserver
FOLDER
"server")
# Add all dynamic projects as dependency to the worldserver
if (WORLDSERVER_DYNAMIC_SCRIPT_MODULES_DEPENDENCIES)
add_dependencies(worldserver ${WORLDSERVER_DYNAMIC_SCRIPT_MODULES_DEPENDENCIES})
endif()
if( WIN32 )
if ( MSVC )
add_custom_command(TARGET worldserver