Files
STM32F4-Base/MDK-ARM/build.bat
T

44 lines
1.4 KiB
Batchfile

@echo off
setlocal
set UV4=C:\Keil_v5\UV4\UV4.exe
set PROJ=%~dp0STM32F407-Demo.uvprojx
set LOG=%~dp0build_log.txt
set TARGET=STM32F407-Demo
:: UV4 is single-instance: if an IDE process is alive, this -b call may be
:: forwarded to it (exit code is lost, GUI may open). Warn only; never kill.
tasklist /fi "imagename eq UV4.exe" /nh | find /i "UV4.exe" >nul
if not errorlevel 1 echo WARNING: UV4 IDE is running - this build may be forwarded to the IDE. Close it for a deterministic CLI build.
:: Remove stale log first: UV4 -o writes the log only when a build actually
:: runs. A leftover log would otherwise be misreported as this build's result.
if exist "%LOG%" del "%LOG%"
"%UV4%" -b "%PROJ%" -t%TARGET% -j0 -o "%LOG%"
if not exist "%LOG%" (
echo BUILD_FAIL: no build log produced - UV4 did not run or hung
exit /b 1
)
:: Error diagnostics in the log: ARMCC V5 "file(line): error: #NN" and
:: "no source: Error: #5" both contain "error:"; a 0E0W log never does.
findstr /I /C:"error:" "%LOG%" >nul
if not errorlevel 1 (
echo BUILD_FAIL: error diagnostics in build log
type "%LOG%"
exit /b 1
)
:: Success proof: exact 0E0W summary line (also rejects warning-only builds).
findstr /C:"0 Error(s), 0 Warning(s)" "%LOG%" >nul
if errorlevel 1 (
echo BUILD_FAIL: no 0E0W marker in build log
type "%LOG%"
exit /b 1
)
echo BUILD_OK: 0 errors, 0 warnings
exit /b 0