Dirs File

You can instruct the Windows Driver Kit (WDK) Build utility (Build.exe) to recursively build a complete source tree by using the Dirs file.

The Dirs file is located in a directory that contains subdirectories (that is, at the root of a source code tree or subtree). Each subdirectory can be a source directory or another source tree. A Dirs file should exist at the root of each source code subtree, and a Sources file should exist in each "leaf" directory (that is, the directories that contain actual source code).

You can use the MakeDirs (Makedirs.exe) tool to create Dirs files within the source tree of your project. If your project source tree contains subtrees with one or more subdirectories, this utility can be used to create Dirs files in the root of each subtree within the project source tree.

You should define the following macros in your Dirs file:

DIRS

This macro contains a list of subdirectories that the Build utility will build every time that it runs.

OPTIONAL_DIRS

This macro contains a list of subdirectories that the Build utility will build only if specified on the build.exe command-line.

 

Subdirectory names in these lists must be separated by spaces or tabs. Each subdirectory name is relative to the directory that contains the Dirs file.

When you build a product, all subdirectories listed as DIRS macro are scanned. Subdirectories listed as OPTIONAL_DIRS macro are scanned only if they are specifically listed as Build utility command arguments, or if they are assigned to the BUILD_OPTIONS environment variable.

If you follow a distinct pattern in naming your directories, it is simple to use Dirs files to build multiple versions of a product. List the current version in the DIRS macro, and the new or earlier versions in the OPTIONAL_DIRS macro. After you set this up, your build computer will be able to build whichever version that you request.

Example

DIRS=dir1 dir2 dir3
OPTIONAL_DIRS=dir4 dir5

The <currentdir>\dir1, <currentdir>\dir2, and <currentdir>\dir3 directories will be built in this order every time. The <currentdir>\dir4 and <currentdir>\dir5 directories will only be built if you so specify on the Build utility command-line or by using the BUILD_OPTIONS environment variable.

The Build utility supports a "not" switch (~) that removes a directory from the default build. Using the previous example,

build /cZg ~dir1 ~dir3 dir4

would build only dir2 and dir4.

An asterisk (*) as a parameter means that the Build utility should build all optional source directories.

WDK Installation and Dirs Files

Every time that you reinstall or partly uninstall the Windows Driver Kit (WDK), new Dirs files are created dynamically and existing Dirs files are deleted. If you need to create Dirs files for additional subdirectories, run the MakeDirs utility, which is included with the WDK, and specify the drive and starting path of the root of your source code tree.

For example:

makedirs d:\winddk\mydriver

The example creates Dirs files in mydriver and any other parent directories subordinate to it.

 

 

Send comments about this topic to Microsoft

Build date: 5/3/2011