Alex Rivera | Logout

Delphi pre-build event not executing BEFORE compile

Asked 2010-01-18T16:12:27.283
14

I'm busy automating our builds to include the svn revision number. We're using Delphi 2010. I added a pre-build event calling a batch file that injects the the svn revision number (read from the entries file in the .svn directory) and a specified version number into aVersionInfo.rc that is compiled with my project. The pre-build event looks like this:

call SetVersionInfo.bat 6 5 4

...and the batch file (hope someone finds this useful)...

@ECHO OFF
SETLOCAL
setLocal EnableDelayedExpansion

SET _myVar=0
FOR /F %%G in (.svn\entries.) DO (
IF !_myVar! LSS 3 SET /A _myVar+=1 & SET _svn_dir_rev=%%G
)

ECHO 1 VERSIONINFO > aVersionInfo.rc
ECHO. FILEVERSION %1,%2,%3,%_svn_dir_rev%   >> aVersionInfo.rc
ECHO. PRODUCTVERSION 1   >> aVersionInfo.rc
ECHO. FILEOS VOS__WINDOWS32   >> aVersionInfo.rc
ECHO. FILETYPE VFT_APP   >> aVersionInfo.rc
ECHO. BEGIN   >> aVersionInfo.rc
ECHO.   BLOCK "StringFileInfo"   >> aVersionInfo.rc
ECHO.   BEGIN   >> aVersionInfo.rc
ECHO.     BLOCK "080904b0"   >> aVersionInfo.rc
ECHO.     BEGIN   >> aVersionInfo.rc
ECHO.       VALUE "CompanyName","COMPANY\000"   >> aVersionInfo.rc
ECHO.       VALUE "FileDescription","APP\000"   >> aVersionInfo.rc
ECHO.       VALUE "FileVersion","%1.%2.%3.%_svn_dir_rev%\000"   >> aVersionInfo.rc
ECHO.       VALUE "InternalName","APP\000"   >> aVersionInfo.rc
ECHO.       VALUE "LegalCopyright","Copyright APP\000"   >> aVersionInfo.rc
ECHO.       VALUE "LegalTrademarks","APP\000"   >> aVersionInfo.rc
ECHO.       VALUE "OriginalFilename","APP.exe\000"   >> aVersionInfo.rc
ECHO.       VALUE "ProductName","APP\000"   >> aVersionInfo.rc
ECHO.       VALUE "ProductVersion,"1\000"   >> aVersionInfo.rc
ECHO.       VALUE "Comments","Compiled on %date% by %username%\000"   >> aVersionInfo.rc
ECHO.     END   >> aVersionInfo.rc
ECHO.   END   >> aVer
Edit
Report

1 Answer

10

Try using

{$R aVersionInfo.res}

and calling brcc32 aVersionInfo.rc manually from your batch file (after you're done with creating the .rc file). That way your .res file should be excluded from the normal IDE build.

answered 2010-01-18T18:11:29.697

Your Answer