Вот пример кода, который я использую, который аналогичным образом создает AC-файл для вас со временем сборки и версией git.Это также включает в себя прием, чтобы получить вывод «git description» в переменную bat-файла.
:: vss1_version.bat
:: This batch file will create a version c file that
:: will contain the build date and time along with
:: version information extracted from GIT.
:: This file expects git to be installed and excessable
:: from the path
if "%1" NEQ "" goto deploy
echo usage: vss1_version [filename]
echo i.e. vss1_version .\deploy\vss1\VSS1_VERSION.c
exit /b 1
:deploy
set VSS1_VERSION_FILENAME=%1
:: Delete the current file.
rm -f -v %VSS1_VERSION_FILENAME%
:: Get time and day nicely formatted
set current_time=%time%
set ver_hour=%current_time:~0,2%
if "%ver_hour:~0,1%" == " " set ver_hour=0%ver_hour:~1,1%
set ver_min=%current_time:~3,2%
if "%ver_min:~0,1%" == " " set ver_min=0%ver_min:~1,1%
set ver_secs=%current_time:~6,2%
if "%ver_secs:~0,1%" == " " set ver_secs=0%ver_secs:~1,1%
set current_date=%date%
set ver_year=%current_date:~-4%
set ver_month=%current_date:~4,2%
if "%ver_month:~0,1%" == " " set ver_month=0%ver_month:~1,1%
set ver_day=%current_date:~7,2%
if "%ver_day:~0,1%" == " " set ver_day=0%ver_day:~1,1%
set datetimef=%ver_year%/%ver_month%/%ver_day%-%ver_hour%:%ver_min%:%ver_secs%
:: Format the date in YYYY\MM\DD-HH:MM:SS.ss
echo const char * build_time = ^"%datetimef%^" ; >> %VSS1_VERSION_FILENAME%
:: Get the output from a program into a local variable fo reuse later
:: Get the "git describe" information into a local variable GITVERSION
FOR /F "tokens=*" %%i in ('git describe --dirt^=*') do SET GITVERSION=%%i
:: Put the git version information into the file
echo const char * build_ver = ^"%GITVERSION%^" ; >> %VSS1_VERSION_FILENAME%
echo Created %VSS1_VERSION_FILENAME%
echo %datetimef%
echo %GITVERSION%
set VSS1_VERSION_FILENAME=
set GITVERSION=
set ver_hour=
set ver_min=
set ver_secs=
set ver_year=
set ver_month=
set ver_day=
set datetimef=
set current_time=
set current_date=
:: Make sure we exit cleanly to the calling batch script will continue
exit /b 1