![]() |
Home | Libraries | People | FAQ | More |
Immediately upon starting, the Boost.Build engine (b2)
loads the Jam code that implements the build system. To do this, it searches for a file
called boost-build.jam, first in the invocation directory, then
in its parent and so forth up to the filesystem root, and finally
in the directories specified by the environment variable
BOOST_BUILD_PATH. When found, the file is interpreted, and should
specify the build system location by calling the boost-build
rule:
rule boost-build ( location ? )
If location is a relative path, it is treated as relative to
the directory of boost-build.jam. The directory specified by
that location and the directories in BOOST_BUILD_PATH are then searched for
a file called bootstrap.jam, which is expected to
bootstrap the build system. This arrangement allows the build
system to work without any command-line or environment variable
settings. For example, if the build system files were located in a
directory "build-system/" at your project root, you might place a
boost-build.jam at the project root containing:
boost-build build-system ;
In this case, running b2 anywhere in the project tree will automatically find the build system.
The default bootstrap.jam, after loading some standard
definitions, loads two site-config.jam and user-config.jam.
This section contains the list of all rules that can be used in Jamfile—both rules that define new targets and auxiliary rules.
exeCreates an executable file. See the section called “Programs”.
libCreates an library file. See the section called “Libraries”.
installInstalls built targets and other files. See the section called “Installing”.
aliasCreates an alias for other targets. See the section called “Alias”.
unit-testCreates an executable that will be automatically run. See the section called “Testing”.
compile, compile-fail, link, link-fail, run, run-fail
Specialized rules for testing. See the section called “Testing”.
check-target-builds
The check-target-builds allows you
to conditionally use different properties depending on whether some
metatarget builds, or not. This is similar to functionality of configure
script in autotools projects. The function signature is:
rule check-target-builds ( target message ? : true-properties * : false-properties * )
This function can only be used when passing requirements or usage requirements to a metatarget rule. For example, to make an application link to a library if it's avavailable, one has use the following:
exe app : app.cpp : [ check-target-builds has_foo "System has foo" : <library>foo : <define>FOO_MISSING=1 ] ;
For another example, the alias rule can be used to consolidate configuraiton choices and make them available to other metatargets, like so:
alias foobar : : : : [ check-target-builds has_foo "System has foo" : <library>foo : <library>bar ] ;
objCreates an object file. Useful when a single source file must be compiled with special properties.
preprocessedCreates an preprocessed source file. The arguments follow the common syntax.
glob
The glob rule takes a list shell pattern
and returns the list of files in the project's source directory that
match the pattern. For example:
lib tools : [ glob *.cpp ] ;
It is possible to also pass a second argument—the list of exclude patterns. The result will then include the list of files patching any of include patterns, and not matching any of the exclude patterns. For example:
lib tools : [ glob *.cpp : file_to_exclude.cpp bad*.cpp ] ;
glob-tree
The glob-tree is similar to the
glob except that it operates recursively from
the directory of the containing Jamfile. For example:
ECHO [ glob-tree *.cpp : .svn ] ;
will print the names of all C++ files in your project. The
.svn exclude pattern prevents the
glob-tree rule from entering administrative
directories of the Subversion version control system.
projectDeclares project id and attributes, including project requirements. See the section called “Projects”.
use-projectAssigns a symbolic project ID to a project at a given path. This rule must be better documented!
explicit
The explicit rule takes a single
parameter—a list of target names. The named targets will
be marked explicit, and will be built only if they are explicitly
requested on the command line, or if their dependents are built.
Compare this to ordinary targets, that are built implicitly when
their containing project is built.
alwaysThe always funciton takes a single
parameter—a list of metatarget names. The top-level targets produced
by the named metatargets will be always considered out of date. Consider this example:
exe hello : hello.cpp ; exe bye : bye.cpp ; always hello ;
If a build of hello is requested, then the binary will
always be relinked. The object files will not be recompiled, though. Note that if
a build of hello is not requested, for example you specify just
bye on the command line, hello will not
be relinked.
constantSets project-wide constant. Takes two parameters: variable name and a value and makes the specified variable name accessible in this Jamfile and any child Jamfiles. For example:
constant VERSION : 1.34.0 ;
path-constantSame as constant except that
the value is treated as path relative to Jamfile location. For example,
if b2 is invoked in the current directory,
and Jamfile in helper subdirectory has:
path-constant DATA : data/a.txt ;
then the variable DATA will be set to
helper/data/a.txt, and if b2
is invoked from the helper directory, then
the variable DATA will be set to
data/a.txt.
build-projectCause some other project to be built. This rule takes a single parameter—a directory name relative to the containing Jamfile. When the containing Jamfile is built, the project located at that directory will be built as well. At the moment, the parameter to this rule should be a directory name. Project ID or general target references are not allowed.
test-suiteThis rule is deprecated and equivalent to
alias.
This section documents the features that are built-in into Boost.Build. For features with a fixed set of values, that set is provided, with the default value listed first.
variantA feature combining several low-level features, making it easy to request common build configurations.
Allowed values:
debug, release,
profile.
The value debug expands to
<optimization>off <debug-symbols>on <inlining>off <runtime-debugging>on
The value release expands to
<optimization>speed <debug-symbols>off <inlining>full <runtime-debugging>off
The value profile expands to the same as
release, plus:
<profiling>on <debug-symbols>on
Users can define their own build variants using the
variant rule from the common module.
Note: Runtime debugging is on in debug builds to suit the expectations of people used to various IDEs.
link
Allowed values: shared,
static
A feature controling how libraries are built.
runtime-link
Allowed values: shared,
static
Controls if a static or shared C/C++ runtime should be used. There are some restrictions how this feature can be used, for example on some compilers an application using static runtime should not use shared libraries at all, and on some compilers, mixing static and shared runtime requires extreme care. Check your compiler documentation for more details.
threadingAllowed values: single,
multi
Controls if the project should be built in multi-threaded mode. This feature does not
necessary change code generation in the compiler, but it causes the compiler to link
to additional or different runtime libraries, and define additional preprocessor
symbols (for example, _MT on Windows and _REENTRANT on Linux).
How those symbols affect the compiled code depends on the code itself.
source<source>X feature has the same effect on
building a target as putting X in the list of sources. It is useful
when you want to add the same source to all targets in the project
(you can put <source> in requirements) or to conditionally
include a source (using conditional requirements, see the section called “Conditions and alternatives”). See also the <library>
feature.
library<source>
feature, except that it takes effect only for linking. When you want
to link all targets in a Jamfile to certain library, the
<library> feature is preferred over
<source>X—the latter will add the library to
all targets, even those that have nothing to do with libraries.
dependencyimplicit-dependencyuse#include paths) of some library
to be applied, but do not want to link to it.
dll-pathdll-path and hardcode-dll-paths
properties useful?
”
in the section called “Frequently Asked Questions” for details.
hardcode-dll-pathsControls automatic generation of dll-path properties.
Allowed values:
true, false. This property is
specific to Unix systems. If an executable is built with
<hardcode-dll-paths>true, the generated binary
will contain the list of all the paths to the used shared libraries.
As the result, the executable can be run without changing system
paths to shared libraries or installing the libraries to system
paths. This is very
convenient during development. Plase see the FAQ entry for details. Note that on Mac
OSX, the paths are unconditionally hardcoded by the linker, and it
is not possible to disable that behaviour.
cflags, cxxflags, linkflags
cflags that is both the C and
C++ compilers, for cxxflags that is the C++ compiler
and for linkflags that is the linker. The features are
handy when you are trying to do something special that cannot be
achieved by a higher-level feature in Boost.Build.
includedefinewarnings<warnings> feature controls the warning level
of compilers. It has the following values:
off - disables all warnings.
on - enables default warning level for the tool.
all - enables all warnings.
all.
warnings-as-errors<warnings-as-errors> makes it possible to
treat warnings as errors and abort compilation on a warning. The
value on enables this behaviour. The default value is
off.
buildAllowed values: no
The build feature is used to conditionally disable
build of a target. If <build>no is in properties
when building a target, build of that target is skipped. Combined
with conditional requirements this allows you to skip building some
target in configurations where the build is known to fail.
tagThe tag feature is used to customize
the name of the generated files. The value should have the form:
@rulename
where
rulename should be a name of a rule with the
following signature:
rule tag ( name : type ? : property-set )
The rule will be called for each target with the default name computed by Boost.Build, the type of the target, and property set. The rule can either return a string that must be used as the name of the target, or an empty string, in which case the default name will be used.
Most typical use of the tag feature is to
encode build properties, or library version in library target names. You
should take care to return non-empty string from the tag rule only for
types you care about — otherwise, you might end up modifying
names of object files, generated header file and other targets for which
changing names does not make sense.
debug-symbolsAllowed values: on, off.
The debug-symbols feature specifies if
produced object files, executables and libraries should include
debug information.
Typically, the value of this feature is implicitly set by the
variant feature, but it can be explicitly
specified by the user. The most common usage is to build
release variant with debugging information.
runtime-debuggingAllowed values: on, off.
The runtime-debugging feature specifies if
produced object files, executables and libraries should include
behaviour useful only for debugging, such as asserts.
Typically, the value of this feature is implicitly set by the
variant feature, but it can be explicitly
specified by the user. The most common usage is to build
release variant with debugging output.
target-osThe operating system for which the code is to be generated. The compiler you used should be the compiler for that operating system. This option causes Boost.Build to use naming conventions suitable for that operating system, and adjust build process accordingly. For example, with gcc, it controls if import libraries are produced for shared libraries or not.
The complete list of possible values for this feature is: aix, bsd, cygwin, darwin, freebsd, hpux, iphone, linux, netbsd, openbsd, osf, qnx, qnxnto, sgi, solaris, unix, unixware, windows.
See the section called “Cross-compilation” for details of crosscompilation
architectureThe architecture features specifies
the general processor familty to generate code for.
instruction-setAllowed values: depend on the used toolset.
The instruction-set specifies for which
specific instruction set the code should be generated. The
code in general might not run on processors with older/different
instruction sets.
While Boost.Build allows a large set of possible values for this features, whether a given value works depends on which compiler you use. Please see the section called “C++ Compilers” for details.
address-modelAllowed values: 32, 64.
The address-model specifies if 32-bit or
64-bit code should be generated by the compiler. Whether this feature
works depends on the used compiler, its version, how the compiler is
configured, and the values of the architecture
instruction-set
features. Please see the section called “C++ Compilers”
for details.
c++-template-depthAllowed values: Any positive integer.
This feature allows configuring a C++ compiler with the maximal template instantiation depth parameter. Specific toolsets may or may not provide support for this feature depending on whether their compilers provide a corresponding command-line option.
Note: Due to some internal details in the current Boost.Build implementation it is not possible to have features whose valid values are all positive integer. As a workaround a large set of allowed values has been defined for this feature and, if a different one is needed, user can easily add it by calling the feature.extend rule.
embed-manifestAllowed values: on, off.
This feature is specific to the msvc toolset (see the section called “Microsoft Visual C++”), and controls whether the manifest files should be embedded inside executables and shared libraries, or placed alongside them. This feature corresponds to the IDE option found in the project settings dialog, under → → → .
embed-manifest-fileThis feature is specific to the msvc toolset (see the section called “Microsoft Visual C++”), and controls which manifest files should be embedded inside executables and shared libraries. This feature corresponds to the IDE option found in the project settings dialog, under → → → .
Boost.Build comes with support for a large number of C++ compilers, and other tools. This section documents how to use those tools.
Before using any tool, you must declare your intention, and possibly
specify additional information about the tool's configuration. This is
done by calling the using rule, typically in your
user-config.jam, for example:
using gcc ;
additional parameters can be passed just like for other rules, for example:
using gcc : 4.0 : g++-4.0 ;
The options that can be passed to each tool are documented in the subsequent sections.
This section lists all Boost.Build modules that support C++
compilers and documents how each one can be initialized. The name
of support module for compiler is also the value for
the toolset feature that can be used to explicitly
request that compiler.
The gcc module supports the
GNU C++ compiler
on Linux, a number of Unix-like system including SunOS and on Windows
(either Cygwin or
MinGW). On Mac OSX, it is recommended
to use system gcc, see the section called “Apple Darwin gcc”.
The gcc module is initialized using the following
syntax:
using gcc : [version] : [c++-compile-command] : [compiler options] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the version is not explicitly specified, it will be
automatically detected by running the compiler with the -v
option. If the command is not specified, the g++
binary will be searched in PATH.
The following options can be provided, using < syntax:option-name>option-value
cflagsSpecifies additional compiler flags that will be used when compiling C sources.
cxxflagsSpecifies additional compiler flags that will be used when compiling C++ sources.
compileflagsSpecifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflagsSpecifies additional command line options that will be passed to the linker.
rootSpecifies root directory of the compiler installation. This option is necessary only if it is not possible to detect this information from the compiler command—for example if the specified compiler command is a user script.
rcSpecifies the resource compiler command that will be used with the version of gcc that is being configured. This setting makes sense only for Windows and only if you plan to use resource files. By default windres will be used.
rc-typeSpecifies the type of resource compiler. The value can
be either windres for msvc resource compiler,
or rc for borland's resource compiler.
address-model=64, and the instruction-set
feature should refer to a 64 bit processor. Currently, those
include nocona, opteron,
athlon64 and athlon-fx.
The darwin module supports the version of gcc that is
modified and provided by Apple. The configuration is essentially identical
to that of the gcc module.
The darwin toolset can generate so called "fat"
binaries—binaries that can run support more than one
architecture, or address mode. To build a binary that can run both
on Intel and PowerPC processors, specify
architecture=combined. To build a binary that can run
both in 32-bit and 64-bit modes, specify
address-model=32_64. If you specify both of those
properties, a "4-way" fat binary will be generated.
The msvc module supports the
Microsoft Visual
C++ command-line tools on Microsoft Windows. The supported
products and versions of command line tools are listed below:
Visual Studio 2010—10.0
Visual Studio 2008—9.0
Visual Studio 2005—8.0
Visual Studio .NET 2003—7.1
Visual Studio .NET—7.0
Visual Studio 6.0, Service Pack 5—6.5
The msvc module is initialized using the following
syntax:
using msvc : [version] : [c++-compile-command] : [compiler options] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the version is not explicitly specified, the most recent
version found in the registry will be used instead. If the special
value all is passed as the version, all versions found in
the registry will be configured. If a version is specified, but the
command is not, the compiler binary will be searched in standard
installation paths for that version, followed by PATH.
The compiler command should be specified using forward slashes, and quoted.
The following options can be provided, using < syntax:option-name>option-value
cflagsSpecifies additional compiler flags that will be used when compiling C sources.
cxxflagsSpecifies additional compiler flags that will be used when compiling C++ sources.
compileflagsSpecifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflagsSpecifies additional command line options that will be passed to the linker.
assemblerThe command that compiles assembler sources. If
not specified, ml will be used. The command
will be invoked after the setup script was executed and adjusted
the PATH variable.
compilerThe command that compiles C and C++ sources. If
not specified, cl will be used. The command
will be invoked after the setup script was executed and adjusted
the PATH variable.
compiler-filterCommand through which to pipe the output of running the compiler. For example to pass the output to STLfilt.
idl-compilerThe command that compiles Microsoft COM interface
definition files. If not specified, midl will
be used. The command will be invoked after the setup script was
executed and adjusted the PATH variable.
linkerThe command that links executables and dynamic
libraries. If not specified, link will be used.
The command will be invoked after the setup script was executed
and adjusted the PATH variable.
mc-compilerThe command that compiles Microsoft message
catalog files. If not specified, mc will be
used. The command will be invoked after the setup script was
executed and adjusted the PATH variable.
resource-compilerThe command that compiles resource files. If not
specified, rc will be used. The command will be
invoked after the setup script was executed and adjusted the
PATH variable.
setupThe filename of the global environment setup script to run before invoking any of the tools defined in this toolset. Will not be used in case a target platform specific script has been explicitly specified for the current target platform. Used setup script will be passed the target platform identifier (x86, x86_amd64, x86_ia64, amd64 or ia64) as a arameter. If not specified a default script is chosen based on the used compiler binary, e.g. vcvars32.bat or vsvars32.bat.
setup-amd64, setup-i386, setup-ia64
The filename of the target platform specific environment setup script to run before invoking any of the tools defined in this toolset. If not specified the global environment setup script is used.
Starting with version 8.0, Microsoft Visual Studio can generate binaries for 64-bit processor, both 64-bit flavours of x86 (codenamed AMD64/EM64T), and Itanium (codenamed IA64). In addition, compilers that are itself run in 64-bit mode, for better performance, are provided. The complete list of compiler configurations are as follows (we abbreviate AMD64/EM64T to just AMD64):
32-bit x86 host, 32-bit x86 target
32-bit x86 host, 64-bit AMD64 target
32-bit x86 host, 64-bit IA64 target
64-bit AMD64 host, 64-bit AMD64 target
64-bit IA64 host, 64-bit IA64 target
The 32-bit host compilers can be always used, even on 64-bit Windows. On the contrary, 64-bit host compilers require both 64-bit host processor and 64-bit Windows, but can be faster. By default, only 32-bit host, 32-bit target compiler is installed, and additional compilers need to be installed explicitly.
To use 64-bit compilation you should:
Configure you compiler as usual. If you provide a path to the compiler explicitly, provide the path to the 32-bit compiler. If you try to specify the path to any of 64-bit compilers, configuration will not work.
When compiling, use address-model=64,
to generate AMD64 code.
To generate IA64 code, use
architecture=ia64
The (AMD64 host, AMD64 target) compiler will be used automatically when you are generating AMD64 code and are running 64-bit Windows on AMD64. The (IA64 host, IA64 target) compiler will never be used, since nobody has an IA64 machine to test.
It is believed that AMD64 and EM64T targets are essentially
compatible. The compiler options /favor:AMD64 and
/favor:EM64T, which are accepted only by AMD64
targeting compilers, cause the generated code to be tuned to a
specific flavor of 64-bit x86. Boost.Build will make use of those
options depending on the value of theinstruction-set
feature.
Starting with version 11.0, Microsoft Visual Studio can
produce binaries for Windows Store and Phone in addition to
traditional Win32 desktop. To specify which Windows API set
to target, use the windows-api feature.
Available options are desktop,
store, or phone. If not
specified, desktop will be used.
When using store or phone
the specified toolset determines what Windows version is
targeted. The following options are available:
Windows 8.0: toolset=msvc-11.0 windows-api=store
Windows 8.1: toolset=msvc-12.0 windows-api=store
Windows Phone 8.0: toolset=msvc-11.0 windows-api=phone
Windows Phone 8.1: toolset=msvc-12.0 windows-api=phone
For example use the following to build for Windows Store 8.1 with the ARM architecture:
.\b2 toolset=msvc=12.0 windows-api=store architecture=arm
Note that when targeting Windows Phone 8.1, version 12.0 didn't include the vcvars phone setup scripts. They can be separately downloaded from here.
The intel-linux and intel-win modules
support the Intel C++ command-line compiler—the Linux
and
Windows versions respectively.
The module is initialized using the following syntax:
using intel-linux : [version] : [c++-compile-command] : [compiler options] ;
or
using intel-win : [version] : [c++-compile-command] : [compiler options] ;
respectively.
This statement may be repeated several times, if you want to configure several versions of the compiler.
If compiler command is not specified, then Boost.Build will
look in PATH for an executable icpc
(on Linux), or icc.exe (on Windows).
The following options can be provided, using < syntax:option-name>option-value
cflagsSpecifies additional compiler flags that will be used when compiling C sources.
cxxflagsSpecifies additional compiler flags that will be used when compiling C++ sources.
compileflagsSpecifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflagsSpecifies additional command line options that will be passed to the linker.
The Linux version supports the following additional options:
rootSpecifies root directory of the compiler installation. This option is necessary only if it is not possible to detect this information from the compiler command—for example if the specified compiler command is a user script.
The acc module supports the
HP aC++ compiler
for the HP-UX operating system.
The module is initialized using the following syntax:
using acc : [version] : [c++-compile-command] : [compiler options] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, the aCC
binary will be searched in PATH.
The following options can be provided, using < syntax:option-name>option-value
cflagsSpecifies additional compiler flags that will be used when compiling C sources.
cxxflagsSpecifies additional compiler flags that will be used when compiling C++ sources.
compileflagsSpecifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflagsSpecifies additional command line options that will be passed to the linker.
The borland module supports the command line
C++ compiler included in
C++ Builder 2006
product and earlier version of it, running on Microsoft Windows.
The supported products are listed below. The version reported by the command lines tools is also listed for reference.:
C++ Builder 2006—5.8.2
CBuilderX—5.6.5, 5.6.4 (depending on release)
CBuilder6—5.6.4
Free command line tools—5.5.1
The module is initialized using the following syntax:
using borland : [version] : [c++-compile-command] : [compiler options] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for
a binary named bcc32 in PATH.
The following options can be provided, using < syntax:option-name>option-value
cflagsSpecifies additional compiler flags that will be used when compiling C sources.
cxxflagsSpecifies additional compiler flags that will be used when compiling C++ sources.
compileflagsSpecifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflagsSpecifies additional command line options that will be passed to the linker.
The como-linux and the como-win
modules supports the
Comeau C/C++ Compiler
on Linux and Windows respectively.
The module is initialized using the following syntax:
using como-linux : [version] : [c++-compile-command] : [compiler options] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for
a binary named como in
PATH.
The following options can be provided, using < syntax:option-name>option-value
cflagsSpecifies additional compiler flags that will be used when compiling C sources.
cxxflagsSpecifies additional compiler flags that will be used when compiling C++ sources.
compileflagsSpecifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflagsSpecifies additional command line options that will be passed to the linker.
Before using the Windows version of the compiler, you need to
setup necessary environment variables per compiler's documentation. In
particular, the COMO_XXX_INCLUDE variable should be
set, where XXX corresponds to the used backend C
compiler.
The cw module support CodeWarrior compiler,
originally produced by Metrowerks and presently developed by
Freescale. Boost.Build supports only the versions of the compiler that
target x86 processors. All such versions were released by Metrowerks
before aquisition and are not sold any longer. The last version known
to work is 9.4.
The module is initialized using the following syntax:
using cw : [version] : [c++-compile-command] : [compiler options] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for a
binary named mwcc in default installation paths and
in PATH.
The following options can be provided, using < syntax:option-name>option-value
cflagsSpecifies additional compiler flags that will be used when compiling C sources.
cxxflagsSpecifies additional compiler flags that will be used when compiling C++ sources.
compileflagsSpecifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflagsSpecifies additional command line options that will be passed to the linker.
rootSpecifies root directory of the compiler installation. This option is necessary only if it is not possible to detect this information from the compiler command—for example if the specified compiler command is a user script.
setupThe command that sets up environment variables prior to invoking the compiler. If not specified, cwenv.bat alongside the compiler binary will be used.
compilerThe command that compiles C and C++ sources.
If not specified, mwcc will be used. The
command will be invoked after the setup script was
executed and adjusted the PATH variable.
linkerThe command that links executables and dynamic
libraries.
If not specified, mwld will be used. The
command will be invoked after the setup script was
executed and adjusted the PATH variable.
The dmc module supports the
Digital Mars C++ compiler.
The module is initialized using the following syntax:
using dmc : [version] : [c++-compile-command] : [compiler options] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for
a binary named dmc in
PATH.
The following options can be provided, using < syntax:option-name>option-value
cflagsSpecifies additional compiler flags that will be used when compiling C sources.
cxxflagsSpecifies additional compiler flags that will be used when compiling C++ sources.
compileflagsSpecifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflagsSpecifies additional command line options that will be passed to the linker.
The hp_cxx modules supports the
HP C++ Compiler for Tru64 Unix.
The module is initialized using the following syntax:
using hp_cxx : [version] : [c++-compile-command] : [compiler options] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for
a binary named hp_cxx in PATH.
The following options can be provided, using < syntax:option-name>option-value
cflagsSpecifies additional compiler flags that will be used when compiling C sources.
cxxflagsSpecifies additional compiler flags that will be used when compiling C++ sources.
compileflagsSpecifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflagsSpecifies additional command line options that will be passed to the linker.
The sun module supports the
Sun Studio C++ compilers for the Solaris OS.
The module is initialized using the following syntax:
using sun : [version] : [c++-compile-command] : [compiler options] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for
a binary named CC
in /opt/SUNWspro/bin and in
PATH.
When using this compiler on complex C++ code, such as the
Boost C++ library, it is
recommended to specify the following options when intializing the
sun module:
-library=stlport4 -features=tmplife -features=tmplrefstatic
See the Sun C++ Frontend Tales for details.
The following options can be provided, using < syntax:option-name>option-value
cflagsSpecifies additional compiler flags that will be used when compiling C sources.
cxxflagsSpecifies additional compiler flags that will be used when compiling C++ sources.
compileflagsSpecifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflagsSpecifies additional command line options that will be passed to the linker.
address-model=64 property.
The vacpp module supports the
IBM Visual
Age C++ Compiler, for the AIX operating system. Versions
7.1 and 8.0 are known to work.
The module is initialized using the following syntax:
using vacpp ;
The module does not accept any initialization options. The
compiler should be installed in the /usr/vacpp/bin
directory.
Later versions of Visual Age are known as XL C/C++. They
were not tested with the the vacpp module.
Boost.Build provides special support for some third-party C++ libraries, documented below.
The STLport library is an alternative implementation of C++ runtime library. Boost.Build supports using that library on Windows platfrom. Linux is hampered by different naming of libraries in each STLport version and is not officially supported.
Before using STLport, you need to configure it in
user-config.jam using the following syntax:
using stlport : [version] :header-path: [library-path] ;
Where version is the version of
STLport, for example 5.1.4,
headers is the location where
STLport headers can be found, and libraries
is the location where STLport libraries can be found.
The version should always be provided, and the library path should
be provided if you're using STLport's implementation of
iostreams. Note that STLport 5.* always uses its own iostream
implementation, so the library path is required.
When STLport is configured, you can build with STLport by
requesting stdlib=stlport on the command line.
Provides support for the zlib library. zlib can be configured either to use precompiled binaries or to build the library from source.
zlib can be initialized using the following syntax
using zlib : [version] : [options] : [condition] : [is-default] ;
Options for using a prebuilt library:
searchThe directory containing the zlib binaries.
nameOverrides the default library name.
includeThe directory containing the zlib headers.
If none of these options is specified, then the environmental variables ZLIB_LIBRARY_PATH, ZLIB_NAME, and ZLIB_INCLUDE will be used instead.
Options for building zlib from source:
sourceThe zlib source directory. Defaults to the environmental variable ZLIB_SOURCE.
tagSets the tag property to adjust the file name of the library. Ignored when using precompiled binaries.
build-nameThe base name to use for the compiled library. Ignored when using precompiled binaries.
Examples:
# Find zlib in the default system location using zlib ; # Build zlib from source using zlib : 1.2.7 : <source>/home/steven/zlib-1.2.7 ; # Find zlib in /usr/local using zlib : 1.2.7 : <include>/usr/local/include <search>/usr/local/lib ; # Build zlib from source for msvc and find # prebuilt binaries for gcc. using zlib : 1.2.7 : <source>C:/Devel/src/zlib-1.2.7 : <toolset>msvc ; using zlib : 1.2.7 : : <toolset>gcc ;
Boost.Build support for the Boost documentation tools is documented below.
To use xsltproc, you first need to configure it using the following syntax:
using xsltproc : [xsltproc] ;
Where xsltproc is the xsltproc executable.
If xsltproc is not specified, and the
variable XSLTPROC is set, the value of XSLTPROC will be used.
Otherwise, xsltproc will be searched for in PATH.
The following options can be provided, using < syntax:option-name>option-value
xsl:paramValues should have the form
name=value
xsl:pathSets an additional search path for xi:include elements.
catalogA catalog file used to rewrite remote URL's to a local copy.
The xsltproc module provides the following rules. Note that these operate on jam targets and are intended to be used by another toolset, such as boostbook, rather than directly by users.
xsltrule xslt ( target : source stylesheet : properties * )
Runs xsltproc to create a single output file.
xslt-dirrule xslt-dir ( target : source stylesheet : properties * : dirname )
Runs xsltproc to create multiple outputs in a directory.
dirname is unused, but exists for
historical reasons. The output directory is determined from the
target.
To use boostbook, you first need to configure it using the following syntax:
using boostbook : [docbook-xsl-dir] : [docbook-dtd-dir] : [boostbook-dir] ;
docbook-xsl-dir is the DocBook XSL stylesheet
directory. If not provided, we use DOCBOOK_XSL_DIR from the environment
(if available) or look in standard locations. Otherwise, we let the
XML processor load the stylesheets remotely.
docbook-dtd-dir is the DocBook DTD directory.
If not provided, we use DOCBOOK_DTD_DIR From the environment (if
available) or look in standard locations. Otherwise, we let the XML
processor load the DTD remotely.
boostbook-dir is the BoostBook directory
with the DTD and XSL subdirs.
The boostbook module depends on xsltproc. For pdf or ps output, it also depends on fop.
The following options can be provided, using < syntax:option-name>option-value
format
Allowed values:
html, xhtml,
htmlhelp, onehtml,
man, pdf,
ps, docbook,
fo, tests.
The format feature determines the type
of output produced by the boostbook rule.
The boostbook module defines a rule for creating a target following the common syntax.
boostbookrule boostbook ( target-name : sources * : requirements * : default-build * )
Creates a boostbook target.
To use doxygen, you first need to configure it using the following syntax:
using doxygen : [name] ;
name is the doxygen command.
If it is not specified, it will be found in the PATH.
The doxygen module depends on the boostbook module when generating BoostBook XML.
The following options can be provided, using < syntax:option-name>option-value
doxygen:paramAll the values of doxygen:param
are added to the doxyfile.
prefixSpecifies the common prefix of all headers when generating BoostBook XML. Everything before this will be stripped off.
reftitleSpecifies the title of the library-reference section, when generating BoostBook XML.
doxygen:xml-imagedirWhen generating BoostBook XML, specifies the directory in which to place the images generated from LaTex formulae.
![]() |
Warning |
|---|---|
The path is interpreted relative to the current working directory, not relative to the Jamfile. This is necessary to match the behavior of BoostBook. |
The doxygen module defines a rule for creating a target following the common syntax.
doxygenrule doxygen ( target : sources * : requirements * : default-build * : usage-requirements * )
Creates a doxygen target. If the target name ends with .html, then this will generate an html directory. Otherwise it will generate BoostBook XML.
The quickbook module provides a generator to convert from Quickbook to BoostBook XML.
To use quickbook, you first need to configure it using the following syntax:
using quickbook : [command] ;
command is the quickbook executable.
If it is not specified, Boost.Build will compile it from source.
If it is unable to find the source it will search for a quickbook
executable in PATH.
The fop module provides generators to convert from XSL formatting objects to Postscript and PDF.
To use fop, you first need to configure it using the following syntax:
using fop : [fop-command] : [java-home] : [java] ;
fop-command is the command to run fop.
If it is not specified, Boost.Build will search for it in PATH and
FOP_HOME.
Either java-home or
java
can be used to specify where to find java.
This section describes the modules that are provided by Boost.Build. The import rule allows rules from one module to be used in another module or Jamfile.
The modules module defines basic functionality
for handling modules.
A module defines a number of rules that can be used in other modules. Modules can contain code at the top level to initialize the module. This code is executed the first time the module is loaded.
![]() |
Note |
|---|---|
A Jamfile is a special kind of module which is managed by the build system. Although they cannot be loaded directly by users, the other features of modules are still useful for Jamfiles. |
Each module has its own namespaces for variables and rules. If two modules A and B both use a variable named X, each one gets its own copy of X. They won't interfere with each other in any way. Similarly, importing rules into one module has no effect on any other module.
Every module has two special variables.
$(__file__) contains the name of the file that
the module was loaded from and $(__name__)
contains the name of the module.
![]() |
Note |
|---|---|
|
rule binding ( module-name )Returns the filesystem binding of the given module.
For example, a module can get its own location with:
me = [ modules.binding $(__name__) ] ;
rule poke ( module-name ? : variables + : value * )Sets the module-local value of a variable.
For example, to set a variable in the global module:
modules.poke : ZLIB_INCLUDE : /usr/local/include ;
rule peek ( module-name ? : variables + )Returns the module-local value of a variable.
For example, to read a variable from the global module:
local ZLIB_INCLUDE = [ modules.peek : ZLIB_INCLUDE ] ;
rule call-in ( module-name ? : rule-name args * : * ) Call the given rule locally in the given module. Use this for rules accepting rule names as arguments, so that the passed rule may be invoked in the context of the rule's caller (for example, if the rule accesses module globals or is a local rule).
![]() |
Note |
|---|---|
rules called this way may accept at most 8 parameters. |
Example:
rule filter ( f : values * ) { local m = [ CALLER_MODULE ] ; local result ; for v in $(values) { if [ modules.call-in $(m) : $(f) $(v) ] { result += $(v) ; } } return result ; }
rule load ( module-name : filename ? : search * )Load the indicated module if it is not already loaded.
module-nameName of module to load.
filename(partial) path to file; Defaults to $(module-name).jam
searchDirectories in which to search for filename.
Defaults to $(BOOST_BUILD_PATH).
rule import ( module-names + : rules-opt * : rename-opt * )Load the indicated module and import rule names into the
current module. Any members of rules-opt will be
available without qualification in the caller's module. Any
members of rename-opt will be taken as the names
of the rules in the caller's module, in place of the names they
have in the imported module. If rules-opt = '*',
all rules from the indicated module are imported into the
caller's module. If rename-opt is supplied, it must have the
same number of elements as rules-opt.
![]() |
Note |
|---|---|
The |
Examples:
import path ; import path : * ; import path : join ; import path : native make : native-path make-path ;
rule clone-rules ( source-module target-module )Define exported copies in $(target-module)
of all rules exported from $(source-module). Also
make them available in the global module with qualification,
so that it is just as though the rules were defined originally
in $(target-module).
Performs various path manipulations. Paths are always in a 'normalized' representation. In it, a path may be either:
'.', or
['/'] [ ( '..' '/' )* (token '/')* token ]
In plain english, a path can be rooted, '..'
elements are allowed only at the beginning, and it never
ends in slash, except for the path consisting of slash only.
rule make ( native )Converts the native path into normalized form.
rule native ( path )Builds the native representation of the path.
rule is-rooted ( path )Tests if a path is rooted.
rule has-parent ( path )Tests if a path has a parent.
rule basename ( path )Returns the path without any directory components.
rule parent ( path )Returns the parent directory of the path. If no parent exists, an error is issued.
rule reverse ( path )
Returns path2 such that
[ join path path2 ] = ".".
The path may not contain ".."
element or be rooted.
rule join ( elements + )Concatenates the passed path elements. Generates an error if any element other than the first one is rooted. Skips any empty or undefined path elements.
rule root ( path root )
If path is relative, it is rooted at
root. Otherwise, it is unchanged.
rule pwd ( )Returns the current working directory.
rule glob ( dirs * : patterns + : exclude-patterns * )Returns the list of files matching the given pattern in the specified directory. Both directories and patterns are supplied as portable paths. Each pattern should be a non-absolute path, and can't contain "." or ".." elements. Each slash separated element of a pattern can contain the following special characters:
'?' matches any character
'*' matches an arbitrary number of characters
A file $(d)/e1/e2/e3 (where 'd' is in $(dirs)) matches the pattern p1/p2/p3 if and only if e1 matches p1, e2 matches p2 and so on. For example:
[ glob . : *.cpp ] [ glob . : */build/Jamfile ]
rule glob-tree ( roots * : patterns + : exclude-patterns * )Recursive version of glob. Builds the glob of files while also searching in the subdirectories of the given roots. An optional set of exclusion patterns will filter out the matching entries from the result. The exclusions also apply to the subdirectory scanning, such that directories that match the exclusion patterns will not be searched.
rule exists ( file )Returns true if the specified file exists.
rule all-parents ( path : upper_limit ? : cwd ? )
Find out the absolute name of path and return the list of all the parents,
starting with the immediate one. Parents are returned as relative names. If
upper_limit is specified, directories above it
will be pruned.
rule glob-in-parents ( dir : patterns + : upper-limit ? )
Search for patterns in parent directories
of dir, up to and including
upper_limit, if it is specified, or
till the filesystem root otherwise.
rule relative ( child parent : no-error ? )
Assuming child is a subdirectory of
parent, return the relative path from
parent to child.
rule relative-to ( path1 path2 )Returns the minimal path to path2 that is relative path1.
rule programs-path ( )Returns the list of paths which are used by the operating system for looking up programs.
rule makedirs ( path )Creates a directory and all parent directories that do not already exist.
Contains rules for string processing using regular expressions.
"x*" matches the pattern
"x" zero or more times.
"x+" matches "x"
one or more times.
"x?" matches "x"
zero or one time.
"[abcd]" matches any of the characters,
"a", "b",
"c", and "d".
A character range such as "[a-z]" matches
any character between "a" and
"z". "[^abc]"
matches any character which is not "a",
"b", or "c".
"x|y" matches either pattern
"x" or pattern "y"
(x) matches "x"
and captures it.
"^" matches the beginning of the string.
"$" matches the end of the string.
"\<" matches the beginning of a word.
"\>" matches the end of a word.
rule split ( string separator )Returns a list of the following substrings:
from beginning till the first occurrence of
separator or till the end,
between each occurrence of
separator and the next occurrence,
from the last occurrence of
separator till the end.
If no separator is present, the result will contain only one element.
rule split-list ( list * : separator )Returns the concatenated results of applying regex.split to every element of the list using the separator pattern.
rule match ( pattern : string : indices * )Match string against
pattern, and return the elements
indicated by indices.
rule transform ( list * : pattern : indices * )Matches all elements of list against
the pattern and returns a list of elements
indicated by indices of all successful
matches. If indices is omitted returns a list
of first parenthesized groups of all successful matches.
rule escape ( string : symbols : escape-symbol )Escapes all of the characters in symbols
using the escape symbol escape-symbol for
the given string, and returns the escaped string.
rule replace ( string match replacement )Replaces occurrences of a match string in a given string and returns the new string. The match string can be a regex expression.
rule replace-list ( list * : match : replacement )Replaces occurrences of a match string in a given list of strings and returns a list of new strings. The match string can be a regex expression.
See also: MATCH
Various useful list functions. Note that algorithms in this module execute largely in the caller's module namespace, so that local rules can be used as function objects. Also note that most predicates can be multi-element lists. In that case, all but the first element are prepended to the first argument which is passed to the rule named by the first element.
rule filter ( predicate + : sequence * )Return the elements e of
$(sequence) for which
[ $(predicate) e ] has a non-null value.
rule transform ( function + : sequence * )Return a new sequence consisting of
[ $(function) $(e) ] for each element
e of $(sequence).
rule reverse ( s * )Returns the elements of s in
reverse order.
rule insertion-sort ( s * : ordered * )Insertion-sort s using the
BinaryPredicate ordered.
rule merge ( s1 * : s2 * : ordered * )Merge two ordered sequences using the BinaryPredicate
ordered.
rule join ( s * : joint ? )Join the elements of s into one
long string. If joint is supplied, it
is used as a separator.
rule length ( s * )Find the length of any sequence.
rule unique ( list * : stable ? )Removes duplicates from list.
If stable is passed, then the order
of the elements will be unchanged.
rule max-element ( elements + : ordered ? )Returns the maximum number in elements.
Uses ordered for comparisons or
numbers.less
if none is provided.
rule select-highest-ranked ( elements * : ranks * )Returns all of elements for which
the corresponding element in the parallel list
rank is equal to the maximum value in
rank.
Deals with target type declaration and defines target class which supports typed targets.
rule register ( type : suffixes * : base-type ? )
Registers a target type, possible derived from a
base-type. Providing a list
of suffixes here is a shortcut for separately calling the
register-suffixes
rule with the given suffixes and the
set-generated-target-suffix
rule with the first given suffix.
rule register-suffixes ( suffixes + : type )
Specifies that files with suffix from suffixes
be recognized as targets of type type.
Issues an error if a different type is already specified for any
of the suffixes.
rule registered ( type )Returns true iff type has been registered.
rule validate ( type )Issues an error if type is unknown.
rule set-scanner ( type : scanner )Sets a scanner class that will be used for this type.
rule get-scanner ( type : property-set )
Returns a scanner instance appropriate to type
and property-set.
rule base ( type )Returns a base type for the given type or nothing in case the given type is not derived.
rule all-bases ( type )Returns the given type and all of its base types in order of their distance from type.
rule all-derived ( type )Returns the given type and all of its derived types in order of their distance from type.
rule is-derived ( type base )
Returns true if type is equal to
base or has base
as its direct or indirect base.
rule set-generated-target-suffix ( type : properties * : suffix )
Sets a file suffix to be used when generating a target of type with the
specified properties. Can be called with no properties if no suffix has
already been specified for the type. The suffix parameter can be an empty
string ("") to indicate that no suffix should be used.
Note that this does not cause files with suffix
to be automatically recognized as being of type.
Two different types can use the same suffix for their generated files
but only one type can be auto-detected for a file with that suffix.
User should explicitly specify which one using the
register-suffixes
rule.
rule change-generated-target-suffix ( type : properties * : suffix )Change the suffix previously registered for this type/properties combination. If suffix is not yet specified, sets it.
rule generated-target-suffix ( type : property-set )
Returns the suffix used when generating a file of
type with the given properties.
rule set-generated-target-prefix ( type : properties * : prefix )
Sets a target prefix that should be used when generating targets of
type with the specified properties. Can
be called with empty properties if no prefix for
type has been specified yet.
The prefix parameter can be empty string
("") to indicate that no prefix
should be used.
Usage example: library names use the "lib"
prefix on unix.
rule change-generated-target-prefix ( type : properties * : prefix )Change the prefix previously registered for this type/properties combination. If prefix is not yet specified, sets it.
rule generated-target-prefix ( type : property-set )
Returns the prefix used when generating a file of
type with the given properties.
rule type ( filename )Returns file type given its name. If there are several dots in filename, tries each suffix. E.g. for name of "file.so.1.2" suffixes "2", "1", and "so" will be tried.
Base class for all abstract targets.
class abstract-target { rule __init__ ( name : project ) rule name ( ) rule project ( ) rule location ( ) rule full-name ( ) rule generate ( property-set ) }
Classes derived from abstract-target:
rule __init__ ( name : project )
nameThe name of the target in the Jamfile.
projectThe project to which this target belongs.
rule name ( )Returns the name of this target.
rule project ( )Returns the project for this target.
rule location ( )Returns the location where the target was declared.
rule full-name ( )Returns a user-readable name for this target.
rule generate ( property-set )Generates virtual targets for this abstract target using the specified properties, unless a different value of some feature is required by the target. This is an abstract method which must be overriden by derived classes.
On success, returns:
If property-set is empty, performs the
default build of this target, in a way specific to the derived class.
class project-target : abstract-target { rule generate ( property-set ) rule build-dir ( ) rule main-target ( name ) rule has-main-target ( name ) rule find ( id : no-error ? ) # Methods inherited from abstract-target rule name ( ) rule project ( ) rule location ( ) rule full-name ( ) }
This class has the following responsibilities:
Maintaining a list of main targets in this project and building them.
rule generate ( property-set )Overrides abstract-target.generate. Generates virtual targets for all the targets contained in this project.
On success, returns:
rule build-dir ( )Returns the root build directory of the project.
rule main-target ( name )
Returns a main-target
class instance corresponding to name.
Can only be called after the project has been fully loaded.
rule has-main-target ( name )Returns whether a main-target with the specified name exists. Can only be called after the project has been fully loaded.
rule find ( id : no-error ? )
Find and return the target with the specified id, treated relative to
self. Id may specify either a target or a file name with the target taking
priority. May report an error or return nothing if the target is not found
depending on the no-error parameter.
class main-target : abstract-target { rule generate ( property-set ) # Methods inherited from abstract-target rule name ( ) rule project ( ) rule location ( ) rule full-name ( ) }
A main-target represents a named top-level target in a Jamfile.
rule generate ( property-set )
Overrides
abstract-target.generate.
Select an alternative for this main target, by finding all alternatives
whose requirements are satisfied by property-set and
picking the one with the longest requirements set. Returns the result
of calling generate
on that alternative.
On success, returns:
class basic-target : abstract-target { rule __init__ ( name : project : sources * : requirements * : default-build * : usage-requirements * ) rule generate ( property-set ) rule construct ( name : source-targets * : property-set ) # Methods inherited from abstract-target rule name ( ) rule project ( ) rule location ( ) rule full-name ( ) }
Implements the most standard way of constructing main target alternative from sources. Allows sources to be either files or other main targets and handles generation of those dependency targets.
rule __init__ ( name : project : sources * : requirements * : default-build * : usage-requirements * )
nameThe name of the target
projectThe project in which the target is declared.
rule generate ( property-set )Overrides abstract-target.generate. Determines final build properties, generates sources, and calls construct. This method should not be overridden.
On success, returns:
rule construct ( name : source-targets * : property-set )Constructs virtual targets for this abstract target. Returns a usage-requirements property-set and a list of virtual targets. Should be overriden in derived classes.
class typed-target : basic-target { rule __init__ ( name : project : type : sources * : requirements * : default-build * : usage-requirements * ) rule type ( ) rule construct ( name : source-targets * : property-set ) # Methods inherited from abstract-target rule name ( ) rule project ( ) rule location ( ) rule full-name ( ) # Methods inherited from basic-target rule generate ( property-set ) }
typed-target is the most common kind of target alternative. Rules for creating typed targets are defined automatically for each type.
rule __init__ ( name : project : type : sources * : requirements * : default-build * : usage-requirements * )
rule type ( )Returns the type of the target.
rule construct ( name : source-targets * : property-set )Implements basic-target.construct. Attempts to create a target of the correct type using generators appropriate for the given property-set. Returns a property-set containing the usage requirements and a list of virtual targets.
![]() |
Note |
|---|---|
This function is invoked automatically by basic-target.generate and should not be called directly by users. |
Class for storing a set of properties.
class property-set { rule raw ( ) rule str ( ) rule propagated ( ) rule add ( ps ) rule add-raw ( properties * ) rule refine ( ps ) rule get ( feature ) }
There is 1<->1 correspondence between identity and value. No two instances of the class are equal. To maintain this property, the 'property-set.create' rule should be used to create new instances. Instances are immutable.
rule raw ( )Returns a Jam list of the stored properties.
rule str ( )Returns the string repesentation of the stored properties.
rule propagated ( )Returns a property-set containing all the propagated properties in this property-set.
rule add ( ps )
Returns a new
property-set containing the union of the properties
in this
property-set and in ps.
![]() |
Note |
|---|---|
If |
rule add-raw ( properties * )Link add, except that it takes a list of properties instead of a property-set.
rule refine ( ps )
Refines properties by overriding any non-free and non-conditional
properties for which a different value is specified in
ps. Returns the resulting
property-set.
rule get ( feature )
Returns all the values of feature.
The general overview of the build process was given in the user documentation. This section provides additional details, and some specific rules.
To recap, building a target with specific properties includes the following steps:
applying default build,
selecting the main target alternative to use,
determining "common" properties,
building targets referred by the sources list and dependency properties,
adding the usage requirements produces when building dependencies to the "common" properties,
building the target using generators,
computing the usage requirements to be returned.
When there are several alternatives, one of them must be selected. The process is as follows:
The "common" properties is a somewhat artificial term. Those are the intermediate property set from which both the build request for dependencies and properties for building the target are derived.
Since default build and alternatives are already handled, we have only two inputs: build requests and requirements. Here are the rules about common properties.
Non-free feature can have only one value
A non-conditional property in requirement in always present in common properties.
A property in build request is present in common properties, unless (2) tells otherwise.
If either build request, or requirements (non-conditional or conditional) include an expandable property (either composite, or property with specified subfeature value), the behaviour is equivalent to explicitly adding all expanded properties to build request or requirements.
If requirements include a conditional property, and condiiton of this property is true in context of common properties, then the conditional property should be in common properties as well.
If no value for a feature is given by other rules here, it has default value in common properties.
Those rules are declarative, they don't specify how to compute the common properties. However, they provide enough information for the user. The important point is the handling of conditional requirements. The condition can be satisfied either by property in build request, by non-conditional requirements, or even by another conditional property. For example, the following example works as expected:
exe a : a.cpp
: <toolset>gcc:<variant>release
<variant>release:<define>FOO ;
Several factors determine the location of a concrete
file target. All files in a project are built under
the directory bin unless this is overriden by the build-dir project
attribute. Under bin is a path that depends on the properties
used to build each target. This path is uniquely determined by
all non-free, non-incidental properties. For example,
given a property set containing:
<toolset>gcc <toolset-gcc:version>4.6.1 <variant>debug
<warnings>all <define>_DEBUG <include>/usr/local/include
<link>static,
the path will be gcc-4.6.1/debug/link-static. <warnings> is an
incidental feature and <define> and <include> are
free features, so they do not affect the path.
Sometimes the paths produced by Boost.Build can become excessively long. There are a couple of command line options that can help with this. --abbreviate-paths reduces each element to no more than five characters. For example, link-static becomes lnk-sttc. The --hash option reduces the path to a single directory using an MD5 hash.
There are two features that affect the build directory. The <location> feature completely overrides the default build directory. For example,
exe a : a.cpp : <location>. ;
builds all the files produced by a
in the directory of the Jamfile. This is generally
discouraged, as it precludes variant builds.
The <location-prefix> feature adds a prefix to the path, under the project's build directory. For example,
exe a : a.cpp : <location-prefix>subdir ;
will create the files for a in bin/subdir/gcc-4.6.1/debug
A feature is a normalized (toolset-independent)
aspect of a build configuration, such as whether inlining is
enabled. Feature names may not contain the '>'
character.
Each feature in a build configuration has one or more
associated values. Feature values for non-free features
may not contain the '<', ':', or
'=' characters. Feature values for free features may not
contain the '<' character.
A property is a (feature,value) pair, expressed as <feature>value.
A subfeature is a feature that only exists in the presence of its parent feature, and whose identity can be derived (in the context of its parent) from its value. A subfeature's parent can never be another subfeature. Thus, features and their subfeatures form a two-level hierarchy.
A value-string for a feature F is a string of
the form
value-subvalue1-subvalue2...-subvalueN, where
value is a legal value for F and
subvalue1...subvalueN are legal values of some
of F's subfeatures. For example, the properties
<toolset>gcc <toolset-version>3.0.1 can be
expressed more conscisely using a value-string, as
<toolset>gcc-3.0.1.
A property set is a set of properties (i.e. a
collection without duplicates), for instance:
<toolset>gcc <runtime-link>static.
A property path is a property set whose elements have
been joined into a single string separated by slashes. A property
path representation of the previous example would be
<toolset>gcc/<runtime-link>static.
A build specification is a property set that fully describes the set of features used to build a target.
For free
features, all values are valid. For all other features,
the valid values are explicitly specified, and the build
system will report an error for the use of an invalid
feature-value. Subproperty validity may be restricted so
that certain values are valid only in the presence of
certain other subproperties. For example, it is possible
to specify that the <gcc-target>mingw
property is only valid in the presence of
<gcc-version>2.95.2.
Each feature has a collection of zero or more of the following attributes. Feature attributes are low-level descriptions of how the build system should interpret a feature's values when they appear in a build request. We also refer to the attributes of properties, so that an incidental property, for example, is one whose feature has the incidental attribute.
incidental
Incidental features are assumed not to affect build products at all. As a consequence, the build system may use the same file for targets whose build specification differs only in incidental features. A feature that controls a compiler's warning level is one example of a likely incidental feature.
Non-incidental features are assumed to affect build products, so the files for targets whose build specification differs in non-incidental features are placed in different directories as described in the section called “Target Paths”.
Features of this kind are
propagated to dependencies. That is, if a main target is built using a
propagated
property, the build systems attempts to use the same property
when building any of its dependencies as part of that main
target. For instance, when an optimized exectuable is
requested, one usually wants it to be linked with optimized
libraries. Thus, the <optimization> feature is
propagated.
Most features have a finite set of allowed values, and can only take on a single value from that set in a given build specification. Free features, on the other hand, can have several values at a time and each value can be an arbitrary string. For example, it is possible to have several preprocessor symbols defined simultaneously:
<define>NDEBUG=1 <define>HAS_CONFIG_H=1
optional
An optional feature is a feature that is not required to appear in a build specification. Every non-optional non-free feature has a default value that is used when a value for the feature is not otherwise specified, either in a target's requirements or in the user's build request. [A feature's default value is given by the first value listed in the feature's declaration. -- move this elsewhere - dwa]
symmetric
Normally a feature only generates a subvariant directory when its value differs from its default value, leading to an assymmetric subvariant directory structure for certain values of the feature. A symmetric feature always generates a corresponding subvariant directory.
path
The value of a path feature specifies a path. The path is treated as relative to the directory of Jamfile where path feature is used and is translated appropriately by the build system when the build is invoked from a different directory
implicit
Values of implicit features alone identify the feature. For example, a user is not required to write "<toolset>gcc", but can simply write "gcc". Implicit feature names also don't appear in variant paths, although the values do. Thus: bin/gcc/... as opposed to bin/toolset-gcc/.... There should typically be only a few such features, to avoid possible name clashes.
composite
Composite features actually correspond to groups of properties. For example, a build variant is a composite feature. When generating targets from a set of build properties, composite features are recursively expanded and added to the build property set, so rules can find them if necessary. Non-composite non-free features override components of composite features in a build property set.
dependency
The value of a dependency feature is a target reference. When used for building of a main target, the value of dependency feature is treated as additional dependency.
For example, dependency features allow to state that library A depends on library B. As the result, whenever an application will link to A, it will also link to B. Specifying B as dependency of A is different from adding B to the sources of A.
Features that are neither free nor incidental are called base features.
When a target with certain properties is requested, and that target requires some set of properties, it is needed to find the set of properties to use for building. This process is called property refinement and is performed by these rules
Sometime it's desirable to apply certain requirements only for a specific combination of other properties. For example, one of compilers that you use issues a pointless warning that you want to suppress by passing a command line option to it. You would not want to pass that option to other compilers. Conditional properties allow you to do just that. Their syntax is:
property ( "," property ) * ":" property
For example, the problem above would be solved by:
exe hello : hello.cpp : <toolset>yfc:<cxxflags>-disable-pointless-warning ;
The syntax also allows several properties in the condition, for example:
exe hello : hello.cpp : <os>NT,<toolset>gcc:<link>static ;
Target identifier is used to denote a target. The syntax is:
target-id -> (project-id | target-name | file-name )
| (project-id | directory-name) "//" target-name
project-id -> path
target-name -> path
file-name -> path
directory-name -> path
This grammar allows some elements to be recognized as either
To determine the real meaning a check is made if project-id by the specified name exists, and then if main target of that name exists. For example, valid target ids might be:
a -- target in current project lib/b.cpp -- regular file /boost/thread -- project "/boost/thread" /home/ghost/build/lr_library//parser -- target in specific project
Rationale:Target is separated from project by special separator (not just slash), because:
Target reference is used to specify a source target, and may additionally specify desired properties for that target. It has this syntax:
target-reference -> target-id [ "/" requested-properties ] requested-properties -> property-path
For example,
exe compiler : compiler.cpp libs/cmdline/<optimization>space ;
would cause the version of cmdline library,
optimized for space, to be linked in even if the
compiler executable is build with optimization for
speed.