Skip to content

Commit b6cbbc0

Browse files
committed
Added Git Version number (Windows MSVS with prebuild script)
1 parent 0898b5c commit b6cbbc0

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

prebuild.cmd

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@echo off
2+
REM This pre-build file is for MSVS VC++. It parses the git master hash and
3+
REM converts it into GitVersion.h for compiling into builds. [George M1GEO]
4+
5+
cd %1
6+
setlocal enabledelayedexpansion
7+
set HEADFILE=.git\HEAD
8+
set HASHFILE=0
9+
if exist %HEADFILE% (
10+
for /F "tokens=4 delims=/:" %%a in ('type %HEADFILE%') do set HEADBRANCH=%%a
11+
set HASHFILE=.git\refs\heads\!HEADBRANCH!
12+
echo Found Git HEAD file: %HEADFILE%
13+
echo Git HEAD branch: !HEADBRANCH!
14+
echo Git HASH file: !HASHFILE!
15+
call :USEHASH
16+
) else (
17+
echo No head file :(
18+
call :USENULL
19+
)
20+
21+
goto :EOF
22+
23+
:USENULL
24+
set GITHASH=0000000000000000000000000000000000000000
25+
goto :WRITEGITVERSIONHEADER
26+
27+
:USEHASH
28+
for /f %%i in ('type !HASHFILE!') do set GITHASH=%%i
29+
goto :WRITEGITVERSIONHEADER
30+
31+
:WRITEGITVERSIONHEADER
32+
echo # File contains Git commit ID SHA1 present at buildtime (prebuild.cmd) > GitVersion.h
33+
echo const char *gitversion = "%GITHASH%"; >> GitVersion.h
34+
echo Current Git HASH: %GITHASH%
35+
goto :FINISHED
36+
37+
:FINISHED
38+
echo GitVersion.h written...

0 commit comments

Comments
 (0)