Core/Misc: CompilerDefs/GitRevision improvements

* Removed INTEL as a separate platform (it does not belong there)
* Removed BORLAND from known compilers list (it was never supported)
* Simplified TRINITY_PLATFORM_WINDOWS detection (_WIN32 is always defined)
* Rename revision_data.h macros that begin with a underscore
* Added processor architecture to --version string
* Added Linux distribution name to .server debug
* Fixed some revision_data.h macros missing/wrong values when regenerated during compilation
* Removed manual adding of _WIN64 macro from cmake (it is predefined internally by compiler)
This commit is contained in:
Shauren
2024-09-03 12:06:16 +02:00
parent c722ff3a68
commit e8740fb2e1
6 changed files with 100 additions and 80 deletions

View File

@@ -28,17 +28,7 @@ target_compile_options(trinity-compile-option-interface
INTERFACE
/permissive-)
if(PLATFORM EQUAL 64)
# This definition is necessary to work around a bug with Intellisense described
# here: http://tinyurl.com/2cb428. Syntax highlighting is important for proper
# debugger functionality.
target_compile_definitions(trinity-compile-option-interface
INTERFACE
_WIN64)
message(STATUS "MSVC: 64-bit platform, enforced -D_WIN64 parameter")
else()
if(PLATFORM EQUAL 32)
# mark 32 bit executables large address aware so they can use > 2GB address space
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
message(STATUS "MSVC: Enabled large address awareness")

View File

