views:

298

answers:

1

I am attempting to automate some legacy Delphi 5 builds with an MSBuild script, and am having trouble capturing errors. Thinking there was some issue with the MSBuild passing, I also tried a batch file and am still receiving back passes (0) when the build should fail (1). %2 is the path to delphi and %3 is the project name.

REM delphi_ide_build.bat
@ECHO OFF
"%1 %2\Bin\delphi32.exe" %3.dpr -b

REM BCB5 returns 0 if build succeeds, 1 if build fails
IF ERRORLEVEL 1 GOTO FAIL
IF ERRORLEVEL 0 GOTO PASS

:FAIL
ECHO An Error Occured in Build - Showing Log
ECHO ---------------------------------------
type %3.err
EXIT 1

:PASS
ECHO The Build Passed - Showing Log
ECHO ------------------------------
type %3.err
EXIT 0

According to the online help:

The Error Level is set to 0 for successful builds and 1 for failed builds.

Currently my project fails (visible in the log file) but my batch file runs as a PASS.

[Fatal Error] MyFile.pas(43): File not found: 'aa.dcu'

Is this a bug in Delphi 5, or am I missing something?


Full IDE help text for option -B on delphi32.exe:

AutoBuild. Must be used with the filename option. When specified, the project or project group is built automatically when the IDE starts. Any hints, errors, or warnings are then saved to a file. Then the IDE exits. This facilitates doing builds in batch mode from a batch file. The Error Level is set to 0 for successful builds and 1 for failed builds. By default, the output file has the same name as the filename specified with the file extension changed to .err. This can be overridden using the o option

+5  A: 

The only help refers to the command line compiler dcc32.exe and not the IDE.

Replacing the delphi32.exe by dcc32.exe should solve your problem.

Andreas Hausladen
I took the quote from the help file of the IDE:IDE command-line options delphi32.exeProject options - option b.
Rob Hunter
While you may be right about the help indicating command line options for the IDE, you would probably be much better changing your script to use the dcc32.exe command line compiler directly as Andreas suggests.There are many people using dcc32.exe for automated builds for many versions of Delphi. Indeed the licensing changed in later versions of Delphi to explicitly allow the installation of the command line compiler on multiple PCs for the explicit purpose of doing command line builds.
Conor Boyd
I was originally trying to cut down on the time to automate. If I switch to dcc32 are there any pointers to retaining the build properties that the developers have set in the IDE? There are also a few environment settings that I would need to include.
Rob Hunter
You'll need to adjust dcc32.cfg for global environment settings. Other than that, you should be fine.
Lieven