Forcing Codewarrior to build a file on each compilation - "AutoTouch"

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Forcing Codewarrior to build a file on each compilation - "AutoTouch"

4,923 次查看
EmbeddedCoder
Contributor III
Hi All,
 
I'm using Codewarrior V5.5 with a HC12 target, but I think my question is pretty generic.
 
I want to be able to force a file to be re-compiled each time I re-compile my project, but I don't want the hassle of having to remember to manually "touch" that file (I'm bound to forget one time, and then my build details will be out of date!!).
 
Basically, I am trying to update the date and time string that is subsequently stored as the build details, this can be done by forcing the compiler to recompile a header with __TIME__ and __DATE__ defines within it. I have created a DOS batch file that will touch my file for me, but can't find any way of hooking this into the Metrowerks compile process - there must be a way, I just can't find a reference in the help file!?!
 
Has anyone else done this?
 
Thanks for your help.
标签 (1)
0 项奖励
回复
5 回复数

2,023 次查看
J2MEJediMaster
Specialist I
In the project's Target Settings panel, there's an option to execute a process prior to linking (the Pre-linker pull-down menu). Pull down this menu and select Batchrunner Prelinker. A Batchrunner Prelinker panel appears in the list of Settings panels. Select this panel, and use it to navigate to the desired batch file that will be executed just prior to the link process. I'm not clear on what your batch file does, but in all likelyhood you'll have to add a command line to compile the source file that you touched, because by this stage the compile stage will be finished.

The solution might sound klunky, but:

1) That's the only hook I see easy available (unless you want to write Tcl or Perl scripts), and
2) The file's compilation becomes part of the build automation, which is what you're trying to accomplish.

---Tom


0 项奖励
回复

2,023 次查看
EmbeddedCoder
Contributor III
Thanks for the swift reply!
 
I did try this, but forgot that of course the compilation was finished!! How do you invoke the compiler from the command line?
 
Also, am I missing an obvious way of doing this - I would have thought that this was a feature many engineers want to make use of to ensure time and date stamps of builds are remembered - is there another easier way of "touching" a file automatically prior to compilation - or altering dependencies manually to ensure alteration to any file in the project causes compilation of the "master" file?
 
Thanks,
Mike
0 项奖励
回复

2,023 次查看
CrasyCat
Specialist III
Hello
 
Please look at following thread:
 
 
CompilerGuru is providing a way to achieve that. This should work with any CodeWarrior installation having the BatchBurner postLinker linker available 
 
CrasyCat
0 项奖励
回复

2,023 次查看
J2MEJediMaster
Specialist I
If Crasycat's pointer didn't help, here's the scoop on compiling from the command line. All of the command-line modules are in the sub-directory \prog within the CodeWarrior directory. HCH12.exe is the compiler. Knowing this we can write a command line invocation program.

Assume that the path to the CodeWarrior directory is "C:\Program Files\Freescale\CW for HC12 V4.5\".
Also assume that within CodeWarrior is the sub-directory MyPWMChannel0\Sources\, with a source file of Start12.c. This is the file we want to compile.

Now we write:

Code:
"C:\Program Files\Freescale\CW for HC12 V4.5\prog\chc12.exe" MyPWMChannel0\Sources\Start12.c -I"C:\Program Files\Freescale\CW for HC12 V4.5\lib\hc12c\include" -Mb -CpuHCS12 -WmsgFbv -WmsgFob"%f%e(%l): %k %d: %m\n"REM pause

 The -I options points to the include files directory. -Mb is for banked memory, and -CpuHCS12 doesn't need an explanation. The weird-looking -W options have the compiler emit verbose error messages into an error file--something you really want to have happen while debugging the batch file code.

I placed this into the Pre-Linker option of the Target Mode window, and it built the file, so it appears to work.

As for why this is so difficult, I don't know. I think you can mark a file as dirty using Tcl or Perl, but I don't understand any of the particulars. There are some scripting examples in the (CodeWarrior Examples) sub-directory, but I don't think they're applicable to you situation.

---Tom




Message Edited by J2MEJediMaster on 2007-09-04 10:56 PM
0 项奖励
回复

2,023 次查看
EmbeddedCoder
Contributor III
Thanks for your help!
 
The compiler didn't seem to like the -Cpu option and I was concerned that the settings used wouldn't give the right results, so I ticked the "Show generated command lines in window" option in the Compiler settings panel, copied the command line shown and used this instead!
 
This seems to work well, and updates my build string.
 
This still isn't quite what I am after, as now the build string is updated on every press of the build or debug button - I only want it to be updated if files were actually compiled by the compiler - is there a switch or interrogation I can use to check if the compiler actually did anything and so whether I need to touch my build string file?
 
Thanks for your help thus far - its a whole lot further than I was!!
Mike
0 项奖励
回复