From 74f27a6bceaf968eb7558edc0d297f03722da5c7 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Mon, 6 Nov 2023 21:17:10 +1000 Subject: [PATCH] build: fix buildstring The revision was always "-", there was code duplication and inconsistency, the meaning of some strings was unclear. Frees up some space in the `status` "version:" line by moving gamenetworkfiltername to "protocol:" which seems like a more relevant section anyway. Signed-off-by: bones_was_here --- builddate.c | 11 ++++++----- cl_demo.c | 2 +- host.c | 6 ++---- makefile.inc | 10 +++++++--- sv_ccmds.c | 3 ++- sv_main.c | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/builddate.c b/builddate.c index e38d9b18..7106dc9b 100644 --- a/builddate.c +++ b/builddate.c @@ -3,14 +3,15 @@ extern const char *buildstring; const char *buildstring = -#ifndef NO_BUILD_TIMESTAMPS -__TIME__ " " __DATE__ " " -#endif -#ifdef SVNREVISION -STRINGIFY(SVNREVISION) +#ifdef VCREVISION +STRINGIFY(VCREVISION) #else "-" #endif +#ifndef NO_BUILD_TIMESTAMPS +//" " __TIME__ +" " __DATE__ +#endif #ifdef BUILDTYPE " " STRINGIFY(BUILDTYPE) #endif diff --git a/cl_demo.c b/cl_demo.c index b1f2e685..502a7fac 100644 --- a/cl_demo.c +++ b/cl_demo.c @@ -509,7 +509,7 @@ static void CL_FinishTimeDemo (void) fpsmax = cls.td_onesecondmaxfps; // LadyHavoc: timedemo now prints out 7 digits of fraction, and min/avg/max Con_Printf("%i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", frames, time, totalfpsavg, fpsmin, fpsavg, fpsmax, cls.td_onesecondavgcount); - Log_Printf("benchmark.log", "date %s | enginedate %s | demo %s | commandline %s | run %d | result %i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", Sys_TimeString("%Y-%m-%d %H:%M:%S"), buildstring, cls.demoname, cmdline.string, benchmark_runs + 1, frames, time, totalfpsavg, fpsmin, fpsavg, fpsmax, cls.td_onesecondavgcount); + Log_Printf("benchmark.log", "date %s | enginedate %s | demo %s | commandline %s | run %d | result %i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", Sys_TimeString("%Y-%m-%d %H:%M:%S"), engineversion, cls.demoname, cmdline.string, benchmark_runs + 1, frames, time, totalfpsavg, fpsmin, fpsavg, fpsmax, cls.td_onesecondavgcount); if (Sys_CheckParm("-benchmark")) { ++benchmark_runs; diff --git a/host.c b/host.c index 5ecf7972..924e655e 100644 --- a/host.c +++ b/host.c @@ -156,7 +156,7 @@ static void Host_Quit_f(cmd_state_t *cmd) static void Host_Version_f(cmd_state_t *cmd) { - Con_Printf("Version: %s build %s\n", gamename, buildstring); + Con_Printf("Version: %s\n", engineversion); } static void Host_Framerate_c(cvar_t *var) @@ -365,7 +365,6 @@ Host_Init static void Host_Init (void) { int i; - const char* os; char vabuf[1024]; host.hook.ConnectLocal = NULL; @@ -445,8 +444,7 @@ static void Host_Init (void) FS_Init(); // construct a version string for the corner of the console - os = DP_OS_NAME; - dpsnprintf (engineversion, sizeof (engineversion), "%s %s %s", gamename, os, buildstring); + dpsnprintf (engineversion, sizeof (engineversion), "%s %s%s, buildstring: %s", gamename, DP_OS_NAME, cls.state == ca_dedicated ? " dedicated" : "", buildstring); Con_Printf("%s\n", engineversion); // initialize process nice level diff --git a/makefile.inc b/makefile.inc index 90e2bf86..ff2a68df 100644 --- a/makefile.inc +++ b/makefile.inc @@ -209,9 +209,13 @@ DO_CC=$(CC) $(CFLAGS) -c $< -o $@ # Link -LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG) -DSVNREVISION=`{ test -d .svn && svnversion; } || { test -d .git && git describe --always; } || echo -` -DBUILDTYPE=debug -LDFLAGS_PROFILE=-g -pg -fprofile-arcs $(OPTIM_RELEASE) -DSVNREVISION=`{ test -d .svn && svnversion; } || { test -d .git && git describe --always; } || echo -` -DBUILDTYPE=profile -LDFLAGS_RELEASE=$(OPTIM_RELEASE) -DSVNREVISION=`{ test -d .svn && svnversion; } || { test -d .git && git describe --always; } || echo -` -DBUILDTYPE=release + +# not checking for .git directory before running `git describe` because that would stop it working in a subdirectory +VCREVISION=$(shell { test -d .svn && svnversion; } || git describe --always --dirty='~' 2>/dev/null || echo -) + +LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG) -DVCREVISION=$(VCREVISION) -DBUILDTYPE=debug +LDFLAGS_PROFILE=-g -pg -fprofile-arcs $(OPTIM_RELEASE) -DVCREVISION=$(VCREVISION) -DBUILDTYPE=profile +LDFLAGS_RELEASE=$(OPTIM_RELEASE) -DVCREVISION=$(VCREVISION) -DBUILDTYPE=release ##### UNIX specific variables ##### diff --git a/sv_ccmds.c b/sv_ccmds.c index 036f4c63..a28b0789 100644 --- a/sv_ccmds.c +++ b/sv_ccmds.c @@ -736,8 +736,9 @@ static void SV_Status_f(cmd_state_t *cmd) for (players = 0, i = 0;i < svs.maxclients;i++) if (svs.clients[i].active) players++; + print ("host: %s\n", Cvar_VariableString (&cvars_all, "hostname", CF_SERVER)); - print ("version: %s build %s (gamename %s)\n", gamename, buildstring, gamenetworkfiltername); + print ("version: %s\n", engineversion); print ("protocol: %i (%s)\n", Protocol_NumberForEnum(sv.protocol), Protocol_NameForEnum(sv.protocol)); print ("map: %s\n", sv.name); print ("timing: %s\n", SV_TimingReport(vabuf, sizeof(vabuf))); diff --git a/sv_main.c b/sv_main.c index c4168d2e..0f4fb8fe 100644 --- a/sv_main.c +++ b/sv_main.c @@ -796,7 +796,7 @@ void SV_SendServerinfo (client_t *client) SZ_Clear (&client->netconnection->message); MSG_WriteByte (&client->netconnection->message, svc_print); - dpsnprintf (message, sizeof (message), "\nServer: %s build %s (progs %i crc)\n", gamename, buildstring, prog->filecrc); + dpsnprintf (message, sizeof (message), "\nServer: %s (progs %i crc)\n", engineversion, prog->filecrc); MSG_WriteString (&client->netconnection->message,message); SV_StopDemoRecording(client); // to split up demos into different files -- 2.39.2