用bat脚本编译keil工程

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 李不清的烦恼,实用篇。

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值