Delphi 5 IDE command-line return codes
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 batc开发者_如何学运维h 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
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.
精彩评论