2

In IAR embedded workbench IDE, I need to force the compilation of a file, every time I build the project (in order to recompile __DATE__ and __TIME__).

So I need to "touch" that file (i.e., delete the corresponding object file).

I went into the project options --> C/C++ Compiler --> Extra Options --> Use command line options.

In there, I entered a shell command for deleting that file, but without luck. I tried several different ways of doing it, including to call a batch file. Examples:

  1. del "$OBJ_DIR$\mng_version.o"

  2. cmd /c "del "$OBJ_DIR$\mng_version.o""

  3. pre_build.bat

None of these worked. Does anybody have any idea how to do this?

wovano
  • 4,543
  • 5
  • 22
  • 49
barak manos
  • 29,648
  • 10
  • 62
  • 114

1 Answers1

1

I use

Project options -> Build Actions 

and enter a command into the Pre-build command line. This can be a batch file invocation. I have a utility that increments a build number declaration in a version file that is then re-compiled on every build.

This is the same on the MSP-430, ARM and Atmel AVR-32 versions of the IAR toolset.

uɐɪ
  • 2,540
  • 1
  • 20
  • 23
  • Thank you. May I just add, that in order to be able to locate the batch file alongside the project (i.e., in the same path), I needed to add '$PROJ_DIR$\' before the batch file name. Also, in order to have the batch file performing an action on a file within my project, I needed to pass '$PROJ_DIR$\' as an argument to the batch file, and to use it as '%1\' inside the batch file. – barak manos Sep 28 '13 at 08:15