Skip to content

Commit

Permalink
libcore|Client: Added Git information to About dialog and version info
Browse files Browse the repository at this point in the history
The current git description (commit hash, most recent tag, number of
commits since the tag) is now visible in the About dialog. The same
information is also printed by the "version" command (as a developer
message) and kept in the Version.GIT variable.
  • Loading branch information
skyjake committed Jun 2, 2015
1 parent 5842a29 commit ac3bfd2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
9 changes: 8 additions & 1 deletion doomsday/apps/client/src/dd_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2984,12 +2984,19 @@ D_CMD(Version)
LOG_NOTE(_E(D) DOOMSDAY_NICENAME " " DOOMSDAY_VERSION_FULLTEXT);
LOG_MSG(_E(l) "Homepage: " _E(.) _E(i) DOOMSDAY_HOMEURL _E(.)
"\n" _E(l) "Project: " _E(.) _E(i) DENGPROJECT_HOMEURL);

// Print the version info of the current game if loaded.
if(App_GameLoaded())
{
LOG_MSG(_E(l) "Game: " _E(.) "%s") << (char const *) gx.GetVariable(DD_PLUGIN_VERSION_LONG);
}

// Additional information for developers.
Version const ver;
if(!ver.gitDescription.isEmpty())
{
LOGDEV_MSG(_E(l) "Git revision: " _E(.) "%s") << ver.gitDescription;
}
return true;
}

Expand Down
5 changes: 3 additions & 2 deletions doomsday/apps/client/src/ui/dialogs/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ AboutDialog::AboutDialog() : DialogWidget("about"), d(new Instance(this))
title->setSizePolicy(ui::Fixed, ui::Expand);

LabelWidget *info = new LabelWidget;
String txt = String(_E(b) "%4 %5 #%6" _E(.) "\n%7\n\n%1 (%2-%8)%3")
String txt = String(_E(b) "%4 %5 #%6" _E(.) "\n%7%9\n\n%1 (%2-%8)%3")
.arg(ver2.operatingSystem() == "windows"? tr("Windows") :
ver2.operatingSystem() == "macx"? tr("Mac OS X") : tr("Unix"))
.arg(ver2.cpuBits())
Expand All @@ -85,7 +85,8 @@ AboutDialog::AboutDialog() : DialogWidget("about"), d(new Instance(this))
.arg(ver2.build)
.arg(Time::fromText(__DATE__ " " __TIME__, Time::CompilerDateTime)
.asDateTime().toString(Qt::SystemLocaleShortDate))
.arg(tr("bit"));
.arg(tr("bit"))
.arg(ver2.gitDescription.isEmpty()? "" : ("\n" _E(s)_E(F) + ver2.gitDescription + _E(.)_E(.)));
info->setText(txt);
info->setSizePolicy(ui::Fixed, ui::Expand);

Expand Down
13 changes: 13 additions & 0 deletions doomsday/sdk/libcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include (../../cmake/Config.cmake)

# Dependencies.
include (ZLIB)
find_package (Git QUIET)

# Definitions.
add_definitions (
Expand All @@ -19,6 +20,18 @@ add_definitions (
if (DEFINED DENG_BUILD)
add_definitions (-DLIBDENG2_BUILD_TEXT="${DENG_BUILD}")
endif ()
if (GIT_FOUND)
execute_process (
COMMAND ${GIT_EXECUTABLE} describe --long
OUTPUT_VARIABLE DENG_GIT_DESCRIPTION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (DENG_GIT_DESCRIPTION)
message (STATUS "Revision: ${DENG_GIT_DESCRIPTION}")
add_definitions (-DLIBDENG2_GIT_DESCRIPTION="${DENG_GIT_DESCRIPTION}")
endif ()
endif ()

# Source and header files.
file (GLOB_RECURSE HEADERS include/de/*)
Expand Down
3 changes: 2 additions & 1 deletion doomsday/sdk/libcore/include/de/core/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class DENG2_PUBLIC Version
int minor;
int patch;
int build;
String label; ///< Informative label, only intended for humans.
String label; ///< Informative label, only intended for humans.
String gitDescription; ///< Output from "git describe".

/**
* Version information about this build.
Expand Down
1 change: 1 addition & 0 deletions doomsday/sdk/libcore/src/scriptsys/scriptsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ DENG2_PIMPL(ScriptSystem)
mod.addText ("OS", Version::operatingSystem()).setReadOnly();
mod.addNumber ("CPU_BITS", Version::cpuBits() ).setReadOnly();
mod.addBoolean("DEBUG", Version::isDebugBuild() ).setReadOnly();
mod.addText ("GIT", ver.gitDescription ).setReadOnly();
#ifdef DENG_STABLE
mod.addBoolean("STABLE", true).setReadOnly();
#else
Expand Down
4 changes: 4 additions & 0 deletions doomsday/sdk/libcore/src/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Version::Version() : build(Time().asBuildNumber())
#endif

label = LIBDENG2_RELEASE_LABEL;

#ifdef LIBDENG2_GIT_DESCRIPTION
gitDescription = LIBDENG2_GIT_DESCRIPTION;
#endif
}

Version::Version(String const &version, int buildNumber) : build(buildNumber)
Expand Down

0 comments on commit ac3bfd2

Please sign in to comment.