Improve Revision System (mangosthree/server#52)

Improve issue and bug reporting with Git Hash tracking
This commit is contained in:
Meltie2013 2022-06-24 23:09:35 +01:00 committed by billy1arm
parent 15d38649fa
commit 07fc102376
No known key found for this signature in database
GPG Key ID: 0DF907270598C85F
14 changed files with 333 additions and 38 deletions

4
.gitignore vendored
View File

@ -120,5 +120,9 @@ msbuild.cmd
/src/tools/Extractor_Binaries/*.exe
# Skip Git Revision created file
/src/shared/revision_data.h
# File generated during compile
/dep/libmpq/compile

View File

@ -98,6 +98,10 @@ else()
endif()
endif()
if(NOT WITHOUT_GIT)
find_package(Git)
endif()
find_package(Threads REQUIRED)
find_package(MySQL REQUIRED)
find_package(DL REQUIRED)
@ -107,6 +111,7 @@ find_package(BZip2 QUIET)
find_package(OpenSSL REQUIRED)
include(${CMAKE_SOURCE_DIR}/cmake/GenRevision.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/EnsureVersion.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/MangosParams.cmake)

81
cmake/GenRevision.cmake Normal file
View File

@ -0,0 +1,81 @@
if(NOT BUILDDIR)
# Workaround for funny MSVC behaviour - this segment is only used when using cmake gui
set(BUILDDIR ${CMAKE_BINARY_DIR})
endif()
if(WITHOUT_GIT)
set(rev_date "1970-01-01 00:00:00 +0000")
set(rev_hash "unknown")
set(rev_branch "Archived")
# No valid git commit date, use compiled date
string(TIMESTAMP rev_date_fallback "%Y-%m-%d %H:%M:%S" UTC)
else()
if(GIT_EXECUTABLE)
# Create a revision-string that we can use
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe --long --match init --dirty=+ --abbrev=12 --always
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE rev_info
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
# And grab the commits timestamp
execute_process(
COMMAND "${GIT_EXECUTABLE}" show -s --format=%ci
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE rev_date
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
# Also retrieve branch name
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE rev_branch
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
endif()
# Last minute check - ensure that we have a proper revision
# If everything above fails (means the user has erased the git revision control directory or removed the origin/HEAD tag)
if(NOT rev_info)
# No valid ways available to find/set the revision/hash, so let's force some defaults
message(STATUS "
Could not find a proper repository signature (hash) - you may need to pull tags with git fetch -t
Continuing anyway - note that the versionstring will be set to \"unknown 1970-01-01 00:00:00 (Archived)\"")
set(rev_date "1970-01-01 00:00:00 +0000")
set(rev_hash "unknown")
set(rev_branch "Archived")
# No valid git commit date, use compiled date
string(TIMESTAMP rev_date_fallback "%Y-%m-%d %H:%M:%S" UTC)
else()
# We have valid date from git commit, use it
set(rev_date_fallback ${rev_date})
# Extract information required to build a proper versionstring
string(REGEX REPLACE init-|[0-9]+-g "" rev_hash ${rev_info})
endif()
endif()
# For package / copyright information we always need proper date
string(REGEX MATCH "([0-9]+)-([0-9]+)-([0-9]+)" rev_date_fallback_match ${rev_date_fallback})
set(rev_year ${CMAKE_MATCH_1})
set(rev_month ${CMAKE_MATCH_2})
set(rev_day ${CMAKE_MATCH_3})
# Create the actual revision_data.h file from the above params
if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}" OR NOT "${rev_branch_cached}" MATCHES "${rev_branch}" OR NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/src/shared/revision_data.h")
configure_file(
"${CMAKE_SOURCE_DIR}/src/shared/revision_data.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/src/shared/revision_data.h"
@ONLY
)
set(rev_hash_cached "${rev_hash}" CACHE INTERNAL "Cached commit-hash")
set(rev_branch_cached "${rev_branch}" CACHE INTERNAL "Cached branch name")
endif()

View File

@ -1,8 +1,15 @@
message("===================================================")
message("Mangos revision : ${rev_hash} ${rev_date} (${rev_branch} branch)")
message("Build type : ${CMAKE_BUILD_TYPE}")
message("Install server(s) to : ${BIN_DIR}")
message("Install configs to : ${CONF_INSTALL_DIR}")
message("")
message("Detailed Information")
message("+-- opeating system : ${CMAKE_HOST_SYSTEM}")
message("+-- cmake version : ${CMAKE_VERSION}")
message("")
if(BUILD_MANGOSD)
message("Build main server : Yes (default)")
if(SCRIPT_LIB_ELUNA)

View File

@ -17,21 +17,31 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Build the mangos shared library
add_subdirectory(shared)
add_subdirectory(genrev)
# Needs to link against mangos_world.lib
if(BUILD_MANGOSD OR BUILD_TOOLS)
# Build the mangos game library
add_subdirectory(game)
endif()
if(BUILD_MANGOSD)
# Build the mangos world server
add_subdirectory(mangosd)
# Build the selected modules
add_subdirectory(modules)
endif()
# Build the mangos realm authentication server
if(BUILD_REALMD)
add_subdirectory(realmd)
endif()
# If we want the tools for map/vmap/mmap extraction
if(BUILD_TOOLS)
add_subdirectory(tools)
endif()

View File

@ -26,9 +26,11 @@
#include "Language.h"
#include "World.h"
#include "Config.h"
#include "GitRevision.h"
#include "SystemConfig.h"
#include "UpdateTime.h"
#include "revision.h"
#include "revision_data.h"
/**********************************************************************
CommandTable : serverCommandTable
@ -65,6 +67,9 @@ bool ChatHandler::HandleServerInfoCommand(char* /*args*/)
SendSysMessage(LANG_USING_SCRIPT_LIB_NONE);
}
PSendSysMessage("%s", GitRevision::GetFullRevision());
PSendSysMessage("%s", GitRevision::GetRunningSystem());
PSendSysMessage(LANG_USING_WORLD_DB, sWorld.GetDBVersion());
PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
PSendSysMessage(LANG_UPTIME, str.c_str());

