首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有一种方法可以用一些脚本来构建arm项目呢?

有没有一种方法可以用一些脚本来构建arm项目呢?
EN

Stack Overflow用户
提问于 2013-12-09 11:00:09
回答 2查看 3.8K关注 0票数 3

最近我在做一个带有arm的项目,但里面没有操作系统。

现在,当我编译它时,我必须打开keil。

但是keil在编辑方面很薄弱,所以我正在考虑编写一个脚本来执行keil的编译器,来构建这个项目。

但是我对基尔知之甚少,所以我想知道它是否具有,以避免无用的工作。

谢谢你的帮助。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-12-11 20:20:43

正如artless噪声所提到的,您可以在命令行上直接调用armcc,或者将其集成到一个构建系统中,如make、scon等。一个很好的起点是让Keil uVision为您创建一个批处理文件:创建项目批处理文件。另一种可能是使用项目文件作为命令行参数从命令行调用Keil,并提供构建项目.Keil uV4命令行的选项。顺便说一句,我还使用这个命令行选项,用于模拟器中的自动单元测试和flash下载。

票数 6
EN

Stack Overflow用户

发布于 2019-03-22 14:02:03

编辑2021:

重新讨论这个答案,因为Kiel还没有改进他们的命令行工具。

  • 修改了脚本中的一个小错误。
  • 修正了指向Kiel命令行文档的链接。
  • 将脚本添加到Github gist中,这样就更容易分叉了。

2019年原答复:

下面是我为Keil uVision4编译器编写脚本的尝试。

Keil的命令行接口基本上从2011年起就没有变化,而且它是非常有限的--尤其是在构建服务器上使用编译器。

此外,Keil uVision4编译器非常奇怪,尤其是在创建输出时,但理论上支持两种方法--但是有时不支持,只创建一个,另一个,或者同时创建两个输出文件。这个批处理脚本试图处理所有这些情况。

另一个问题是何时使用Flex许可证服务器。此脚本允许您定义要重试生成的次数并设置尝试构建之间的间隔。如果在构建过程中突然撤回许可证,它也会成功地恢复。

如果你有这个脚本的附加内容,请在这里张贴。

代码语言:javascript
复制
@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=OutputFolderDefinedIn_MyProject\"
::
:: ======================
:: 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 %OutFolder%*.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
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20468910

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档