Always build a file


Is it possible to set the options for a particular source file so that it always gets recompiled, even if it hasn’t changed since the last build? I have a file that uses the TIME and DATE macros, but unless I make changes to that file or do a clean build, these values never get updated. If I right-click on a file in the project explorer and select properties, I can find an option to exclude the file from the build, but I can’t see anything for making sure it gets compiled every time.


Me too: viewtopic.php?f=19&t=495&hilit=+always+build+timestamp


I hadn’t seen your post, and you make an interesting point. I’m going to reply here, as I think that M2M requires a specific solution.

You mentioned using the Unix “touch” command. Windows also has this command, which you could speicify as a pre-build command. However this doesn’t work, as M2M doesn’t compile files based on their last modified date, but on the date it thinks they were last modified, and there is a subtle differerence between the two.

Say I have two files called workInProgress.c (code I’m actively working on), and buildDate.c (contains my macros, and isn’t being changed), both files are open in M2M. I make some changes to workInProgress.c and save it. When the build process starts, workInProgress. c is compiled, buildDate.c isn’t.

If I change workInProgress.c, then “touch” buildDate.c before the build starts, still only workInProgress.c is compiled.

However, if I “touch” buildDate.c, then switch to its tab in M2M, M2M sees the new timestamp, and asks if I want to reload the file. If I say yes, buildDate.c is compiled.

M2M is obviously keeping track of file modification internally, then uses this to decide which files to build, rather than actually checking which files have changed. :imp:


Why would you want to recompile an unchanged file in the first place? Maybe if you tell us more on your problem, there could be another solution…

Best regards,



As I said above, the file uses the TIME and DATE macros. These macros are defined by the compiler, to have the current time and date respectively at the time the file is compiled. If the file does’t get recompiled when you change other files, then the old values from the existing object file get linked into the executable. This means the values represent the date and time that file was last built, not the date and time the application last changed.


That’s why! 8)


It was a long time ago!

The original post was long before M2M Studio - and the tools then didn’t give a facility for pre-build commands. :frowning:


Sorry, I obviously overlooked that. I thought of a method, but it is a bit unorthodox to say the least. I also haven’t tried it, but in theory it should work. So here it is:
M2MStudio seems to invoke the compiler by calling:


Notice that it doesn’t use the .exe extension, so in theory one could replace arm-elf-gcc.exe in the zip file by a custom arm-elf-gcc.bat which first “touches” the required file and the invokes the normal arm-elf-gcc.exe (which will have to be renamed).

If you try it I’d be interested to hear whether it works.

Since M2MStudio determines which files to compile before launching the compiler, you will probably have to compile twice.

Best regards,



How would that be different to using the pre-build command option in M2M? M2M provides the compiler with the list of files that it thinks should be built. M2M only checks the file timestamp when opening a file or switching to its editor tab, so won’t notice the change until you specifically interact with that file through M2M.


That seems bizarre, and unnecessarily complicated. :open_mouth:
Is this normal Eclipse behaviour, or have Anyware gone out of their way to do this?


In Project Properties > C/C++ Build > Settings > Build steps, you can set a commands to be invoked before/after the build.
Unfortunately, it seems that if you touch .c files thanks to these steps, they are not seen as modified by M2M Studio, untill you press F5 in the explorer, or open the editor… :confused:

I had the same issue with simple CDT projects, it seems to be an Eclipse bug. I had a workaround, by adding a builder (Ant script or external program) through Project properties > Builders. But this property page does not exist under M2M Studio :frowning:


Another reason why M2M should check the file timestamp is version control. If I do a CVS update to bring another colleague’s changes into my sandbox, then hit build, M2M won’t care that some files have changed, because they were changed externally. This forces me to do a clean build, which requiers building every file (fortunately M2M is literally 100 times faster at compiling than the old IDE).


So it sounds like somebody has specifically chosen to implement it this way - rather than the “normal” way! :open_mouth:

Why on earth would someone do that?! :open_mouth: :open_mouth:


On this point, I think it’s possible to install Eclipse CVS client in M2M Studio: in this case the update will be “seen” and the build will be performed…


As far as I can see, the Eclipse CVS client is shipped with Eclipse, and as such is not available as a separate download. I know M2M is based on Eclipse, but does it officially support standard Eclipse plugins?


Regarding the architecture of Eclipse, I think there is no problem with installing additional plug-ins in M2M Studio.

Actually it is available: I made the test and it works.
You have to download it from the update site, thanks to the Help > Software Updates menu in M2M Studio.


Hi all,

it seems that the 1.0.1 release fulfills our needs…

  • Plug-ins for CVS/SVN repositories connection are now integrated
  • The builders property page I talked about is back: I haven’t made the test yet, but it should be possible now to invoke a touch command as an external tool, and force a workspace refresh prior to launch the M2M Studio build.


This thread seems to have got somewhat side-tracked into CVS issues.

Meanwhile, back at the original issue, I think that M2MStudio still needs a way to mark a file as ‘Always Build’


I have a functional workaround for that:

  • get touch.exe from somewhere on the Internet (I don’t remember where I’ve found mine, but it’s easy to find)
  • On your projet properties page, go to the Builders page
  • Create a New builder, name it as you want
  • For program location, put the absolute path to touch.exe (if you want to persist your project settings in SCM, you should use an environment variable)
  • For arguments, put the location of the file you want to touch, relative to the ${project_loc} variable (e.g. ${project_loc}/src/timestamp.c)
  • On the Refresh tab, click the checkbox for refresh after completion, and select the “project containing selected resource” option
  • Finally, back to the Builders page, put your builder on top of the list thanks to the Up button, in order to touch and refresh prior to launch the C compilation.

And it just works: as soon as you trigger a manual build, the wanted file is always rebuilt.


Any chance of getting this properly built-in in the next release?