- Use gitinfo.h instead of svnrevision.h for versioning.

- Use functions in gitinfo.cpp to retrieve the strings from gitinfo.h so
  that changes to gitinfo.h only require recompiling one file instead of
  several.
This commit is contained in:
Randy Heit 2013-06-22 21:49:51 -05:00
parent fece189bdb
commit 98ac224e53
15 changed files with 139 additions and 72 deletions

View file

@ -483,12 +483,12 @@ if( BACKPATCH )
add_definitions( -DBACKPATCH )
endif( BACKPATCH )
# Update svnrevision.h
# Update gitinfo.h
get_target_property( UPDATEREVISION_EXE updaterevision LOCATION )
add_custom_target( revision_check ALL
COMMAND ${UPDATEREVISION_EXE} . src/svnrevision.h
COMMAND ${UPDATEREVISION_EXE} . src/gitinfo.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS updaterevision )

View file

@ -395,7 +395,7 @@ CCMD (take)
CCMD (gameversion)
{
Printf ("%s : " __DATE__ "\n", DOTVERSIONSTR);
Printf ("%s @ %s\nCommit %s", GetVersionString(), GetGitTime(), GetGitHash());
}
CCMD (print)

View file

@ -1167,9 +1167,9 @@ void C_DrawConsole (bool hw2d)
if (ConBottom >= 12)
{
screen->DrawText (ConFont, CR_ORANGE, SCREENWIDTH - 8 -
ConFont->StringWidth ("v" DOTVERSIONSTR),
ConFont->StringWidth (GetVersionString()),
ConBottom - ConFont->GetHeight() - 4,
"v" DOTVERSIONSTR, TAG_DONE);
GetVersionString(), TAG_DONE);
if (TickerMax)
{
char tickstr[256];

View file

@ -2058,6 +2058,8 @@ static void PutSavePic (FILE *file, int width, int height)
void G_DoSaveGame (bool okForQuicksave, FString filename, const char *description)
{
char buf[100];
// Do not even try, if we're not in a level. (Can happen after
// a demo finishes playback.)
if (lines == NULL || sectors == NULL)
@ -2084,7 +2086,8 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
SaveVersion = SAVEVER;
PutSavePic (stdfile, SAVEPICWIDTH, SAVEPICHEIGHT);
M_AppendPNGText (stdfile, "Software", "ZDoom " DOTVERSIONSTR);
mysnprintf(buf, countof(buf), GAMENAME " %s", GetVersionString());
M_AppendPNGText (stdfile, "Software", buf);
M_AppendPNGText (stdfile, "Engine", GAMESIG);
M_AppendPNGText (stdfile, "ZDoom Save Version", SAVESIG);
M_AppendPNGText (stdfile, "Title", description);

View file

@ -225,7 +225,7 @@ FGameConfigFile::~FGameConfigFile ()
void FGameConfigFile::WriteCommentHeader (FILE *file) const
{
fprintf (file, "# This file was generated by " GAMENAME " " DOTVERSIONSTR " on %s\n", myasctime());
fprintf (file, "# This file was generated by " GAMENAME " %s on %s\n", GetVersionString(), myasctime());
}
void FGameConfigFile::MigrateStub (const char *pathname, FConfigFile *config, void *userdata)

65
src/gitinfo.cpp Normal file
View file

@ -0,0 +1,65 @@
/*
** gitinfo.cpp
** Returns strings from gitinfo.h.
**
**---------------------------------------------------------------------------
** Copyright 2013 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
** This file is just here so that when gitinfo.h changes, only one source
** file needs to be recompiled.
*/
#include "gitinfo.h"
#include "version.h"
const char *GetGitDescription()
{
return GIT_DESCRIPTION;
}
const char *GetGitHash()
{
return GIT_HASH;
}
const char *GetGitTime()
{
return GIT_TIME;
}
const char *GetVersionString()
{
if (GetGitDescription()[0] == '\0')
{
return VERSIONSTR;
}
else
{
return GIT_DESCRIPTION;
}
}

View file

@ -632,8 +632,10 @@ void WritePCXfile (FILE *file, const BYTE *buffer, const PalEntry *palette,
void WritePNGfile (FILE *file, const BYTE *buffer, const PalEntry *palette,
ESSType color_type, int width, int height, int pitch)
{
char software[100];
mysnprintf(software, countof(software), GAMENAME " %s", GetVersionString());
if (!M_CreatePNG (file, buffer, palette, color_type, width, height, pitch) ||
!M_AppendPNGText (file, "Software", GAMENAME DOTVERSIONSTR) ||
!M_AppendPNGText (file, "Software", software) ||
!M_FinishPNG (file))
{
Printf ("Could not create screenshot.\n");

View file

@ -150,7 +150,7 @@ static int DoomSpecificInfo (char *buffer, char *end)
int i, p;
p = 0;
p += snprintf (buffer+p, size-p, GAMENAME" version " DOTVERSIONSTR " (" __DATE__ ")\n");
p += snprintf (buffer+p, size-p, GAMENAME" version %s (%s)\n", GetVersionString(), GetGitHash());
#ifdef __VERSION__
p += snprintf (buffer+p, size-p, "Compiler version: %s\n", __VERSION__);
#endif
@ -248,8 +248,8 @@ int main (int argc, char **argv)
}
#endif // !__APPLE__
printf(GAMENAME" v%s - SVN revision %s - SDL version\nCompiled on %s\n",
DOTVERSIONSTR_NOREV,SVN_REVISION_STRING,__DATE__);
printf(GAMENAME" %s - %s - SDL version\nCompiled on %s\n",
GetVersionString(), GetGitTime(), __DATE__);
seteuid (getuid ());
std::set_new_handler (NewFailure);
@ -284,7 +284,9 @@ int main (int argc, char **argv)
printf("\n");
}
SDL_WM_SetCaption (GAMESIG " " DOTVERSIONSTR " (" __DATE__ ")", NULL);
char caption[100];
mysnprintf(caption, countof(caption), GAMESIG " %s (%s)", GetVersionString(), GetGitTime());
SDL_WM_SetCaption(caption);
#ifdef __APPLE__

View file

@ -483,10 +483,12 @@ int I_PickIWad_Gtk (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
GtkTreeIter iter, defiter;
int close_style = 0;
int i;
char caption[100];
// Create the dialog window.
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW(window), GAMESIG " " DOTVERSIONSTR ": Select an IWAD to use");
mysnprintf(caption, countof(caption), GAMESIG " %s: Select an IWAD to use", GetVersionString());
gtk_window_set_title (GTK_WINDOW(window), caption);
gtk_window_set_position (GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_container_set_border_width (GTK_CONTAINER(window), 10);
g_signal_connect (window, "delete_event", G_CALLBACK(gtk_main_quit), NULL);
@ -614,7 +616,8 @@ int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
const char *str;
if((str=getenv("KDE_FULL_SESSION")) && strcmp(str, "true") == 0)
{
FString cmd("kdialog --title \""GAMESIG" "DOTVERSIONSTR": Select an IWAD to use\""
FString cmd("kdialog --title \""GAMESIG" ");
cmd << GetVersionString() << ": Select an IWAD to use\""
" --menu \"ZDoom found more than one IWAD\n"
"Select from the list below to determine which one to use:\"");

View file

@ -34,21 +34,18 @@
#ifndef __VERSION_H__
#define __VERSION_H__
// The svnrevision.h is automatically updated to grab the revision of
// of the current source tree so that it can be included with version numbers.
#include "svnrevision.h"
const char *GetGitDescription();
const char *GetGitHash();
const char *GetGitTime();
const char *GetVersionString();
/** Lots of different version numbers **/
#define DOTVERSIONSTR_NOREV "2.7.0"
// The version string the user actually sees.
#define DOTVERSIONSTR DOTVERSIONSTR_NOREV " (r" SVN_REVISION_STRING ")"
#define VERSIONSTR "2.7.0"
// The version as seen in the Windows resource
#define RC_FILEVERSION 2,7,0,SVN_REVISION_NUMBER
#define RC_FILEVERSION 2,7,0,0
#define RC_PRODUCTVERSION 2,7,0,0
#define RC_FILEVERSION2 DOTVERSIONSTR
#define RC_PRODUCTVERSION2 "2.7"
// Version identifier for network games.
@ -75,36 +72,15 @@
// SAVESIG should match SAVEVER.
// MINSAVEVER is the minimum level snapshot version that can be loaded.
#define MINSAVEVER 3100
#define MINSAVEVER 3100
#if SVN_REVISION_NUMBER < MINSAVEVER
// If we don't know the current revision write something very high to ensure that
// the reesulting executable can read its own savegames but no regular engine can.
#define SAVEVER 999999
#define SAVESIG MakeSaveSig()
static inline const char *MakeSaveSig()
{
static char foo[] = { 'Z','D','O','O','M','S','A','V','E',
#if SAVEVER > 99999
'0' + (SAVEVER / 100000),
#endif
#if SAVEVER > 9999
'0' + ((SAVEVER / 10000) % 10),
#endif
#if SAVEVER > 999
'0' + ((SAVEVER / 1000) % 10),
#endif
'0' + ((SAVEVER / 100) % 10),
'0' + ((SAVEVER / 10) % 10),
'0' + (SAVEVER % 10),
'\0'
};
return foo;
}
#else
#define SAVEVER SVN_REVISION_NUMBER
#define SAVESIG "ZDOOMSAVE"SVN_REVISION_STRING
#endif
// Use 4500 as the base git save version, since it's higher than the
// SVN revision ever got.
#define SAVEVER 4500
#define SAVEVERSTRINGIFY2(x) str(x)
#define SAVEVERSTRINGIFY(x) #x
#define SAVESIG "ZDOOMSAVE" SAVEVERSTRINGIFY(SAVEVER)
// This is so that derivates can use the same savegame versions without worrying about engine compatibility
#define GAMESIG "ZDOOM"

View file

@ -128,7 +128,7 @@ RtlVirtualUnwind (
// If you are working on your own modified version of ZDoom, change
// the last part of the UPLOAD_AGENT (between parentheses) to your
// own program's name. e.g. (Skulltag) or (ZDaemon) or (ZDoomFu)
#define UPLOAD_AGENT "ZDoom/" DOTVERSIONSTR " (" GAMESIG ")"
#define UPLOAD_AGENT "ZDoom/" VERSIONSTR " (" GAMESIG ")"
// Time, in milliseconds, to wait for a send() or recv() to complete.
#define TIMEOUT 60000

View file

@ -95,8 +95,6 @@
#define X64 ""
#endif
#define WINDOW_TITLE GAMESIG " " DOTVERSIONSTR X64 " (" __DATE__ ")"
// The maximum number of functions that can be registered with atterm.
#define MAX_TERMS 64
@ -714,7 +712,9 @@ void ShowErrorPane(const char *text)
}
if (text != NULL)
{
SetWindowText (Window, "Fatal Error - " WINDOW_TITLE);
char caption[100];
mysnprintf(caption, countof(caption), "Fatal Error - "GAMESIG" %s "X64" (%s)", GetVersionString(), GetGitTime());
SetWindowText (Window, caption);
ErrorIcon = CreateWindowEx (WS_EX_NOPARENTNOTIFY, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SS_OWNERDRAW, 0, 0, 0, 0, Window, NULL, g_hInst, NULL);
if (ErrorIcon != NULL)
{
@ -945,10 +945,12 @@ void DoMain (HINSTANCE hInstance)
I_FatalError ("Could not register window class");
/* create window */
char caption[100];
mysnprintf(caption, countof(caption), ""GAMESIG" %s "X64" (%s)", GetVersionString(), GetGitTime());
Window = CreateWindowEx(
WS_EX_APPWINDOW,
(LPCTSTR)WinClassName,
(LPCTSTR)WINDOW_TITLE,
(LPCTSTR)caption,
WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN,
x, y, width, height,
(HWND) NULL,
@ -1045,7 +1047,7 @@ void DoomSpecificInfo (char *buffer, size_t bufflen)
char *const buffend = buffer + bufflen - 2; // -2 for CRLF at end
int i;
buffer += mysnprintf (buffer, buffend - buffer, "ZDoom version " DOTVERSIONSTR " (" __DATE__ ")\r\n");
buffer += mysnprintf (buffer, buffend - buffer, GAMENAME " version %s (%s)", GetVersionString(), GetGitHash());
buffer += mysnprintf (buffer, buffend - buffer, "\r\nCommand line: %s\r\n", GetCommandLine());
for (i = 0; (arg = Wads.GetWadName (i)) != NULL; ++i)

View file

@ -1095,7 +1095,7 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
FString newlabel;
GetWindowText(hDlg, label, countof(label));
newlabel.Format(GAMESIG " " DOTVERSIONSTR_NOREV ": %s", label);
newlabel.Format(GAMESIG " %s: %s", GetVersionString(), label);
SetWindowText(hDlg, newlabel.GetChars());
}
// Populate the list with all the IWADs found

View file

@ -8,7 +8,8 @@
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
#include "../version.h"
#include "../version.h"
#include "../gitinfo.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
@ -36,7 +37,8 @@ END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"#include ""../version.h""\r\0"
"#include ""../version.h""\r\r\n"
"#include ""../gitinfo.h""\r\0"
END
3 TEXTINCLUDE
@ -49,6 +51,7 @@ BEGIN
"//\r\n"
"// Version\r\n"
"//\r\n"
"#define RC_FILEVERSION2 GIT_DESCRIPTION\r\n"
"\r\n"
"VS_VERSION_INFO VERSIONINFO\r\n"
" FILEVERSION RC_FILEVERSION\r\n"
@ -72,8 +75,8 @@ BEGIN
" VALUE ""FileDescription"", ""ZDoom""\r\n"
" VALUE ""FileVersion"", RC_FILEVERSION2\r\n"
" VALUE ""InternalName"", ""ZDoom""\r\n"
" VALUE ""LegalCopyright"", ""Copyright \u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al.""\r\n"
" VALUE ""LegalTrademarks"", ""Doom® is a Registered Trademark of id Software, Inc.""\r\n"
" VALUE ""LegalCopyright"", ""Copyright \\u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al.""\r\n"
" VALUE ""LegalTrademarks"", ""DoomR is a Registered Trademark of id Software, Inc.""\r\n"
" VALUE ""OriginalFilename"", ""zdoom.exe""\r\n"
" VALUE ""ProductName"", ""ZDoom""\r\n"
" VALUE ""ProductVersion"", RC_PRODUCTVERSION2\r\n"
@ -83,7 +86,7 @@ BEGIN
" BEGIN\r\n"
" VALUE ""Translation"", 0x409, 1200\r\n"
" END\r\n"
"END\0"
"EN\0"
END
#endif // APSTUDIO_INVOKED
@ -468,6 +471,7 @@ IDB_DEADGUY BITMAP "deadguy.bmp"
//
// Version
//
#define RC_FILEVERSION2 GIT_DESCRIPTION
VS_VERSION_INFO VERSIONINFO
FILEVERSION RC_FILEVERSION
@ -491,8 +495,8 @@ BEGIN
VALUE "FileDescription", "ZDoom"
VALUE "FileVersion", RC_FILEVERSION2
VALUE "InternalName", "ZDoom"
VALUE "LegalCopyright", "Copyright © 1993-1996 id Software, 1998-2013 Randy Heit, Christoph Oelckers, Braden Obrzut, et al."
VALUE "LegalTrademarks", "Doom® is a Registered Trademark of id Software, Inc."
VALUE "LegalCopyright", "Copyright \u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al."
VALUE "LegalTrademarks", "DoomR is a Registered Trademark of id Software, Inc."
VALUE "OriginalFilename", "zdoom.exe"
VALUE "ProductName", "ZDoom"
VALUE "ProductVersion", RC_PRODUCTVERSION2

View file

@ -28,8 +28,8 @@
>
<Tool
Name="VCPreBuildEventTool"
Description="Checking svnrevision.h..."
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src src/svnrevision.h"
Description="Checking gitinfo.h..."
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src src/gitinfo.h"
/>
<Tool
Name="VCCustomBuildTool"
@ -151,7 +151,8 @@
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="$(OutDir)\updaterevision.exe src src/svnrevision.h"
Description="Checking gitinfo.h..."
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src src/gitinfo.h"
/>
<Tool
Name="VCCustomBuildTool"
@ -263,8 +264,8 @@
>
<Tool
Name="VCPreBuildEventTool"
Description="Checking svnrevision.h..."
CommandLine="$(OutDir)\updaterevision.exe src src/svnrevision.h"
Description="Checking gitinfo.h..."
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src src/gitinfo.h"
/>
<Tool
Name="VCCustomBuildTool"
@ -370,7 +371,8 @@
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="$(OutDir)\updaterevision.exe src src/svnrevision.h"
Description="Checking gitinfo.h..."
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src src/gitinfo.h"
/>
<Tool
Name="VCCustomBuildTool"
@ -652,6 +654,10 @@
RelativePath=".\src\gi.cpp"
>
</File>
<File
RelativePath=".\src\gitinfo.cpp"
>
</File>
<File
RelativePath=".\src\hu_scores.cpp"
>
@ -2417,6 +2423,10 @@
<Filter
Name="Versioning"
>
<File
RelativePath=".\src\baseversion.h"
>
</File>
<File
RelativePath=".\src\version.h"
>