From 719159e2074ac2d0902c70bdd3c7a39e0d311bbe Mon Sep 17 00:00:00 2001 From: Naios Date: Sun, 21 Feb 2016 15:52:42 +0100 Subject: Core/Common: Add a generic config helper to access built-in overwriteable paths. * Adds CMAKE_COMMAND and CMAKE_BINARY_DIR to revision_data.h * Move the source and mysql exe path handling out of the DBUpdater. * Make some Config methods const for correctness. * Remove C & CXX flags from revision_data.h (was unused and didn't capture all cxx vars) * Reorder the link order to prevent `ld` from ignoring the file * Ref #15671 --- src/server/bnetserver/CMakeLists.txt | 4 +- src/server/bnetserver/bnetserver.conf.dist | 40 +++++++++---------- src/server/database/Updater/DBUpdater.cpp | 33 +++++----------- src/server/database/Updater/DBUpdater.h | 4 +- src/server/worldserver/CMakeLists.txt | 4 +- src/server/worldserver/worldserver.conf.dist | 59 ++++++++++++++++++---------- 6 files changed, 74 insertions(+), 70 deletions(-) (limited to 'src/server') diff --git a/src/server/bnetserver/CMakeLists.txt b/src/server/bnetserver/CMakeLists.txt index e3f4defd479..6d19b9ca95e 100644 --- a/src/server/bnetserver/CMakeLists.txt +++ b/src/server/bnetserver/CMakeLists.txt @@ -87,10 +87,10 @@ if( NOT WIN32 ) endif() target_link_libraries(bnetserver - common + shared database ipc - shared + common zmqpp format ${MYSQL_LIBRARY} diff --git a/src/server/bnetserver/bnetserver.conf.dist b/src/server/bnetserver/bnetserver.conf.dist index e90cd4634f7..cf5d27699d8 100644 --- a/src/server/bnetserver/bnetserver.conf.dist +++ b/src/server/bnetserver/bnetserver.conf.dist @@ -137,6 +137,26 @@ WrongPass.BanType = 0 WrongPass.Logging = 0 +# +# SourceDirectory +# Description: The path to your TrinityCore source directory. +# If the path is left empty, the built-in CMAKE_SOURCE_DIR is used. +# Example: "../TrinityCore" +# Default: "" + +SourceDirectory = "" + +# +# MySQLExecutable +# Description: The path to your mysql cli binary. +# If the path is left empty, built-in path from cmake is used. +# Example: "C:/Program Files/MySQL/MySQL Server 5.6/bin/mysql.exe" +# "mysql.exe" +# "/usr/bin/mysql" +# Default: "" + +MySQLExecutable = "" + # ################################################################################################### @@ -180,26 +200,6 @@ LoginDatabase.WorkerThreads = 1 Updates.EnableDatabases = 0 -# -# Updates.SourcePath -# Description: The path to your TrinityCore source directory. -# If the path is left empty, built-in CMAKE_SOURCE_DIR is used. -# Example: "../TrinityCore" -# Default: "" - -Updates.SourcePath = "" - -# -# Updates.MySqlCLIPath -# Description: The path to your mysql cli binary. -# If the path is left empty, built-in path from cmake is used. -# Example: "C:/Program Files/MySQL/MySQL Server 5.6/bin/mysql.exe" -# "mysql.exe" -# "/usr/bin/mysql" -# Default: "" - -Updates.MySqlCLIPath = "" - # # Updates.AutoSetup # Description: Auto populate empty databases. diff --git a/src/server/database/Updater/DBUpdater.cpp b/src/server/database/Updater/DBUpdater.cpp index b36ccd37691..ab4b767b104 100644 --- a/src/server/database/Updater/DBUpdater.cpp +++ b/src/server/database/Updater/DBUpdater.cpp @@ -21,6 +21,7 @@ #include "UpdateFetcher.h" #include "DatabaseLoader.h" #include "Config.h" +#include "BuiltInConfig.h" #include #include @@ -35,23 +36,17 @@ using namespace boost::process; using namespace boost::process::initializers; using namespace boost::iostreams; -std::string DBUpdaterUtil::GetMySqlCli() +std::string DBUpdaterUtil::GetCorrectedMySQLExecutable() { if (!corrected_path().empty()) return corrected_path(); else - { - std::string const entry = sConfigMgr->GetStringDefault("Updates.MySqlCLIPath", ""); - if (!entry.empty()) - return entry; - else - return GitRevision::GetMySQLExecutable(); - } + return BuiltInConfig::GetMySQLExecutable(); } bool DBUpdaterUtil::CheckExecutable() { - boost::filesystem::path exe(GetMySqlCli()); + boost::filesystem::path exe(GetCorrectedMySQLExecutable()); if (!exists(exe)) { exe.clear(); @@ -85,16 +80,6 @@ std::string& DBUpdaterUtil::corrected_path() return path; } -template -std::string DBUpdater::GetSourceDirectory() -{ - std::string const entry = sConfigMgr->GetStringDefault("Updates.SourcePath", ""); - if (!entry.empty()) - return entry; - else - return GitRevision::GetSourceDirectory(); -} - // Auth Database template<> std::string DBUpdater::GetConfigEntry() @@ -111,7 +96,8 @@ std::string DBUpdater::GetTableName() template<> std::string DBUpdater::GetBaseFile() { - return DBUpdater::GetSourceDirectory() + "/sql/base/auth_database.sql"; + return BuiltInConfig::GetSourceDirectory() + + "/sql/base/auth_database.sql"; } template<> @@ -169,7 +155,8 @@ std::string DBUpdater::GetTableName() template<> std::string DBUpdater::GetBaseFile() { - return DBUpdater::GetSourceDirectory() + "/sql/base/characters_database.sql"; + return BuiltInConfig::GetSourceDirectory() + + "/sql/base/characters_database.sql"; } template<> @@ -271,7 +258,7 @@ bool DBUpdater::Update(DatabaseWorkerPool& pool) TC_LOG_INFO("sql.updates", "Updating %s database...", DBUpdater::GetTableName().c_str()); - Path const sourceDirectory(GetSourceDirectory()); + Path const sourceDirectory(BuiltInConfig::GetSourceDirectory()); if (!is_directory(sourceDirectory)) { @@ -442,7 +429,7 @@ void DBUpdater::ApplyFile(DatabaseWorkerPool& pool, std::string const& hos boost::process::pipe errPipe = create_pipe(); child c = execute(run_exe( - boost::filesystem::absolute(DBUpdaterUtil::GetMySqlCli()).generic_string()), + boost::filesystem::absolute(DBUpdaterUtil::GetCorrectedMySQLExecutable()).generic_string()), set_args(args), bind_stdin(source), throw_on_error(), bind_stdout(file_descriptor_sink(outPipe.sink, close_handle)), bind_stderr(file_descriptor_sink(errPipe.sink, close_handle))); diff --git a/src/server/database/Updater/DBUpdater.h b/src/server/database/Updater/DBUpdater.h index c9792ffe060..dbb897d2527 100644 --- a/src/server/database/Updater/DBUpdater.h +++ b/src/server/database/Updater/DBUpdater.h @@ -57,7 +57,7 @@ struct UpdateResult class DBUpdaterUtil { public: - static std::string GetMySqlCli(); + static std::string GetCorrectedMySQLExecutable(); static bool CheckExecutable(); @@ -71,8 +71,6 @@ class DBUpdater public: using Path = boost::filesystem::path; - static std::string GetSourceDirectory(); - static inline std::string GetConfigEntry(); static inline std::string GetTableName(); diff --git a/src/server/worldserver/CMakeLists.txt b/src/server/worldserver/CMakeLists.txt index 55d64d8c923..0d1a296e68a 100644 --- a/src/server/worldserver/CMakeLists.txt +++ b/src/server/worldserver/CMakeLists.txt @@ -140,11 +140,11 @@ set_target_properties(worldserver PROPERTIES LINK_FLAGS "${worldserver_LINK_FLAG target_link_libraries(worldserver game - common + scripts shared database - scripts ipc + common g3dlib gsoap Detour diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index f2a594e7482..b6787e25e19 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -175,6 +175,45 @@ BindIP = "0.0.0.0" ThreadPool = 2 +# +# CMakeCommand +# Description: The path to your CMake binary. +# If the path is left empty, the built-in CMAKE_COMMAND is used. +# Example: "C:/Program Files (x86)/CMake/bin/cmake.exe" +# "/usr/bin/cmake" +# Default: "" + +CMakeCommand = "" + +# +# BuildDirectory +# Description: The path to your build directory. +# If the path is left empty, the built-in CMAKE_BINARY_DIR is used. +# Example: "../TrinityCore" +# Default: "" + +BuildDirectory = "" + +# +# SourceDirectory +# Description: The path to your TrinityCore source directory. +# If the path is left empty, the built-in CMAKE_SOURCE_DIR is used. +# Example: "../TrinityCore" +# Default: "" + +SourceDirectory = "" + +# +# MySQLExecutable +# Description: The path to your mysql cli binary. +# If the path is left empty, built-in path from cmake is used. +# Example: "C:/Program Files/MySQL/MySQL Server 5.6/bin/mysql.exe" +# "mysql.exe" +# "/usr/bin/mysql" +# Default: "" + +MySQLExecutable = "" + # ################################################################################################### @@ -1148,26 +1187,6 @@ FeatureSystem.CharacterUndelete.Cooldown = 2592000 Updates.EnableDatabases = 15 -# -# Updates.SourcePath -# Description: The path to your TrinityCore source directory. -# If the path is left empty, built-in CMAKE_SOURCE_DIR is used. -# Example: "../TrinityCore" -# Default: "" - -Updates.SourcePath = "" - -# -# Updates.MySqlCLIPath -# Description: The path to your mysql cli binary. -# If the path is left empty, built-in path from cmake is used. -# Example: "C:/Program Files/MySQL/MySQL Server 5.6/bin/mysql.exe" -# "mysql.exe" -# "/usr/bin/mysql" -# Default: "" - -Updates.MySqlCLIPath = "" - # # Updates.AutoSetup # Description: Auto populate empty databases. -- cgit v1.2.3