Build: Don't rewrite svnrev.h unconditionally

Stops VS from recompiling the files which include it every time you hit
run.
This commit is contained in:
Connor McLaughlin 2022-05-28 15:21:14 +10:00 committed by refractionpcsx2
parent 1bb86d8984
commit 5ef159876a
1 changed files with 14 additions and 3 deletions

View File

@ -38,6 +38,16 @@ set REV2=%REV3: =%
set REV1=%REV2:-=% set REV1=%REV2:-=%
set REV=%REV1::=% set REV=%REV1::=%
SET SIGNATURELINE=// H[%GIT_HASH%] T[%GIT_TAG%]
SET /P EXISTINGLINE=<"%CD%\svnrev.h"
IF "%EXISTINGLINE%"=="%SIGNATURELINE%" (
goto cleanup
)
ECHO Updating "%CD%\svnrev.h"...
echo %SIGNATURELINE%> "%CD%\svnrev.h"
git show -s > NUL 2>&1 git show -s > NUL 2>&1
if %ERRORLEVEL% NEQ 0 ( if %ERRORLEVEL% NEQ 0 (
echo Automatic version detection unavailable. echo Automatic version detection unavailable.
@ -46,7 +56,7 @@ if %ERRORLEVEL% NEQ 0 (
echo or in your PATH. echo or in your PATH.
echo You can safely ignore this message - a dummy string will be printed. echo You can safely ignore this message - a dummy string will be printed.
echo #define SVN_REV_UNKNOWN > "%CD%\svnrev.h" echo #define SVN_REV_UNKNOWN >> "%CD%\svnrev.h"
echo #define SVN_REV 0ll >> "%CD%\svnrev.h" echo #define SVN_REV 0ll >> "%CD%\svnrev.h"
echo #define GIT_REV "" >> "%CD%\svnrev.h" echo #define GIT_REV "" >> "%CD%\svnrev.h"
echo #define GIT_HASH "" >> "%CD%\svnrev.h" echo #define GIT_HASH "" >> "%CD%\svnrev.h"
@ -56,7 +66,7 @@ if %ERRORLEVEL% NEQ 0 (
:: Support New Tagged Release Model :: Support New Tagged Release Model
if [%GIT_TAG%] NEQ [] ( if [%GIT_TAG%] NEQ [] (
echo Detected that the current commit is tagged, using that! echo Detected that the current commit is tagged, using that!
echo #define SVN_REV %REV%ll > "%CD%\svnrev.h" echo #define SVN_REV %REV%ll >> "%CD%\svnrev.h"
echo #define GIT_REV "" >> "%CD%\svnrev.h" echo #define GIT_REV "" >> "%CD%\svnrev.h"
echo #define GIT_HASH "%GIT_HASH%" >> "%CD%\svnrev.h" echo #define GIT_HASH "%GIT_HASH%" >> "%CD%\svnrev.h"
echo #define GIT_TAG "%GIT_TAG%" >> "%CD%\svnrev.h" echo #define GIT_TAG "%GIT_TAG%" >> "%CD%\svnrev.h"
@ -72,7 +82,7 @@ if %ERRORLEVEL% NEQ 0 (
echo #define GIT_TAGGED_COMMIT 1 >> "%CD%\svnrev.h" echo #define GIT_TAGGED_COMMIT 1 >> "%CD%\svnrev.h"
) else ( ) else (
echo #define SVN_REV %REV%ll > "%CD%\svnrev.h" echo #define SVN_REV %REV%ll >> "%CD%\svnrev.h"
echo #define GIT_REV "%GIT_REV%" >> "%CD%\svnrev.h" echo #define GIT_REV "%GIT_REV%" >> "%CD%\svnrev.h"
echo #define GIT_HASH "%GIT_HASH%" >> "%CD%\svnrev.h" echo #define GIT_HASH "%GIT_HASH%" >> "%CD%\svnrev.h"
echo #define GIT_TAG "" >> "%CD%\svnrev.h" echo #define GIT_TAG "" >> "%CD%\svnrev.h"
@ -80,6 +90,7 @@ if %ERRORLEVEL% NEQ 0 (
) )
) )
:cleanup
ENDLOCAL ENDLOCAL
:: Always return an errorlevel of 0 -- this allows compilation to continue if SubWCRev failed. :: Always return an errorlevel of 0 -- this allows compilation to continue if SubWCRev failed.
exit /B 0 exit /B 0