comptime.bat 840 Bytes
Newer Older
1
@echo off
2 3 4
set BRA=Unknown
set REV=illegal

Alam Ed Arias committed
5 6
copy nul: /b +%1\comptime.c tmp.$$$ > nul
move tmp.$$$ %1\comptime.c > nul
7 8

if exist .git goto gitrev
9
if exist ..\.git goto gitrev
10 11 12 13 14 15
if exist .svn goto svnrev
goto filwri

:gitrev
set GIT=%2
if "%GIT%"=="" set GIT=git
16 17
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
18 19 20 21 22
set REV=%REV:~0,8%
goto filwri

:svnrev
set BRA=Subversion
23
for /f "usebackq" %%s in (`svnversion .`) do @set REV=%%s
24
set REV=r%REV%
25 26 27
goto filwri

:filwri
28 29 30 31 32
echo // Do not edit!  This file was autogenerated > %1\comptime.h
echo // by the %0 batch file >> %1\comptime.h
echo // >> %1\comptime.h
echo const char* compbranch = "%BRA%"; >> %1\comptime.h
echo const char* comprevision = "%REV%"; >> %1\comptime.h