Problems with batch file not halting on error

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems with batch file not halting on error

Jump to solution
2,263 Views
italiandoh
Contributor III
Hello,
I am using Codewarrior for Freescale MC9S12X family via batch file and not using the IDE.
I successfully created the batch file for compiling, linking and so on and it works OK, but with a problem. In case of a error during execution of compiler, the batch file in unable to detect this error and stop the process. This way we are forced to wait for the compilation of all files before stopping the process.
Of course we use the tool "Piper.exe" to capture the output of the various tools and save it to file and print it on screen.
Here's a sample of the batch file code :

for %%c in (%CTARGETS%) do (call %COMPILER_PATH%\piper.exe %COMPILER% %%c %COMPILER_OPTIONS%
                            IF %ERRORLEVEL% NEQ 0 goto error_label
                            echo.
                            echo.
                            echo.)

We use this for loop in the batch file to compile all the *.c source code files. But it seems like that, in case of compiler errors, the ERRORLEVEL variable is not set, so the for loop is not interrupted.
I guess that the problem is that piper.exe does not report any errors even if chc12.exe returned them.
Has anyone experienced such a problem ?
If anyone knows a possible solution for this, please let me know.
Thanks in advance and best regards,

Matteo
Labels (1)
Tags (1)
0 Kudos
1 Solution
484 Views
italiandoh
Contributor III

FYI, I solved the problem in my batches by checking for the creation of err.log after the compiling of each source file.

See this example:

 

echo.
for /R %CSOURCES_PATH% %%c in (*.c) do (call "%COMPILER_PATH%\piper.exe" %COMPILER% "%%c" %COMPILER_OPTIONS%
                            IF %ERRORLEVEL% NEQ 0 goto error_label
                            IF EXIST %PROJECT_ROOT%\err.log goto compiler_fault
                            echo.
                            echo.
                            echo.)

Bye,

 

Matteo

View solution in original post

0 Kudos
1 Reply
485 Views
italiandoh
Contributor III

FYI, I solved the problem in my batches by checking for the creation of err.log after the compiling of each source file.

See this example:

 

echo.
for /R %CSOURCES_PATH% %%c in (*.c) do (call "%COMPILER_PATH%\piper.exe" %COMPILER% "%%c" %COMPILER_OPTIONS%
                            IF %ERRORLEVEL% NEQ 0 goto error_label
                            IF EXIST %PROJECT_ROOT%\err.log goto compiler_fault
                            echo.
                            echo.
                            echo.)

Bye,

 

Matteo

0 Kudos