Skip to content

Commit a86ed98

Browse files
authored
[GEN][ZH] Generate git version information and print it in the Game Window title, Options Menu (and Main Menu) (#1219)
1 parent 8bd0bcf commit a86ed98

File tree

19 files changed

+1186
-227
lines changed

19 files changed

+1186
-227
lines changed

Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ target_include_directories(corei_libraries_source_wwvegas_wwlib INTERFACE "Libra
1212
target_link_libraries(corei_always INTERFACE
1313
core_utility
1414
corei_libraries_include
15+
resources
1516
)
1617

1718
# Set where the build results will end up

Generals/Code/GameEngine/Include/Common/version.h

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,69 @@
3131
#ifndef __VERSION_H__
3232
#define __VERSION_H__
3333

34+
#include <time.h>
35+
3436
/**
3537
* The Version class formats the version number into integer and string
3638
* values for different parts of the game.
3739
* @todo: increment build number on compile, and stamp exe with username
3840
*/
41+
// TheSuperHackers @tweak The Version class now also provides Git information
42+
// alongside the original Version information.
3943
class Version
4044
{
4145
public:
4246
Version();
43-
UnsignedInt getVersionNumber( void ); ///< Return a 4-byte integer suitable for WOLAPI
44-
AsciiString getAsciiVersion( void ); ///< Return a human-readable version number
45-
UnicodeString getUnicodeVersion( void ); ///< Return a human-readable version number
46-
UnicodeString getFullUnicodeVersion( void ); ///< Return a human-readable version number
47-
AsciiString getAsciiBuildTime( void ); ///< Return a formated date/time string for build time
48-
UnicodeString getUnicodeBuildTime( void ); ///< Return a formated date/time string for build time
49-
AsciiString getAsciiBuildLocation( void ); ///< Return a string with the build location
50-
UnicodeString getUnicodeBuildLocation( void ); ///< Return a string with the build location
51-
AsciiString getAsciiBuildUser( void ); ///< Return a string with the build user
52-
UnicodeString getUnicodeBuildUser( void ); ///< Return a string with the build user
53-
54-
Bool showFullVersion( void ) { return m_showFullVersion; }
47+
48+
UnsignedInt getVersionNumber() const; ///< Return a 4-byte integer suitable for WOLAPI
49+
50+
AsciiString getAsciiVersion() const; ///< Return a human-readable version number
51+
UnicodeString getUnicodeVersion() const; ///< Return a human-readable version number. Is decorated with localized string
52+
53+
AsciiString getAsciiBuildTime() const; ///< Return a formated date/time string for build time
54+
UnicodeString getUnicodeBuildTime() const; ///< Return a formated date/time string for build time. Is decorated with localized string
55+
56+
AsciiString getAsciiBuildLocation() const; ///< Return a string with the build location
57+
UnicodeString getUnicodeBuildLocation() const; ///< Return a string with the build location. Is decorated with localized string
58+
59+
AsciiString getAsciiBuildUser() const; ///< Return a string with the build user
60+
UnicodeString getUnicodeBuildUser() const; ///< Return a string with the build user. Is decorated with localized string
61+
62+
static Int getGitCommitCount(); ///< Returns the git commit count as a number
63+
static time_t getGitCommitTime(); ///< Returns the git head commit time as a UTC timestamp
64+
static const char* getGitCommitAuthorName(); ///< Returns the git head commit author name
65+
66+
AsciiString getAsciiGitCommitCount() const; ///< Returns the git commit count. Is prefixed with ~ if there were uncommitted changes.
67+
UnicodeString getUnicodeGitCommitCount() const; ///< Returns the git commit count. Is prefixed with ~ if there were uncommitted changes.
68+
69+
AsciiString getAsciiGitTagOrHash() const; ///< Returns the git head commit tag or hash. Is prefixed with ~ if there were uncommitted changes.
70+
UnicodeString getUnicodeGitTagOrHash() const; ///< Returns the git head commit tag or hash. Is prefixed with ~ if there were uncommitted changes.
71+
72+
AsciiString getAsciiGitCommitTime() const; ///< Returns the git head commit time in YYYY-mm-dd HH:MM:SS format
73+
UnicodeString getUnicodeGitCommitTime() const; ///< Returns the git head commit time in YYYY-mm-dd HH:MM:SS format
74+
75+
AsciiString getAsciiGameAndGitVersion() const; ///< Returns the game and git version
76+
UnicodeString getUnicodeGameAndGitVersion() const; ///< Returns the game and git version. Is decorated with localized string
77+
78+
AsciiString getAsciiBuildUserOrGitCommitAuthorName() const;
79+
UnicodeString getUnicodeBuildUserOrGitCommitAuthorName() const; ///< Is decorated with localized string
80+
81+
Bool showFullVersion() const { return m_showFullVersion; }
5582
void setShowFullVersion( Bool val ) { m_showFullVersion = val; }
5683

5784
void setVersion(Int major, Int minor, Int buildNum,
5885
Int localBuildNum, AsciiString user, AsciiString location,
59-
AsciiString buildTime, AsciiString buildDate); ///< Set version info
86+
AsciiString buildTime, AsciiString buildDate);
87+
88+
private:
89+
static AsciiString buildAsciiGitCommitCount();
90+
static UnicodeString buildUnicodeGitCommitCount();
91+
92+
static AsciiString buildAsciiGitTagOrHash();
93+
static UnicodeString buildUnicodeGitTagOrHash();
94+
95+
static AsciiString buildAsciiGitCommitTime();
96+
static UnicodeString buildUnicodeGitCommitTime();
6097

6198
private:
6299
Int m_major;
@@ -67,9 +104,15 @@ class Version
67104
AsciiString m_buildUser;
68105
AsciiString m_buildTime;
69106
AsciiString m_buildDate;
107+
AsciiString m_asciiGitCommitCount;
108+
AsciiString m_asciiGitTagOrHash;
109+
AsciiString m_asciiGitCommitTime;
110+
UnicodeString m_unicodeGitCommitCount;
111+
UnicodeString m_unicodeGitTagOrHash;
112+
UnicodeString m_unicodeGitCommitTime;
70113
Bool m_showFullVersion;
71114
};
72115

73-
extern Version *TheVersion; ///< The Version singleton
116+
extern Version *TheVersion;
74117

75118
#endif // __VERSION_H__

Generals/Code/GameEngine/Source/Common/GameEngine.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,17 +254,14 @@ void GameEngine::init()
254254
if (TheVersion)
255255
{
256256
DEBUG_LOG(("================================================================================"));
257-
#ifdef DEBUG_LOGGING
258-
#if defined RTS_DEBUG
259-
const char *buildType = "Debug";
260-
#else
261-
const char *buildType = "Release";
262-
#endif
263-
#endif // DEBUG_LOGGING
264-
DEBUG_LOG(("Generals version %s (%s)", TheVersion->getAsciiVersion().str(), buildType));
257+
DEBUG_LOG(("Generals version %s", TheVersion->getAsciiVersion().str()));
265258
DEBUG_LOG(("Build date: %s", TheVersion->getAsciiBuildTime().str()));
266259
DEBUG_LOG(("Build location: %s", TheVersion->getAsciiBuildLocation().str()));
267-
DEBUG_LOG(("Built by: %s", TheVersion->getAsciiBuildUser().str()));
260+
DEBUG_LOG(("Build user: %s", TheVersion->getAsciiBuildUser().str()));
261+
DEBUG_LOG(("Build git revision: %s", TheVersion->getAsciiGitCommitCount().str()));
262+
DEBUG_LOG(("Build git version: %s", TheVersion->getAsciiGitTagOrHash().str()));
263+
DEBUG_LOG(("Build git commit time: %s", TheVersion->getAsciiGitCommitTime().str()));
264+
DEBUG_LOG(("Build git commit author: %s", Version::getGitCommitAuthorName()));
268265
DEBUG_LOG(("================================================================================"));
269266
}
270267

0 commit comments

Comments
 (0)