From 6ebdb1472423ebcdcb9933b7d34f9c881a5048c2 Mon Sep 17 00:00:00 2001 From: Wanderingss <1624155937@qq.com> Date: Sat, 19 Sep 2026 20:07:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E6=A4=8D=20v2=20=E5=88=86=E6=94=AF=20?= =?UTF-8?q?build.bat=20=E9=98=B2=E5=81=87=E6=88=90=E5=8A=9F=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=EF=BC=88=E6=97=A5=E5=BF=97=E5=86=85=E5=AE=B9=E4=B8=89?= =?UTF-8?q?=E9=87=8D=E5=88=A4=E5=AE=9A=20+=20UV4=20=E5=8D=95=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E5=91=8A=E8=AD=A6=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MDK-ARM/build.bat | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/MDK-ARM/build.bat b/MDK-ARM/build.bat index 98d86c7d..938c1e56 100644 --- a/MDK-ARM/build.bat +++ b/MDK-ARM/build.bat @@ -6,14 +6,38 @@ 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%" -findstr /C:"0 Error(s), 0 Warning(s)" "%LOG%" >nul -if %ERRORLEVEL% equ 0 ( - echo BUILD_OK: 0 errors, 0 warnings - exit /b 0 +if not exist "%LOG%" ( + echo BUILD_FAIL: no build log produced - UV4 did not run or hung + exit /b 1 ) -echo BUILD_FAIL: no success marker in log -type "%LOG%" -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