@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%" -r "%PROJ%" -t%TARGET% -j0 -o "%LOG%"
set RET=%ERRORLEVEL%

if %RET% equ 0 (
    echo BUILD_OK: 0 Error(s), 0 Warning(s)
) else (
    echo BUILD_FAIL: exit code %RET%
    if exist "%LOG%" type "%LOG%"
)

exit /b %RET%
