Keil编译脚本
文件内容
- 设置环境变量KEIL_TOOL指向keil安装路径的UV4.exe。(比如D:\Soft\Keil\UV4\UV4.exe)
- 其中"Target_D"和"Target_R"对应keil工程创建的Target名称。(可以根据自己的项目修改对应的名称)
@echo off
::Keil执行文件位置
set keil_tool=%KEIL_TOOL%
if "%keil_tool%"=="" (
echo ERROR: Keil tool chain not found, exit.
exit /B 1
)
:Step1
echo -----------------------------------------------
echo please select product to build
echo 0 CLEAN ALL
echo 1 Debug
echo 2 Release
echo q EXIT
set /p target=:
rem
if %target%==0 (
del /q /s .\Listings\* .\Objects\*
goto Step1
) else if %target%==1 (
set prj_target="Target_D"
) else if %target%==2 (
set prj_target="Target_R"
) else if %target%==q (
exit
) else if %target%==Q (
exit
)
set UV=%keil_tool%
set UV_PRO_FILE="uvprojx"
set UV_PRO_DIR=%cd%
for /f "usebackq delims=" %%j in (`dir /b "%UV_PRO_DIR%"\*."%UV_PRO_FILE%"`) do (
if exist %%j (
set UV_PRO_FILE_PATH="%UV_PRO_DIR%\%%j"
)
)
echo %UV%
echo %UV_PRO_DIR%
echo %UV_PRO_FILE_PATH%
echo Init building ...
echo .>build_log.txt
%UV% -j0 -r %UV_PRO_FILE_PATH% -t %prj_target% -o %cd%\build_log.txt
type build_log.txt
echo Done.
goto Step1
2023-07-25 李不清的烦恼,实用篇。