HC12: Forcing compiler to always compile source

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HC12: Forcing compiler to always compile source

2,916 Views
Lundin
Senior Contributor IV
I have a constant string in ROM containing the ANSI C constant __DATE__. I want to have the the file containing this constant to be automatically compiled every time I link the project, to get a relevant date code. Is this possible in some way? I don't wish to manually click on the file in the project window, since it is easy to forget.

Or is there another way to get a date stamp downloaded to the flash automatically?

I'm using CW3.1 for HCS12.

Message Edited by CrasyCat on 2007-04-13 01:55 PM

Labels (1)
Tags (1)
0 Kudos
6 Replies

517 Views
CompilerGuru
NXP Employee
NXP Employee
I think there is a batch burner postlinker plugin in
HC12 V3.1 (not 100% sure).
You could use a batch file like this:

echo // automatically generated date > date.c
echo const char date= "%DATE%"; >> date.c

(and then add ENTRIES date END to the prm file so it gets linked.
Daniel
0 Kudos

517 Views
Lundin
Senior Contributor IV
Thanks for your reply.

I'm not sure what you are suggesting, that I should use burner.exe in some way? I wish to avoid external programs, otherwise I could simply write a Windows prog that runs in the background and opens/saves the source file with the date every 10 minutes or so, since CW senses that the file has been changed by another program.

I was just wondering if there was any built-in support for this, since it must be a rather common wish to include compile/linking date info into one's program.

(And yep, I've got the variable in ENTRIES. The linker will pick an old date though, unless changes are made to the .obj file associated with the C file containing the date.)
0 Kudos

517 Views
CompilerGuru
NXP Employee
NXP Employee
Oh I used the wrong word.
I intended to say "batch runner postlinker". The burner.exe wont help much here.
Basically in the Target->Settings, in the Pre-linker or Post-linker tab you can choose to run additional tools, there is a BatchRunner PostLinker , which basically will execute a batch file after every linking phase.

Using the cmd file I preposed below is actually not the right thing, when I think about it as it would encode the data of when you last built the app in future builds, so it would always be off by invocation, so for example the batch file could touch the *.c file containing the __DATE__ macro.

Daniel
0 Kudos

517 Views
EmbeddedCoder
Contributor III
Hi There,
 
I am trying to achieve this too - so that each time the build is remade, a new time / date / version stamp is created automatically.
 
My intial thought was to create a DOS batch file that touched my file containing defines that had the __DATE__ & __TIME__ pragmas, thus forcing creation of a new string.
 
I have been trying to find a way to hook this into codewarriors build process - and it has been suggested, as on this thread (sorry - not sure how to post cross links to other threads - but I have a thread under Codewarrior general - search for "AutoTouch") , that the Post Linker is the way to go. However, the big problem with this is that the compilation has already taken place by this time, and so there needs to be a way to re-kick off a compilation - I assume there is a command line command to perform this but I haven't had the time to search for this!
 
Of course, this then means that anytime the "Debug" arrow is pressed, a new time and date build string is generated. This is not quite ideal - really what is needed is for the file to be touched only if the compiler has been run (i.e. code has changed). Is there a way of achieving this?
 
Many Thanks,
Mike
0 Kudos

517 Views
RoyAtRce
Contributor II

While this may be counter intuitive, the trick I am using is to delete the object file with the BatchRunner PostLinker.  This guarentees that the next time you Make the project the C file will be compiled and __DATE__ & __TIME__ will be updated.

Here is the contents of my PostLink.bat file

cd %CD%\..\Main_Data\Standard\ObjectCode
del SysInfo.c.o

 

 

0 Kudos

517 Views
Lundin
Senior Contributor IV
I think it might work if I delete the .o file associated with the .c file at the same time. I will give it a try, thanks for helping! :smileyhappy:
0 Kudos