I was involved in an interesting email discussion yesterday. The email chain started with an odd question. The question was is there a way to force a folder to rebuild every time the folder is built? This was asked by an engineer that I have a lot of respect for, so I am not going to question his madness, if he says he needs it to be build every time then it needs to be built.
The discussion was interesting, the solution elegant, but more important my mistake in implementing was a learning experience.
The solution is to add a target that forces a rebuild. For this, we have WINCETARGETFILE0. WINCETARGETFILE0 is used to set a target or targets that are to be built before building the source code defined by SOURCES. When adding WINCETARGETFILE0 to a sources file, the folder also needs a file named makefile.inc. The target “clean” will force to folder to be cleaned which forces a rebuild. The following solves this problem:
Now what about the mistake that I made? I quickly added the solution to a source file to test it, but in my haste I used WINCETARGETFILES (note the ‘S’ instead of ‘0’.) The difference is that WINCETARGETFILES is used to set targets that are built after linking TARGETNAME target. The result was that it almost worked. The first time that I rebuilt the folder, it did not build clean. But each and every time after that it built clean. I almost stopped there and called it a successful test, but then I thought more about it and decided to understand better what was happening.
I quickly realized that I had used the wrong variable and knew what the solution was. That helped me understand why my implementation failed the first time but worked every time after that. Remember that WINCETARGETFILES sets a target to build after linking the TARGETNAME target. This means that my new target caused the folder to be cleaned after building, which of course forces the target to rebuild the next time.
For more on the Platform Builder build system take a look at: Summary of Building Windows CE which lists the articles that I have written about building Windows CE using Platform Builder.
Copyright © 2009 – Bruce Eitman
All Rights Reserved