@@ -12,7 +12,7 @@
# This is done EACH compile so they can be alerted about the consequences.
if(NOT BUILDDIR)
# Workaround for funny MSVC behaviour - this segment is only used when using cmake gui
# Workaround for cmake script mode
set(BUILDDIR ${CMAKE_BINARY_DIR})
endif()
@@ -122,12 +122,28 @@ 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}" STREQUAL "${rev_hash}" OR NOT "${rev_branch_cached}" STREQUAL "${rev_branch}" OR NOT EXISTS "${BUILDDIR}/revision_data.h")
configure_file(
"${CMAKE_SOURCE_DIR}/revision_data.h.in.cmake"
"${BUILDDIR}/revision_data.h"
@ONLY
cmake_host_system_information(RESULT TRINITY_BUILD_HOST_SYSTEM QUERY OS_NAME)
cmake_host_system_information(RESULT TRINITY_BUILD_HOST_DISTRO QUERY DISTRIB_INFO)
cmake_host_system_information(RESULT TRINITY_BUILD_HOST_SYSTEM_RELEASE QUERY OS_RELEASE)
# on windows OS_RELEASE contains sub-type string tag like "Professional" instead of a version number and OS_VERSION has only build number
# so we grab that from cmd "ver" command
if(WIN32)
execute_process(
COMMAND cmd /c ver
OUTPUT_VARIABLE TRINITY_BUILD_HOST_SYSTEM_RELEASE
)
set(rev_hash_cached "${rev_hash}" CACHE INTERNAL "Cached commit-hash")
set(rev_branch_cached "${rev_branch}" CACHE INTERNAL "Cached branch name")
string(STRIP ${TRINITY_BUILD_HOST_SYSTEM_RELEASE} TRINITY_BUILD_HOST_SYSTEM_RELEASE)
string(REGEX MATCH "[0-9]+[.][0-9]+[.][0-9]+" TRINITY_BUILD_HOST_SYSTEM_RELEASE ${TRINITY_BUILD_HOST_SYSTEM_RELEASE})
endif()
if(CMAKE_SCRIPT_MODE_FILE)
# hack for CMAKE_SYSTEM_PROCESSOR missing in script mode
set(CMAKE_PLATFORM_INFO_DIR ${BUILDDIR}${CMAKE_FILES_DIRECTORY})
include(${CMAKE_ROOT}/Modules/CMakeDetermineSystem.cmake)
endif()
configure_file(
"${CMAKE_SOURCE_DIR}/revision_data.h.in.cmake"
"${BUILDDIR}/revision_data.h"
@ONLY
)

View File

@@ -1,20 +1,54 @@
#ifndef __REVISION_DATA_H__
#define __REVISION_DATA_H__
#define _HASH "@rev_hash@"
#define _DATE "@rev_date@"
#define _BRANCH "@rev_branch@"
#define _CMAKE_COMMAND R"(@CMAKE_COMMAND@)"
#define _CMAKE_VERSION R"(@CMAKE_VERSION@)"
#define _CMAKE_HOST_SYSTEM R"(@CMAKE_HOST_SYSTEM_NAME@ @CMAKE_HOST_SYSTEM_VERSION@)"
#define _SOURCE_DIRECTORY R"(@CMAKE_SOURCE_DIR@)"
#define _BUILD_DIRECTORY R"(@BUILDDIR@)"
#define _MYSQL_EXECUTABLE R"(@MYSQL_EXECUTABLE@)"
#define _FULL_DATABASE "TDB_full_world_1102.24091_2024_09_03.sql"
#define _HOTFIXES_DATABASE "TDB_full_hotfixes_1102.24091_2024_09_03.sql"
#define VER_COMPANYNAME_STR "TrinityCore Developers"
#define VER_LEGALCOPYRIGHT_STR "(c)2008-@rev_year@ TrinityCore"
#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 // __REVISION_DATA_H__
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* 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/>.
*/
#ifndef TRINITYCORE_REVISION_DATA_H
#define TRINITYCORE_REVISION_DATA_H
// Git commit information
#define TRINITY_GIT_COMMIT_HASH "@rev_hash@"
#define TRINITY_GIT_COMMIT_DATE "@rev_date@"
#define TRINITY_GIT_COMMIT_BRANCH R"(@rev_branch@)"
// Build OS information
#define TRINITY_BUILD_HOST_SYSTEM R"(@TRINITY_BUILD_HOST_SYSTEM@)"
#define TRINITY_BUILD_HOST_SYSTEM_VERSION R"(@TRINITY_BUILD_HOST_SYSTEM_RELEASE@)"
#cmakedefine TRINITY_BUILD_HOST_DISTRO_NAME R"(@TRINITY_BUILD_HOST_DISTRO_NAME@)"
#cmakedefine TRINITY_BUILD_HOST_DISTRO_VERSION_ID R"(@TRINITY_BUILD_HOST_DISTRO_VERSION_ID@)"
// Build target information
#define TRINITY_BUILD_PROCESSOR R"(@CMAKE_SYSTEM_PROCESSOR@)"
// CMake build information
#define TRINITY_BUILD_CMAKE_COMMAND R"(@CMAKE_COMMAND@)"
#define TRINITY_BUILD_CMAKE_VERSION R"(@CMAKE_VERSION@)"
#define TRINITY_BUILD_CMAKE_SOURCE_DIRECTORY R"(@CMAKE_SOURCE_DIR@)"
#define TRINITY_BUILD_CMAKE_BUILD_DIRECTORY R"(@BUILDDIR@)"
// Database updater base information
#define DATABASE_MYSQL_EXECUTABLE R"(@MYSQL_EXECUTABLE@)"
#define DATABASE_FULL_DATABASE "TDB_full_world_1102.24091_2024_09_03.sql"
#define DATABASE_HOTFIXES_DATABASE "TDB_full_hotfixes_1102.24091_2024_09_03.sql"
// Windows resource defines
#define VER_COMPANYNAME_STR "TrinityCore Developers"
#define VER_LEGALCOPYRIGHT_STR "(c)2008-@rev_year@ TrinityCore"
#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 // TRINITYCORE_REVISION_DATA_H

View File

@@ -21,30 +21,21 @@
#define TRINITY_PLATFORM_WINDOWS 0
#define TRINITY_PLATFORM_UNIX 1
#define TRINITY_PLATFORM_APPLE 2
#define TRINITY_PLATFORM_INTEL 3
// must be first (win 64 also define _WIN32)
#if defined( _WIN64 )
#if defined( _WIN32 )
# define TRINITY_PLATFORM TRINITY_PLATFORM_WINDOWS
#elif defined( __WIN32__ ) || defined( WIN32 ) || defined( _WIN32 )
# define TRINITY_PLATFORM TRINITY_PLATFORM_WINDOWS
#elif defined( __APPLE_CC__ )
#elif defined( __APPLE__ )
# define TRINITY_PLATFORM TRINITY_PLATFORM_APPLE
#elif defined( __INTEL_COMPILER )
# define TRINITY_PLATFORM TRINITY_PLATFORM_INTEL
#else
# define TRINITY_PLATFORM TRINITY_PLATFORM_UNIX
#endif
#define TRINITY_COMPILER_MICROSOFT 0
#define TRINITY_COMPILER_GNU 1
#define TRINITY_COMPILER_BORLAND 2
#define TRINITY_COMPILER_INTEL 3
#define TRINITY_COMPILER_INTEL 2
#ifdef _MSC_VER
# define TRINITY_COMPILER TRINITY_COMPILER_MICROSOFT
#elif defined( __BORLANDC__ )
# define TRINITY_COMPILER TRINITY_COMPILER_BORLAND
#elif defined( __INTEL_COMPILER )
# define TRINITY_COMPILER TRINITY_COMPILER_INTEL
#elif defined( __GNUC__ )

View File

@@ -20,73 +20,64 @@
char const* GitRevision::GetHash()
{
return _HASH;
return TRINITY_GIT_COMMIT_HASH;
}
char const* GitRevision::GetDate()
{
return _DATE;
return TRINITY_GIT_COMMIT_DATE;
}
char const* GitRevision::GetBranch()
{
return _BRANCH;
return TRINITY_GIT_COMMIT_BRANCH;
}
char const* GitRevision::GetCMakeCommand()
{
return _CMAKE_COMMAND;
return TRINITY_BUILD_CMAKE_COMMAND;
}
char const* GitRevision::GetCMakeVersion()
{
return _CMAKE_VERSION;
return TRINITY_BUILD_CMAKE_VERSION;
}
char const* GitRevision::GetHostOSVersion()
{
return _CMAKE_HOST_SYSTEM;
return
#ifdef TRINITY_BUILD_HOST_DISTRO_NAME
TRINITY_BUILD_HOST_DISTRO_NAME " " TRINITY_BUILD_HOST_DISTRO_VERSION_ID "; "
#endif
TRINITY_BUILD_HOST_SYSTEM " " TRINITY_BUILD_HOST_SYSTEM_VERSION
;
}
char const* GitRevision::GetBuildDirectory()
{
return _BUILD_DIRECTORY;
return TRINITY_BUILD_CMAKE_BUILD_DIRECTORY;
}
char const* GitRevision::GetSourceDirectory()
{
return _SOURCE_DIRECTORY;
return TRINITY_BUILD_CMAKE_SOURCE_DIRECTORY;
}
char const* GitRevision::GetMySQLExecutable()
{
return _MYSQL_EXECUTABLE;
return DATABASE_MYSQL_EXECUTABLE;
}
char const* GitRevision::GetFullDatabase()
{
return _FULL_DATABASE;
return DATABASE_FULL_DATABASE;
}
char const* GitRevision::GetHotfixesDatabase()
{
return _HOTFIXES_DATABASE;
return DATABASE_HOTFIXES_DATABASE;
}
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
# ifdef _WIN64
# define TRINITY_PLATFORM_STR "Win64"
# else
# define TRINITY_PLATFORM_STR "Win32"
# endif
#elif TRINITY_PLATFORM == TRINITY_PLATFORM_APPLE
# define TRINITY_PLATFORM_STR "MacOSX"
#elif TRINITY_PLATFORM == TRINITY_PLATFORM_INTEL
# define TRINITY_PLATFORM_STR "Intel"
#else // TRINITY_PLATFORM_UNIX
# define TRINITY_PLATFORM_STR "Unix"
#endif
#ifndef TRINITY_API_USE_DYNAMIC_LINKING
# define TRINITY_LINKAGE_TYPE_STR "Static"
#else
@@ -96,7 +87,7 @@ char const* GitRevision::GetHotfixesDatabase()
char const* GitRevision::GetFullVersion()
{
return "TrinityCore rev. " VER_PRODUCTVERSION_STR
" (" TRINITY_PLATFORM_STR ", " _BUILD_DIRECTIVE ", " TRINITY_LINKAGE_TYPE_STR ")";
" (" TRINITY_BUILD_HOST_SYSTEM ", " TRINITY_BUILD_PROCESSOR ", " _BUILD_DIRECTIVE ", " TRINITY_LINKAGE_TYPE_STR ")";
}
char const* GitRevision::GetCompanyNameStr()

View File

@@ -21,8 +21,6 @@
#cmakedefine TRINITY_IS_DYNAMIC_SCRIPTLOADER
#include "Define.h"
#include <vector>
#include <string>
@TRINITY_SCRIPTS_FORWARD_DECL@
#ifdef TRINITY_IS_DYNAMIC_SCRIPTLOADER
@@ -33,7 +31,7 @@ extern "C" {
/// Exposed in script modules to return the script module revision hash.
TC_SCRIPT_API char const* GetScriptModuleRevisionHash()
{
return _HASH;
return TRINITY_GIT_COMMIT_HASH;
}
/// Exposed in script module to return the name of the script module