VScode 编译IAR工程
前言
利用VSCode的终端直接编译已经创建好的IAR工程,网上很多教程都是通过VSCode 的插件进行IAR工程编译。下面说一种不通过插件的方式,直接通过VSCode的终端进行编译的方式。
一、准备工作
- 安装好IAR这个IDE,如何安装网上很多教程
- 设置环境变量
iarbuild.exe目录
- 写好编译脚本,这个比较简单
二、使用步骤
1.bat批处理文件
批处理文件使用到的指令如下:
iarbuild [-clean | -build | -make | -cstat_analyze | -cstat_clean]
[-log errors|warnings|info|all] [-parallel ] [-varfile ]
Parameter: Description:
Your IAR Embedded Workbench project file (project.ewp).
-clean Removes any intermediate and output files.
-build Rebuilds and relinks all files in the current
build configuration.
-make Brings the current build configuration up to date
by compiling, assembling, and linking only the files
that have changed since the last build.
-cstat_analyze Analyzes the project using C-STAT and generates
information about the number of messages.
For more information, see the C-STAT Static Analysis Guide.
-cstat_clean Cleans the C-STAT message database for the project.
For more information, see the C-STAT Static Analysis Guide.
The name of the configuration you want to process,
which can either be one of the predefined configurations
Debug or Release, or a name that you define yourself.
By using a comma separated list it is possible to
process multiple configurations.
Using * (wild card character), all configurations
defined in the project will be processed.
-log errors Display build error messages.
-log warnings Display build warning and error messages.
-log info Display build warning and error messages, and messages
issued by the #pragma message preprocessor directive.
-log all Display all messages generated from the build,
for example compiler sign-on information and the
full command line.
-parallel Specifies the number of parallel processes to run the
compiler in to make better use of the cores in the CPU.
-varfile Makes custom argument variables defined in a workspace
scope available to the build engine by specifying the
file to use.
示例:
iarbuild.exe example\uart\uart_int\EWARM\uart_int.ewp -%1 debug -log info -parallel 4
简单来说就是调用iarbuild.exe,后面跟着IAR工程名,接着一些配置,其中%1表示输入的参数可以是build、make、clean,debug表示编译debug的版本,这个参数如下图设置,选择需要编译的。
这里不做其他详细介绍,目前有些东西也在摸索中。
为了方便我直接将批处理文件放在了VSCode打开的文件夹路径下,这个路径可以随便放,我的如下:
2.使用方法
- VSCode通过CTRL + ~打开终端,如下图,我打开后是下面界面
- 调用批处理文件,使用参数使用的build
- 编译完成
三 、对比使用VSCode插件编译
我使用的是IAR build这个插件,通过这个插件,编译出来的与使用批处理编译出来是一样的
总结
主要是记录下使用方法,有什么不对的地方,请大家指正,谢谢!