moved the create_git_header scripts into the cnq3 repository

This commit is contained in:
myT 2017-03-08 02:41:21 +01:00
parent ae2560984a
commit 0bc9c75e49
8 changed files with 35 additions and 17 deletions

View file

@ -0,0 +1,9 @@
@echo off
FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse HEAD`) DO (
SET GIT_COMMIT_HASH=%%F
)
FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --abbrev-ref HEAD`) DO (
SET GIT_BRANCH_NAME=%%F
)
:: We create the file in one go to avoid doubled lines in multi-threaded builds.
(echo #define GIT_COMMIT ^"%GIT_COMMIT_HASH%^" && echo #define GIT_BRANCH ^"%GIT_BRANCH_NAME%^")>%1

6
build/create_git_header.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
COMMIT="$(git rev-parse HEAD)"
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
echo "#define GIT_COMMIT \"${COMMIT}\"" > $1
echo "#define GIT_BRANCH \"${BRANCH}\"" >> $1

View file

@ -28,7 +28,7 @@ ifeq ($(config),debug_x32)
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
@echo Running prebuild commands
"../../../cnq3tools/git/create_git_header.sh" "../../code/qcommon/git.h"
"../create_git_header.sh" "../../code/qcommon/git.h"
endef
define PRELINKCMDS
endef
@ -59,7 +59,7 @@ ifeq ($(config),debug_x64)
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
@echo Running prebuild commands
"../../../cnq3tools/git/create_git_header.sh" "../../code/qcommon/git.h"
"../create_git_header.sh" "../../code/qcommon/git.h"
endef
define PRELINKCMDS
endef
@ -90,7 +90,7 @@ ifeq ($(config),release_x32)
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
@echo Running prebuild commands
"../../../cnq3tools/git/create_git_header.sh" "../../code/qcommon/git.h"
"../create_git_header.sh" "../../code/qcommon/git.h"
endef
define PRELINKCMDS
endef
@ -121,7 +121,7 @@ ifeq ($(config),release_x64)
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
@echo Running prebuild commands
"../../../cnq3tools/git/create_git_header.sh" "../../code/qcommon/git.h"
"../create_git_header.sh" "../../code/qcommon/git.h"
endef
define PRELINKCMDS
endef

View file

@ -28,7 +28,7 @@ ifeq ($(config),debug_x32)
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
@echo Running prebuild commands
"../../../cnq3tools/git/create_git_header.sh" "../../code/qcommon/git.h"
"../create_git_header.sh" "../../code/qcommon/git.h"
endef
define PRELINKCMDS
endef
@ -59,7 +59,7 @@ ifeq ($(config),debug_x64)
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
@echo Running prebuild commands
"../../../cnq3tools/git/create_git_header.sh" "../../code/qcommon/git.h"
"../create_git_header.sh" "../../code/qcommon/git.h"
endef
define PRELINKCMDS
endef
@ -90,7 +90,7 @@ ifeq ($(config),release_x32)
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
@echo Running prebuild commands
"../../../cnq3tools/git/create_git_header.sh" "../../code/qcommon/git.h"
"../create_git_header.sh" "../../code/qcommon/git.h"
endef
define PRELINKCMDS
endef
@ -121,7 +121,7 @@ ifeq ($(config),release_x64)
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
@echo Running prebuild commands
"../../../cnq3tools/git/create_git_header.sh" "../../code/qcommon/git.h"
"../create_git_header.sh" "../../code/qcommon/git.h"
endef
define PRELINKCMDS
endef

View file

@ -26,7 +26,7 @@ path_build = path_root.."/cnq3/build"
path_bin = path_root.."/.bin"
-- relative to the makefile
make_path_git_scripts = "../../../cnq3tools/git"
make_path_git_scripts = ".."
make_path_git_header = "../../code/qcommon/git.h"
make_path_bin = "../../../.bin"

View file

@ -120,7 +120,7 @@
<AdditionalOptions> ..\..\cnq3\code\win32\winquake.res /STACK:8388608 %(AdditionalOptions)</AdditionalOptions>
</Link>
<PreBuildEvent>
<Command>"..\..\..\cnq3tools\git\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
<Command>"..\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>copy "..\..\..\.bin\debug_x32\cnq3-server-x86.exe" "$(QUAKE3DIR)"
@ -148,7 +148,7 @@ copy "..\..\..\.bin\debug_x32\cnq3-server-x86.pdb" "$(QUAKE3DIR)"</Command>
<AdditionalOptions> ..\..\cnq3\code\win32\winquake.res /STACK:8388608 %(AdditionalOptions)</AdditionalOptions>
</Link>
<PreBuildEvent>
<Command>"..\..\..\cnq3tools\git\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
<Command>"..\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>copy "..\..\..\.bin\debug_x64\cnq3-server-x64.exe" "$(QUAKE3DIR)"
@ -187,7 +187,7 @@ copy "..\..\..\.bin\debug_x64\cnq3-server-x64.pdb" "$(QUAKE3DIR)"</Command>
<AdditionalOptions> ..\..\cnq3\code\win32\winquake.res /STACK:8388608 /OPT:REF /OPT:ICF %(AdditionalOptions)</AdditionalOptions>
</Link>
<PreBuildEvent>
<Command>"..\..\..\cnq3tools\git\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
<Command>"..\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>copy "..\..\..\.bin\release_x32\cnq3-server-x86.exe" "$(QUAKE3DIR)"
@ -225,7 +225,7 @@ copy "..\..\..\.bin\release_x32\cnq3-server-x86.pdb" "$(QUAKE3DIR)"</Command>
<AdditionalOptions> ..\..\cnq3\code\win32\winquake.res /STACK:8388608 /OPT:REF /OPT:ICF %(AdditionalOptions)</AdditionalOptions>
</Link>
<PreBuildEvent>
<Command>"..\..\..\cnq3tools\git\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
<Command>"..\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>copy "..\..\..\.bin\release_x64\cnq3-server-x64.exe" "$(QUAKE3DIR)"

View file

@ -121,7 +121,7 @@
<AdditionalOptions> ..\..\cnq3\code\win32\winquake.res /STACK:8388608 %(AdditionalOptions)</AdditionalOptions>
</Link>
<PreBuildEvent>
<Command>"..\..\..\cnq3tools\git\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
<Command>"..\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>copy "..\..\..\.bin\debug_x32\cnq3-x86.exe" "$(QUAKE3DIR)"
@ -150,7 +150,7 @@ copy "..\..\..\.bin\debug_x32\cnq3-x86.pdb" "$(QUAKE3DIR)"</Command>
<AdditionalOptions> ..\..\cnq3\code\win32\winquake.res /STACK:8388608 %(AdditionalOptions)</AdditionalOptions>
</Link>
<PreBuildEvent>
<Command>"..\..\..\cnq3tools\git\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
<Command>"..\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>copy "..\..\..\.bin\debug_x64\cnq3-x64.exe" "$(QUAKE3DIR)"
@ -190,7 +190,7 @@ copy "..\..\..\.bin\debug_x64\cnq3-x64.pdb" "$(QUAKE3DIR)"</Command>
<AdditionalOptions> ..\..\cnq3\code\win32\winquake.res /STACK:8388608 /OPT:REF /OPT:ICF %(AdditionalOptions)</AdditionalOptions>
</Link>
<PreBuildEvent>
<Command>"..\..\..\cnq3tools\git\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
<Command>"..\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>copy "..\..\..\.bin\release_x32\cnq3-x86.exe" "$(QUAKE3DIR)"
@ -229,7 +229,7 @@ copy "..\..\..\.bin\release_x32\cnq3-x86.pdb" "$(QUAKE3DIR)"</Command>
<AdditionalOptions> ..\..\cnq3\code\win32\winquake.res /STACK:8388608 /OPT:REF /OPT:ICF %(AdditionalOptions)</AdditionalOptions>
</Link>
<PreBuildEvent>
<Command>"..\..\..\cnq3tools\git\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
<Command>"..\create_git_header.cmd" "..\..\code\qcommon\git.h"</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>copy "..\..\..\.bin\release_x64\cnq3-x64.exe" "$(QUAKE3DIR)"

View file

@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "q_shared.h"
#include "qcommon.h"
#include "git.h"
static cvar_t* cvar_vars;
static cvar_t* cvar_cheats;
@ -675,6 +676,8 @@ void Cvar_Update( vmCvar_t *vmCvar )
void Cvar_Init()
{
cvar_cheats = Cvar_Get( "sv_cheats", "1", CVAR_ROM | CVAR_SYSTEMINFO );
Cvar_Get( "git_branch", GIT_BRANCH, CVAR_ROM );
Cvar_Get( "git_headHash", GIT_COMMIT, CVAR_ROM );
Cmd_AddCommand( "toggle", Cvar_Toggle_f );
Cmd_AddCommand( "set", Cvar_Set_f );