Sometimes it is handy to be able to include a binary file, like a DLL, LIB or EXE, in the build tree and have it “built” while the rest of the tree is built.   I know you are wondering when you would possibly need to build an already existing file. You might want to do this for a few reasons, like:
·         You are creating a binary BSP. In this case, the BSP would not include source.
·         You are creating a source BSP, but you have some third party driver code that you aren’t licensed to deliver with the BSP
·         You want to deliver part of your driver as source and part as binary to protect your intellectual property
·         You received the binary from a vendor and don’t want to clutter your Files folder with binaries
I have seen binary BSPs delivered with the binaries in the Lib and/or Target folders. The problem with this is that as soon as the user does a clean build, the files can be deleted. One solution is to mark the files as read-only, but that can cause error or warnings during the build.
The solution that I am showing here is to add a folder in the build tree for the binary. In the folder, I place the binary file, a sources, makefile and makefile.inc. If I have them, I also include the MAP, REL and PDB files. In this example, I have a driver named binary.dll, and the associated MAP, REL and PDB files. When the folder is built, I want these files copied to the Target folder.
Start with a simple sources file:
TARGETNAME=MyBinaryDriver
TARGETTYPE=LIBRARY
RELEASETYPE=PLATFORM
SOURCES=
 
WINCETARGETFILES=Binary.DLLCOPY
This sources file sets the variables that the Public makefile.def requires when nmake runs, then also sets WINCETARGETFILES. WINCETARGETFILES, when set, tells build to also build the targets listed after building TARGETNAME. This target is named Binary.DLLCOPY, which can be found listed in makefile.inc:
Binary.DLLCOPY:
   xcopy /I /D /Q $*.* $(_TARGETPLATROOT)\target\$(_CPUDEPPATH)
The rule for Binary.DLLCOPY simply runs xcopy to copy the files to the target folder. The “$*” is a makefile variable which is replaced with the target’s base name (the name before the dot.)
Combine this with the standard Platform Builder makefile and when this folder is built, the Binary.* files will be copied to the target folder just as if they had been built from source code.
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