Hello all
I'd like to use a windows batch-file (preBuild.bat) as pre-build script. If the preBuild.bat detects an error, the build process should be stopped. This works perfectly if the pre-build "script" is a regular .exe, returning a non zero value.
However, I am not successful when returning a non zero value using the preBuild.bat batch file.
I tried to use
exit 1
in the .bat file, but uVision seems to ignore the return value of .bat files.
Any ideas?
Thanks & regards, Martin
Does this help:
www.vistax64.com/.../91448-get-exit-code-batch-file.html
Unfortunately not.
I also tried but without success:
cmd /c exit /b 1
and
exit /b 1
Keil just keeps building.
windows batch-file (preBuild.bat)
To some extent that's a contradiction. *.bat files are DOS batch files, really. CMD.exe will run those, too, sure, but proper Windows batch files (on those versions of Windows that actually support current uVision) are supposed to be named *.cmd.
Now, that distinction would usually be moot. But there's just this far-off possibility that uVision might know about one of the major show-stopping shortcomings of actual DOS batch files: they cannot return an exit status. Command.com always finishes with exit status 0 no matter what. The optional "[Exitcode]" argument to CMD.exe's "exit" ia a Windows extension.
So, assuming that uVision embodies this knowledge, they would be somewhat justified to ignore any exit code from a *.bat script. Maybe you should try making that a *.cmd script instead.
Might be worth contacting Keil Support on this one...
Thanks Hans-Bernhard for this comment, didnt know that...
Unfortunately, renaming the script to *.cmd instead of *.bat didnt help. I'll try contacting keil support tomorrow.
Regards, martin
.. checking exit codes is sequence critical i.e. (as I do not recall) only one of these work
if == 0 if == 1
or if == 1 if == 0
Erik
Just received the answer from Keil Support: Dear Martin,
you are right, also calling a script via "cmd /C" which returns an error level code => 1 will not stop the build process. When using a exe file the evaluation of the error level code works as expected. I will talk to our development team if this is intended (guess not) and will try to get it fixed with the next version.
Please be patient! I'll keep you posted.
I'm still interested if someone comes up with a smart workaround.
Could this be a Windows Command Processor limitation, rather than a uVision problem?
Does anyone know if this issue has been resolved in the current release of uVision?