最近我正在开展一些手臂项目,但没有操作系统
现在当我编译它时,我必须打开keil
但keil在编辑方面很弱,所以我正在考虑编写一个脚本来执行keil的编译,以构建项目。
但我对keil知之甚少,所以我想知道是否可能,以避免无用的工作。
感谢您的帮助。
答案 0 :(得分:4)
如无艺术噪音所述,您可以直接在命令行上调用armcc,或将其集成到make,scons等构建系统中。一个很好的起点是让Keil uVision为您创建一个批处理文件:CREATING A PROJECT BATCH FILE。 另一种可能性是从命令行调用Keil,将项目文件作为命令行参数,并使用选项来构建项目。Keil uV4 command line。 顺便说一下,我也使用这个命令行选项在模拟器中进行自动单元测试和闪存下载。
答案 1 :(得分:0)
这是我尝试编写Keil uVision4编译器的脚本。
Keil的Commandline interface自2011年以来基本上没有变化,而且非常有限-尤其是在构建服务器上使用编译器时。
此外,Keil uVision4编译器非常奇怪,不仅在创建输出时如此,而且在理论上支持两种方法-但是有时不创建任何方法,仅创建一个,另一个或两个输出文件。该批处理脚本尝试处理所有这些情况。
另一个问题是使用Flex许可证服务器时。该脚本允许您定义要重试构建的次数,并设置两次尝试构建之间的间隔。如果在构建期间突然撤消了许可证,它也可以成功恢复。
如果您对此脚本有补充,请在此处发布。
@echo off
setlocal
:: KeiluVisionBuilder.cmd
:: Written by Flemming Steffensen, 2019.
:: Free for use and abuse by anyone.
:: ======================
:: Configuration
set WaitForLicenseTimeout=60
set BuildAttemptsMax=10
set "ProjectFileName=bootloader.uvprojx"
set "ProjectPath=MyProject\bootloader\"
set "Compiler=C:\Keil_v5\UV4\UV4.exe"
set "OutFolder=out_585\"
:: ======================
:: Do not edit below this line
set BuildAttempt=0
pushd %ProjectPath%
:PerformBuild
echo:
echo:Performing Keil Build...
if exist build.log del build.log
if exist out_585\*.build_log.htm del %OutFolder%*.build_log.htm
start /wait %Compiler% -j0 -b %ProjectFileName% -o build.log
set ReportedError=%ERRORLEVEL%
:: Scan build.log to determine if the license is locked.
find /c "Error: *** All Flex licenses are in use! ***" build.log >nul
if %errorlevel% equ 0 (
set /a BuildAttempt=%BuildAttempt% + 1
echo:Error: *** All Flex licenses are in use!
if %BuildAttempt% equ %BuildAttemptsMax% goto NoLicenseAvailable
echo:Retrying ^(%BuildAttempt% of %BuildAttemptsMax%^) in %WaitForLicenseTimeout% seconds
waitfor SignalNeverComming /T %WaitForLicenseTimeout% >nul 2>&1
goto PerformBuild
)
:: Scan alternative build.log to determine if the license is locked.
find /c "Failed to check out a license" %OutFolder%*.build_log.htm >nul
if %errorlevel% equ 0 (
set /a BuildAttempt=%BuildAttempt% + 1
echo:Error: Failed to check out a license
if %BuildAttempt% equ %BuildAttemptsMax% goto NoLicenseAvailable
echo:Retrying ^(%BuildAttempt% of %BuildAttemptsMax%^) in %WaitForLicenseTimeout% seconds
waitfor SignalNeverComming /T %WaitForLicenseTimeout% >nul 2>&1
goto PerformBuild
)
goto NoLicenseProblem
:NoLicenseAvailable
echo:Error: After %BuildAttempt% attempts, the Flex license still appear to be unavailable. Failing the build!
echo:
popd
exit /b 1
:NoLicenseProblem
:: Parse exit codes
set KnownErrors=0 1 2 3 11 12 13 15 20 41
echo:Kiel compiler exited with error code %ReportedError%
for %%a in (%KnownErrors%) do (
if [%ReportedError%] equ [%%a] goto Error%ReportedError%
)
goto UnknownError
:Error0
echo Compilation successful
goto ExitButContinueJob
:Error1
echo Warnings were found
goto ExitButContinueJob
:Error2
echo Errors were found
goto ExitCritical
:Error3
echo Error 3 = Fatal Errors
goto ExitCritical
:Error11
echo Error 11 = Cannot open project file for writing
goto ExitCritical
:Error12
echo Error 12 = Device with given name in not found in database
goto ExitCritical
:Error13
echo Error 13 = Error writing project file
goto ExitCritical
:Error15
echo Error 15 = Error reading import XML file
goto ExitCritical
:Error20
echo Error 20 = Can not convert the project file.
goto ExitCritical
:Error41
echo Error 41 = Can not create the logfile requested using the -l switch.
goto ExitCritical
:UnknownError
echo Error %ReportedError% = Unknown error
goto ExitCritical
:ExitCritical
echo:
if [%ReportedError%] neq 0 exit /b %ReportedError%
:ExitButContinueJob
echo:
popd
exit /b 0