Skip to content

[GEN][ZH] Generate git version information and print it in the Game Window title, Options Menu (and Main Menu) #1219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target_include_directories(corei_libraries_source_wwvegas_wwlib INTERFACE "Libra
target_link_libraries(corei_always INTERFACE
core_utility
corei_libraries_include
resources
)

# Set where the build results will end up
Expand Down
71 changes: 57 additions & 14 deletions GeneralsMD/Code/GameEngine/Include/Common/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,69 @@
#ifndef __VERSION_H__
#define __VERSION_H__

#include <time.h>

/**
* The Version class formats the version number into integer and string
* values for different parts of the game.
* @todo: increment build number on compile, and stamp exe with username
*/
// TheSuperHackers @tweak The Version class now also provides Git information
// alongside the original Version information.
class Version
{
public:
Version();
UnsignedInt getVersionNumber( void ); ///< Return a 4-byte integer suitable for WOLAPI
AsciiString getAsciiVersion( void ); ///< Return a human-readable version number
UnicodeString getUnicodeVersion( void ); ///< Return a human-readable version number
UnicodeString getFullUnicodeVersion( void ); ///< Return a human-readable version number
AsciiString getAsciiBuildTime( void ); ///< Return a formated date/time string for build time
UnicodeString getUnicodeBuildTime( void ); ///< Return a formated date/time string for build time
AsciiString getAsciiBuildLocation( void ); ///< Return a string with the build location
UnicodeString getUnicodeBuildLocation( void ); ///< Return a string with the build location
AsciiString getAsciiBuildUser( void ); ///< Return a string with the build user
UnicodeString getUnicodeBuildUser( void ); ///< Return a string with the build user

Bool showFullVersion( void ) { return m_showFullVersion; }

UnsignedInt getVersionNumber() const; ///< Return a 4-byte integer suitable for WOLAPI

AsciiString getAsciiVersion() const; ///< Return a human-readable version number
UnicodeString getUnicodeVersion() const; ///< Return a human-readable version number. Is decorated with localized string

AsciiString getAsciiBuildTime() const; ///< Return a formated date/time string for build time
UnicodeString getUnicodeBuildTime() const; ///< Return a formated date/time string for build time. Is decorated with localized string

AsciiString getAsciiBuildLocation() const; ///< Return a string with the build location
UnicodeString getUnicodeBuildLocation() const; ///< Return a string with the build location. Is decorated with localized string

AsciiString getAsciiBuildUser() const; ///< Return a string with the build user
UnicodeString getUnicodeBuildUser() const; ///< Return a string with the build user. Is decorated with localized string

static Int getGitCommitCount(); ///< Returns the git commit count as a number
static time_t getGitCommitTime(); ///< Returns the git head commit time as a UTC timestamp
static const char* getGitCommitAuthorName(); ///< Returns the git head commit author name

AsciiString getAsciiGitCommitCount() const; ///< Returns the git commit count. Is prefixed with ~ if there were uncommitted changes.
UnicodeString getUnicodeGitCommitCount() const; ///< Returns the git commit count. Is prefixed with ~ if there were uncommitted changes.

AsciiString getAsciiGitTagOrHash() const; ///< Returns the git head commit tag or hash. Is prefixed with ~ if there were uncommitted changes.
UnicodeString getUnicodeGitTagOrHash() const; ///< Returns the git head commit tag or hash. Is prefixed with ~ if there were uncommitted changes.

AsciiString getAsciiGitCommitTime() const; ///< Returns the git head commit time in YYYY-mm-dd HH:MM:SS format
UnicodeString getUnicodeGitCommitTime() const; ///< Returns the git head commit time in YYYY-mm-dd HH:MM:SS format

AsciiString getAsciiGameAndGitVersion() const; ///< Returns the game and git version
UnicodeString getUnicodeGameAndGitVersion() const; ///< Returns the game and git version. Is decorated with localized string

AsciiString getAsciiBuildUserOrGitCommitAuthorName() const;
UnicodeString getUnicodeBuildUserOrGitCommitAuthorName() const; ///< Is decorated with localized string

Bool showFullVersion() const { return m_showFullVersion; }
void setShowFullVersion( Bool val ) { m_showFullVersion = val; }

void setVersion(Int major, Int minor, Int buildNum,
Int localBuildNum, AsciiString user, AsciiString location,
AsciiString buildTime, AsciiString buildDate); ///< Set version info
AsciiString buildTime, AsciiString buildDate);

private:
static AsciiString buildAsciiGitCommitCount();
static UnicodeString buildUnicodeGitCommitCount();

static AsciiString buildAsciiGitTagOrHash();
static UnicodeString buildUnicodeGitTagOrHash();

static AsciiString buildAsciiGitCommitTime();
static UnicodeString buildUnicodeGitCommitTime();

private:
Int m_major;
Expand All @@ -67,9 +104,15 @@ class Version
AsciiString m_buildUser;
AsciiString m_buildTime;
AsciiString m_buildDate;
AsciiString m_asciiGitCommitCount;
AsciiString m_asciiGitTagOrHash;
AsciiString m_asciiGitCommitTime;
UnicodeString m_unicodeGitCommitCount;
UnicodeString m_unicodeGitTagOrHash;
UnicodeString m_unicodeGitCommitTime;
Bool m_showFullVersion;
};

extern Version *TheVersion; ///< The Version singleton
extern Version *TheVersion;

#endif // __VERSION_H__
15 changes: 6 additions & 9 deletions GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,14 @@ void GameEngine::init()
if (TheVersion)
{
DEBUG_LOG(("================================================================================\n"));
#if defined RTS_DEBUG
const char *buildType = "Debug";
#elif defined RTS_INTERNAL
const char *buildType = "Internal";
#else
const char *buildType = "Release";
#endif
DEBUG_LOG(("Generals version %s (%s)\n", TheVersion->getAsciiVersion().str(), buildType));
DEBUG_LOG(("Generals version %s\n", TheVersion->getAsciiVersion().str()));
DEBUG_LOG(("Build date: %s\n", TheVersion->getAsciiBuildTime().str()));
DEBUG_LOG(("Build location: %s\n", TheVersion->getAsciiBuildLocation().str()));
DEBUG_LOG(("Built by: %s\n", TheVersion->getAsciiBuildUser().str()));
DEBUG_LOG(("Build user: %s\n", TheVersion->getAsciiBuildUser().str()));
DEBUG_LOG(("Build git revision: %s\n", TheVersion->getAsciiGitCommitCount().str()));
DEBUG_LOG(("Build git version: %s\n", TheVersion->getAsciiGitTagOrHash().str()));
DEBUG_LOG(("Build git commit time: %s\n", TheVersion->getAsciiGitCommitTime().str()));
DEBUG_LOG(("Build git commit author: %s\n", Version::getGitCommitAuthorName()));
DEBUG_LOG(("================================================================================\n"));
}
#endif
Expand Down
Loading
Loading