回植 v2 分支 build.bat 防假成功修复(日志内容三重判定 + UV4 单实例告警)
This commit is contained in:
+31
-7
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user