Using Custom Build Steps

You can run a custom build step during any build pass by using an NTTARGETFILEx macro in your Sources file and providing a Makefile.inc file. The macro specifies that a custom build step is required and the Makefile.inc file provides the information to perform the custom build step

The NTTARGETFILE0, NTTARGETFILE1, and NTTARGETFILE2 macros identify custom build steps for each of the three build passes.

Important  For the best experience, use one of the three macros listed previously and do not use the NTTARGETFILES macro. The NTTARGETFILES macro does not specify the build pass during which the custom build step should be performed. As a result, the Build utility attempts to build the custom target during every pass. In this situation, you need to add conditional code to your Sources file if the custom step is not relevant to all build passes.

You can use a Makefile.inc file to instruct the Build utility to perform project-specific steps, such as the following examples:

  • Build header files that are required by subdirectories within the project.

  • Generate additional files such as text files.

  • Copy or delete files.

The following figure shows how the build components work together.

Diagram illustrating how the build components work together

As shown in the previous figure, the Build utility starts NMAKE and passes it the path to the project Makefile file. The project Makefile contains an !INCLUDE directive that redirects the Build utility to process the system-supplied Makefile.def file. The Makefile.def file sets any macros that may be required for an operating system-specific build and then redirects the Build utility to process the Makefile.new by using an !INCLUDE directive. The Build utility processes the Sources file by using directives within Makefile.new.

In this example, the Sources file contains an NTTARGETFILEx macro, which directs Makefile.new to look for the Makefile.inc file in addition to the Sources file in the project directory. The Makefile.inc file contains the information for the custom build step.

Note  If the project does not supply a Makefile file, which is optional starting with the Windows Driver Kit for Windows Vista, the Build utility passes to NMAKE the path to the Makefile.def file.

 

 

Send comments about this topic to Microsoft

Build date: 5/3/2011