IAR 命令行編譯

Introduction

This Technical Note shows examples of how to build an IAR Embedded Workbench project from the command line, outside the IDE.

Discussion

The alternatives below are examples made for IAR Embedded Workbench for Arm, but they can easily be modified for other target devices.

 

Alternative 1 - Run IarBuild.exe from the command line

If you have a project file named test.ewp with a configuration named Debug, the following command can be used to build the project:

<installation dir>\common\bin\IarBuild.exe test.ewp Debug

Note: Run IarBuild.exe without parameters to get usage information.

 

To rebuild the project, use the following command (extended with an option to log all compiler messages):

<installation dir>\common\bin\IarBuild.exe test.ewp -build Debug -log all

 The rebuild command above corresponds to:

<installation dir>\common\bin\IarBuild.exe test.ewp -clean Debug -log all
<installation dir>\common\bin\IarBuild.exe test.ewp -make Debug -log all

 

Alternative 2 – Compile and link from the command line

You can run all .exe files in the <installation directory>\arm\bin folder from the command line. Run each of them, for example iccarm.exe, without parameters to get a list of available command line options.

To automate the build process, it is possible to create a .bat file that compiles each source file separately. To see the command line parameters, select the following option in the IAR Embedded Workbench IDE:

Tools > Options > IDE Options > Messages > Show build messages: 'All'.

 

To create a .bat file that compiles one source file, enter the full path to iccarm.exe followed by the parameters (copied from the View > Messages > Build window):

<installation dir>\arm\bin\iccarm.exe <source-file> <options>

When you get the command working for one source file, you can add more commands in the .bat file for the remaining source files.

 

When you link, the command line option -f <file> might be useful. For example:

<installation dir>\arm\bin\ilinkarm.exe -f options.xcl

Place all the linker parameters from the Build window in the options.xcl file (make sure to place each parameter on a separate line). Because the linker command line in many cases might be very long, it is recommended to use the –f option to avoid any problems with command prompt line length.

 

Conclusion

It is possible to build IAR Embedded Workbench projects from the command line, using IarBuild.exe, or by invoking IAR C/C++ Compiler and ILINK Linker separately. To read more about command line building, see Help > IDE Project Management and Building Guide, under the heading Building from the command line.

 

原文地址:https://www.iar.com/support/tech-notes/general/build-from-the-command-line/

 

All product names are trademarks or registered trademarks of their respective owners.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章