Problems with batch file not halting on error

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problems with batch file not halting on error

ソリューションへジャンプ
2,820件の閲覧回数
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
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,041件の閲覧回数
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 件の賞賛
返信
1 返信
1,042件の閲覧回数
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 件の賞賛
返信