Branch and revision information in builds

Also makes comptime.bat work with git if able.
Development builds will now show the branch and the SHA1 hash of the revision. Also been tested to work with subversion, where it displays "Subversion r####". You know, just in case.
This commit is contained in:
Inuyasha 2016-01-14 04:31:48 -08:00
parent f2b2cd3f7a
commit 06dea3ab78
7 changed files with 52 additions and 19 deletions

View file

@ -1,10 +1,30 @@
@ECHO OFF @ECHO OFF
set REV=Unknown set BRA=Unknown
set REV=illegal
copy nul: /b +%1\comptime.c tmp.$$$ > nul copy nul: /b +%1\comptime.c tmp.$$$ > nul
move tmp.$$$ %1\comptime.c > nul move tmp.$$$ %1\comptime.c > nul
SET REV=illegal
FOR /F "usebackq" %%s IN (`svnversion %1`) DO @SET REV=%%s if exist .git goto gitrev
if exist .svn goto svnrev
goto filwri
:gitrev
set GIT=%2
if "%GIT%"=="" set GIT=git
FOR /F "usebackq" %%s IN (`%GIT% rev-parse --abbrev-ref HEAD`) DO @SET BRA=%%s
FOR /F "usebackq" %%s IN (`%GIT% rev-parse HEAD`) DO @SET REV=%%s
set REV=%REV:~0,8%
goto filwri
:svnrev
set BRA=Subversion
FOR /F "usebackq" %%s IN (`svnversion .`) DO @SET REV=%%s
goto filwri
:filwri
ECHO // Do not edit! This file was autogenerated > %1\comptime.h ECHO // Do not edit! This file was autogenerated > %1\comptime.h
ECHO // by the %0 batch file >> %1\comptime.h ECHO // by the %0 batch file >> %1\comptime.h
ECHO // >> %1\comptime.h ECHO // >> %1\comptime.h
ECHO const char* comprevision = "r%REV%"; >> %1\comptime.h ECHO const char* compbranch = "%BRA%"; >> %1\comptime.h
ECHO const char* comprevision = "%REV%"; >> %1\comptime.h

View file

@ -5,13 +5,15 @@ if [ x"$1" != x ]; then
fi fi
versiongit() { versiongit() {
gitversion=`git describe` gitbranch=`git rev-parse --abbrev-ref HEAD`
gitversion=`git rev-parse HEAD`
cat <<EOF > $path/comptime.h cat <<EOF > $path/comptime.h
// Do not edit! This file was autogenerated // Do not edit! This file was autogenerated
// by the $0 script with git svn // by the $0 script with git
// //
const char* comprevision = "$gitversion"; const char* compbranch = "$gitbranch";
const char* comprevision = "${gitversion:0:8}";
EOF EOF
exit 0 exit 0
} }
@ -23,6 +25,7 @@ versionsvn() {
// Do not edit! This file was autogenerated // Do not edit! This file was autogenerated
// by the $0 script with subversion // by the $0 script with subversion
// //
const char* compbranch = "Subversion";
const char* comprevision = "r$svnrevision"; const char* comprevision = "r$svnrevision";
EOF EOF
exit 0 exit 0
@ -34,6 +37,7 @@ versionfake() {
// Do not edit! This file was autogenerated // Do not edit! This file was autogenerated
// by the $0 script with an unknown or nonexist SCM // by the $0 script with an unknown or nonexist SCM
// //
const char* compbranch = "Unknown";
const char* comprevision = "illegal"; const char* comprevision = "illegal";
EOF EOF
} }

View file

@ -9,12 +9,14 @@
#if (defined(CMAKECONFIG)) #if (defined(CMAKECONFIG))
#include "config.h" #include "config.h"
const char *compbranch = ""; // hell if I know what to do with cmake
const char *comprevision = SRB2_COMP_REVISION; const char *comprevision = SRB2_COMP_REVISION;
#elif (defined(COMPVERSION)) #elif (defined(COMPVERSION))
#include "comptime.h" #include "comptime.h"
#else #else
const char *compbranch = "Unknown";
const char *comprevision = "illegal"; const char *comprevision = "illegal";
#endif #endif

View file

@ -3179,7 +3179,11 @@ static void Command_ListWADS_f(void)
*/ */
static void Command_Version_f(void) static void Command_Version_f(void)
{ {
#ifdef DEVELOP
CONS_Printf("Sonic Robo Blast 2 %s-%s (%s %s)\n", compbranch, comprevision, compdate, comptime);
#else
CONS_Printf("Sonic Robo Blast 2 %s (%s %s %s)\n", VERSIONSTRING, compdate, comptime, comprevision); CONS_Printf("Sonic Robo Blast 2 %s (%s %s %s)\n", VERSIONSTRING, compdate, comptime, comprevision);
#endif
} }
#ifdef UPDATE_ALERT #ifdef UPDATE_ALERT

View file

@ -142,8 +142,10 @@ extern FILE *logstream;
#ifdef DEVELOP #ifdef DEVELOP
#define VERSION 0 // Game version #define VERSION 0 // Game version
#define SUBVERSION 0 // more precise version number #define SUBVERSION 0 // more precise version number
#define VERSIONSTRING "Trunk" #define VERSIONSTRING "Development EXE"
#define VERSIONSTRINGW L"Trunk" #define VERSIONSTRINGW L"Development EXE"
// most interface strings are ignored in development mode.
// we use comprevision and compbranch instead.
#else #else
#define VERSION 201 // Game version #define VERSION 201 // Game version
#define SUBVERSION 14 // more precise version number #define SUBVERSION 14 // more precise version number
@ -426,7 +428,7 @@ INT32 I_GetKey(void);
#endif #endif
// Compile date and time and revision. // Compile date and time and revision.
extern const char *compdate, *comptime, *comprevision; extern const char *compdate, *comptime, *comprevision, *compbranch;
// Disabled code and code under testing // Disabled code and code under testing
// None of these that are disabled in the normal build are guaranteed to work perfectly // None of these that are disabled in the normal build are guaranteed to work perfectly

View file

@ -2463,11 +2463,14 @@ void M_Drawer(void)
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, customversionstring); V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, customversionstring);
} }
else else
#if VERSION > 0 || SUBVERSION > 0 {
#ifdef DEVELOP // Development -- show revision / branch info
V_DrawThinString(vid.dupx, vid.height - 17*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, compbranch);
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, comprevision);
#else // Regular build
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s", VERSIONSTRING)); V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s", VERSIONSTRING));
#else // Trunk build, show revision info
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s (%s)", VERSIONSTRING, comprevision));
#endif #endif
}
} }
} }

View file

@ -1800,16 +1800,14 @@ UINT8 M_HighestBit(UINT32 num)
const char *GetRevisionString(void) const char *GetRevisionString(void)
{ {
INT32 vinfo; static char rev[9] = {0};
static char rev[8] = {0};
if (rev[0]) if (rev[0])
return rev; return rev;
vinfo = atoi(&comprevision[1]); if (comprevision[0] == 'r')
if (vinfo) strncpy(rev, comprevision, 7);
snprintf(rev, 7, "r%d", vinfo);
else else
strcpy(rev, "rNULL"); snprintf(rev, 7, "r%s", comprevision);
rev[7] = '\0'; rev[7] = '\0';
return rev; return rev;