博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IAR USING PRE- AND POST-BUILD ACTIONS
阅读量:5834 次
发布时间:2019-06-18

本文共 3425 字,大约阅读时间需要 11 分钟。

Using pre-build actions for time stamping

If necessary, you can specify pre-build and post-build actions that you want to occur before or after the build. 

The Build Actions dialog box—available from the Project menu—lets you specify the actions required.

For more information about the Build Actions dialog box, see Build actions options, page 215.

Using pre-build actions for time stamping

You can use pre-build actions to embed a time stamp for the build in the resulting binary file. Follow these steps:

1 Create a dedicated time stamp file, for example, timestamp.c and add it to your project.
2 In this source file, use the preprocessor macros __TIME__ and __DATE__ to initialize a string variable.
3 Choose Project>Options>Build Actions to open the Build Actions dialog box.
4 In the Pre-build command line text field, specify for example this pre-build action:
cmd /c "del "$OBJ_DIR$\timestamp.o""
This command removes the timestamp.o object file.
Alternatively, you can use the open source command line utility touch for this purpose 
or any other suitable utility that updates the modification time of the source file. For example:
"touch $PROJ_DIR$\timestamp.c"
5 If the project is not entirely up-to-date, the next time you use the Make command,
the pre-build action will be invoked before the regular build process.
Then the regular build process must always recompile timestamp.c and
the correct timestamp will end up in the binary file.

If the project already is up-to-date, the pre-build action will not be invoked.

This means that nothing is built, and the binary file still contains the timestamp for when it was last built.

 

ADDING AN EXTERNAL TOOL

The following example demonstrates how to add the tool Flex to the toolchain.

Thesame procedure can be used also for other tools.

In the example, Flex takes the file myFile.lex as input. The two files myFile.c and myFile.h are generated as output.

1 Add the file you want to work with to your project, for example myFile.lex.
2 Select this file in the workspace window and choose Project>Options. Select Custom Build from the list of categories.
3 In the Filename extensions field, type the filename extension .lex. Remember to specify the leading period (.).
4 In the Command line field, type the command line for executing the external tool, for example

flex $FILE_PATH$ -o$FILE_BNAME$.c

During the build process, this command line is expanded to:

flex myFile.lex -omyFile.c

Note the usage of argument variables.

Note specifically the use of $FILE_BNAME$ which gives the base name of the input file,

in this example appended with the c extension to provide a C source file in the same directory as the input file foo.lex.

For more information about these variables, see Argument variables, page 71.

5 In the Output files field, describe the output files that are relevant for the build.
In this example, the tool Flex would generate two files—one source file and one header file.
The text in the Output files text box for these two files would look like this:
$FILE_BPATH$.c
$FILE_BPATH$.h
6 If the external tool uses any additional files during the build, these should be added in the Additional input files field, for instance:
$TOOLKIT_DIR$\inc\stdio.h
This is important, because if the dependency files change, the conditions will no longer be the same and the need for a rebuild is detected.
7 Click OK.
8 To build your application, choose Project>Make.

 

 

 

转载地址:http://kzucx.baihongyu.com/

你可能感兴趣的文章
新开的博客,为自己祝贺一下
查看>>
采用JXL包进行EXCEL数据写入操作
查看>>
将txt文件转化为json进行操作
查看>>
线性表4 - 数据结构和算法09
查看>>
我的2014-相对奢侈的生活
查看>>
Java设计模式
查看>>
Spring Cloud 微服务分布式链路跟踪 Sleuth 与 Zipkin
查看>>
ORM数据库框架 SQLite 常用数据库框架比较 MD
查看>>
华为OJ 名字美丽度
查看>>
微信公众号与APP微信第三方登录账号打通
查看>>
Windows 下最佳的 C++ 开发的 IDE 是什么?
查看>>
软件工程师成长为架构师必备的十项技能
查看>>
python 异常
查看>>
百度账号注销
查看>>
mysql-This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME 错误解决
查看>>
BIEE Demo(RPD创建 + 分析 +仪表盘 )
查看>>
Cocos2dx 3.0开发环境的搭建--Eclipse建立在Android工程
查看>>
基本概念复习
查看>>
重构第10天:提取方法(Extract Method)
查看>>
Android Fragment使用(四) Toolbar使用及Fragment中的Toolbar处理
查看>>