File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
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...
You can’t perform that action at this time.
0 commit comments