Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.

Target types


The first thing we did in the intruduction was declaring a new target type:

import type ;
type.register VERBATIM : verbatim ;

The type is the most important property of a target. Boost.Build can automatically generate necessary build actions only because you specify the desired type (using the different main target rules), and because Boost.Build can guess the type of sources from their extensions.

The first two parameters for the type.register rule are the name of new type and the list of extensions associated with it. A file with an extension from the list will have the given target type. In the case where a target of the declared type is generated from other sources, the first specified extension will be used. This behaviour can be changed using the type.set-generated-target-suffix rule.

Something about 'main' types.

Something about base types.


Sometimes, a file can refer to other files via some include mechanism. To make Boost.Build track dependencies to the included files, you need to provide a scanner. The primary limitation is that only one scanner can be assigned to a target type.

First, we need to declare a new class for the scanner:

class verbatim-scanner : common-scanner
    rule pattern ( )
        return "//###include[ ]*\"([^\"]*)\"" ;

All the complex logic is in the common-scanner class, and you only need to override the method which returns the regular expression to be used for scanning. The paranthethis in the regular expression indicate which part of the string is the name of the included file.

After that, we need to register our scanner class:

scanner.register verbatim-scanner : include ;

The value of the second parameter, in this case include, specifies which properties contain the list of paths which should be searched for the included files.

Finally, we assign the new scaner to the VERBATIM target type:

type.set-scanner VERBATIM : verbatim-scanner ;

That's enough for scanning include dependencies.