23
src/genrev/CMakeLists.txt Normal file
View File

@ -0,0 +1,23 @@
# MaNGOS is a full featured server for World of Warcraft, supporting
# the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
#
# Copyright (C) 2005-2022 MaNGOS <https://getmangos.eu>
#
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
add_custom_target(revision_data.h ALL
COMMAND "${CMAKE_COMMAND}" -DBUILDDIR="${CMAKE_BINARY_DIR}" -P "${CMAKE_SOURCE_DIR}/cmake/GenRevision.cmake" "${CMAKE_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)

View File

@ -34,11 +34,13 @@
#include "Common.h"
#include "Database/DatabaseEnv.h"
#include "Config/Config.h"
#include "GitRevision.h"
#include "ProgressBar.h"
#include "Log.h"
#include "SystemConfig.h"
#include "AuctionHouseBot.h"
#include "revision.h"
#include "revision_data.h"
#include "World.h"
#include "Util.h"
#include "DBCStores.h"
@ -385,10 +387,11 @@ int main(int argc, char** argv)
#endif
sLog.outString("%s [world-daemon]", REVISION_NR);
sLog.outString("%s", GitRevision::GetFullRevision());
print_banner();
sLog.outString("Using configuration file %s.", cfg_file);
DETAIL_LOG("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
DETAIL_LOG("Using SSL version: %s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
if (SSLeay() < 0x009080bfL)
{
DETAIL_LOG("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!");

@ -1 +1 @@
Subproject commit 1f668a7a2cc7bb730ba51a2341ce345f19617168
Subproject commit 7d70f55a347aec7ccd2010dcf9e715560e95fad3

View File

@ -40,6 +40,8 @@ set(SRC_GRP_COMMON
Common/Common.cpp
Common/Common.h
Common/ServerDefines.h
Common/GitRevision.cpp
Common/GitRevision.h
)
source_group("Common" FILES ${SRC_GRP_COMMON})
@ -186,6 +188,7 @@ set(TGT_INCL
Policies
)
configure_file(revision_data.h.in ${CMAKE_CURRENT_BINARY_DIR}/revision_data.h)
configure_file(SystemConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/SystemConfig.h)
TEST_BIG_ENDIAN(ENDIAN_VALUE)
@ -206,6 +209,7 @@ add_library(shared STATIC
${SRC_GRP_SVC}
${SRC_GRP_UTILITIES}
revision.h
${CMAKE_CURRENT_BINARY_DIR/revision_data.h}
${CMAKE_CURRENT_BINARY_DIR/SystemConfig.h}
)

View File

@ -0,0 +1,97 @@
/**
* MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
*
* Copyright (C) 2005-2022 MaNGOS <https://getmangos.eu>
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#include "GitRevision.h"
char const* GitRevision::GetHash()
{
return REVISION_HASH;
}
char const* GitRevision::GetDate()
{
return REVISION_DATE;
}
char const* GitRevision::GetBranch()
{
return REVISION_BRANCH;
}
char const* GitRevision::GetCMakeVersion()
{
return CMAKE_VERSION;
}
char const* GitRevision::GetHostOSVersion()
{
return "Compiled on: " CMAKE_HOST_SYSTEM;
}
// Platform Define
#if PLATFORM == PLATFORM_WINDOWS
#ifdef _WIN64
#define MANGOS_PLATFORM_STR "Win64"
#else
#define MANGOS_PLATFORM_STR "Win32"
#endif
#elif PLATFORM == PLATFORM_APPLE
#define MANGOS_PLATFORM_STR "MacOSX"
#elif PLATFORM == PLATFORM_INTEL
#define MANGOS_PLATFORM_STR "Intel"
#elif PLATFORM == PLATFORM_UNIX
#define MANGOS_PLATFORM_STR "Linux"
#else
#define MANGOS_PLATFORM_STR "Unknown System"
#endif
char const* GitRevision::GetFullRevision()
{
return "Mangos revision: " VER_PRODUCTVERSION_STR;
}
char const* GitRevision::GetRunningSystem()
{
return "Running on: " CMAKE_HOST_SYSTEM;
}
char const* GitRevision::GetCompanyNameStr()
{
return VER_COMPANY_NAME_STR;
}
char const* GitRevision::GetLegalCopyrightStr()
{
return VER_LEGALCOPYRIGHT_STR;
}
char const* GitRevision::GetFileVersionStr()
{
return VER_FILEVERSION_STR;
}
char const* GitRevision::GetProductVersionStr()
{
return VER_PRODUCTVERSION_STR;
}

View File

@ -0,0 +1,52 @@
/**
* MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
*
* Copyright (C) 2005-2022 MaNGOS <https://getmangos.eu>
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef GITREVISION_H
#define GITREVISION_H
#include "Define.h"
#include "revision_data.h"
namespace GitRevision
{
// github data
char const* GetHash();
char const* GetDate();
char const* GetBranch();
// system data
char const* GetCMakeVersion();
char const* GetHostOSVersion();
char const* GetRunningSystem();
// application data
char const* GetFullRevision();
char const* GetCompanyNameStr();
char const* GetLegalCopyrightStr();
char const* GetFileVersionStr();
char const* GetProductVersionStr();
}
#endif

View File

@ -55,41 +55,6 @@
# define MANGOS_ENDIAN_STRING "little-endian"
#endif
#if defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86)
# define ARCHITECTURE "x86"
#elif defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(_M_X64)
# define ARCHITECTURE "x64"
#elif defined(__ia64) || defined(__IA64__) || defined(_M_IA64)
# define ARCHITECTURE "IA64"
#else
# define ARCHITECTURE "x86"
#endif
#if PLATFORM == PLATFORM_WINDOWS
# ifdef _WIN64
# define MANGOS_ENDIAN_PLATFORM "Win64 (" MANGOS_ENDIAN_STRING ")"
# else
# define MANGOS_ENDIAN_PLATFORM "Win32 (" MANGOS_ENDIAN_STRING ")"
# endif
#else
# if defined (__FreeBSD__)
# define MANGOS_ENDIAN_PLATFORM "FreeBSD_" ARCHITECTURE " (" MANGOS_ENDIAN_STRING ")"
# elif defined(__NetBSD__)
# define MANGOS_ENDIAN_PLATFORM "NetBSD_" ARCHITECTURE " (" MANGOS_ENDIAN_STRING ")"
# elif defined(__OpenBSD__)
# define MANGOS_ENDIAN_PLATFORM "OpenBSD_" ARCHITECTURE " (" MANGOS_ENDIAN_STRING ")"
# elif defined(__DragonFly__)
# define MANGOS_ENDIAN_PLATFORM "DragonFlyBSD_" ARCHITECTURE " (" MANGOS_ENDIAN_STRING ")"
# elif defined(__APPLE__)
# define MANGOS_ENDIAN_PLATFORM "MacOSX_" ARCHITECTURE " (" MANGOS_ENDIAN_STRING ")"
# elif defined(__linux) || defined(__linux__)
# define MANGOS_ENDIAN_PLATFORM "Linux_" ARCHITECTURE " (" MANGOS_ENDIAN_STRING ")"
# else
# define MANGOS_ENDIAN_PLATFORM "Unix_" ARCHITECTURE " (" MANGOS_ENDIAN_STRING ")"
# endif
#endif
#define SYSCONFDIR "@CONF_INSTALL_DIR@/"
@ -101,7 +66,6 @@
#define REALMD_CONFIG_LOCATION SYSCONFDIR REALMD_CONFIG_NAME
#define AUCTIONHOUSEBOT_CONFIG_LOCATION SYSCONFDIR AUCTIONHOUSEBOT_CONFIG_NAME
#define MANGOS_FULLVERSION(REVD,REVT,REVN,REVH) MANGOS_PACKAGENAME "/" MANGOS_VERSION(REVD,REVT,REVN,REVH) " for " MANGOS_ENDIAN_PLATFORM
#define DEFAULT_PLAYER_LIMIT 100
#define DEFAULT_WORLDSERVER_PORT 8085 //8129

View File

@ -0,0 +1,40 @@
/**
* MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
*
* Copyright (C) 2005-2022 MaNGOS <https://getmangos.eu>
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef REVISION_DATA_H
#define REVISION_DATA_H
#define REVISION_HASH "@rev_hash@"
#define REVISION_DATE "@rev_date@"
#define REVISION_BRANCH "@rev_branch@"
#define CMAKE_VERSION R"(@CMAKE_VERSION@)"
#define CMAKE_HOST_SYSTEM R"(@CMAKE_HOST_SYSTEM_NAME@ @CMAKE_HOST_SYSTEM_VERSION@)"
#define VER_COMPANY_NAME_STR "MaNGOS Developers"
#define VER_LEGALCOPYRIGHT_STR "(c)2005-@rev_year@ MaNGOS"
#define VER_FILEVERSION 0,0,0
#define VER_FILEVERSION_STR "@rev_hash@ @rev_date@ (@rev_branch@ branch)"
#define VER_PRODUCTVERSION VER_FILEVERSION
#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR
#endif