diff options
| author | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
| commit | e0737c56c1e384e05064a0c6e1ac46979371041b (patch) | |
| tree | a0123d694a2d36c43dabdf0a3907392fce11d457 /boost/tools/build/doc/src | |
| parent | b4aebf2d137b892f53503b13785ecae900062ff7 (diff) | |
New upstream version 2.0.0+repackupstream/2.0.0+repack
Diffstat (limited to 'boost/tools/build/doc/src')
23 files changed, 10153 insertions, 0 deletions
diff --git a/boost/tools/build/doc/src/abstract-target.xml b/boost/tools/build/doc/src/abstract-target.xml new file mode 100644 index 00000000..dad53380 --- /dev/null +++ b/boost/tools/build/doc/src/abstract-target.xml @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<section id="bbv2.reference.class.abstract-target"> + + <title>Class abstract-target</title> + <indexterm> + <primary>abstract-target</primary> + </indexterm> + + <para> + Base class for all abstract targets. + </para> + +<programlisting language="jam"> +class abstract-target { + rule <link linkend="bbv2.reference.class.abstract-target.__init__">__init__</link> ( name : project ) + rule <link linkend="bbv2.reference.class.abstract-target.name">name</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.project">project</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.location">location</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.full-name">full-name</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.__init__">generate</link> ( property-set ) +} +</programlisting> + + <para> + Classes derived from <link linkend="bbv2.reference.class.abstract-target">abstract-target</link>: + <itemizedlist> + <listitem> + <link linkend="bbv2.reference.class.project-target">project-target</link> + </listitem> + <listitem> + <link linkend="bbv2.reference.class.main-target">main-target</link> + </listitem> + <listitem> + <link linkend="bbv2.reference.class.project-target">basic-target</link> + </listitem> + </itemizedlist> + </para> + + <orderedlist> + + <listitem id="bbv2.reference.class.abstract-target.__init__"> + <code language="jam">rule __init__ ( name : project )</code> + <para> + <variablelist> + <varlistentry> + <term><literal>name</literal></term> + <listitem> + <para>The name of the target in the Jamfile.</para> + </listitem> + </varlistentry> + <varlistentry> + <term><literal>project</literal></term> + <listitem> + <para>The <link linkend="bbv2.reference.class.project-target">project</link> to which this target belongs.</para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + + <listitem id="bbv2.reference.class.abstract-target.name"> + <indexterm zone="bbv2.reference.class.abstract-target.name"> + <primary>name</primary> + <secondary>Abstract Target</secondary> + </indexterm> + <code language="jam">rule name ( )</code> + <para>Returns the name of this target.</para> + </listitem> + + <listitem id="bbv2.reference.class.abstract-target.project"> + <indexterm zone="bbv2.reference.class.abstract-target.project"> + <primary>project</primary> + <secondary>Abstract Target</secondary> + </indexterm> + <code language="jam">rule project ( )</code> + <para>Returns the <link linkend="bbv2.reference.class.project-target">project</link> for this target.</para> + </listitem> + + <listitem id="bbv2.reference.class.abstract-target.location"> + <indexterm zone="bbv2.reference.class.abstract-target.location"> + <primary>location</primary> + <secondary>Abstract Target</secondary> + </indexterm> + <code language="jam">rule location ( )</code> + <para>Returns the location where the target was declared.</para> + </listitem> + + <listitem id="bbv2.reference.class.abstract-target.full-name"> + <indexterm zone="bbv2.reference.class.abstract-target.full-name"> + <primary>full-name</primary> + <secondary>Abstract Target</secondary> + </indexterm> + <code language="jam">rule full-name ( )</code> + <para>Returns a user-readable name for this target.</para> + </listitem> + + <listitem id="bbv2.reference.class.abstract-target.generate"> + <indexterm zone="bbv2.reference.class.abstract-target.generate"> + <primary>generate</primary> + <secondary>Abstract Target</secondary> + </indexterm> + <code language="jam">rule generate ( property-set )</code> + <para> + 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. + </para> + + <para> + On success, returns: + <itemizedlist> + <listitem>a property-set with the usage requirements to be applied to dependents</listitem> + <listitem>a list of produced virtual targets, which may be empty.</listitem> + </itemizedlist> + If <code language="jam">property-set</code> is empty, performs the + default build of this target, in a way specific to the derived class. + </para> + </listitem> + + </orderedlist> + +</section> diff --git a/boost/tools/build/doc/src/architecture.xml b/boost/tools/build/doc/src/architecture.xml new file mode 100644 index 00000000..0b22defe --- /dev/null +++ b/boost/tools/build/doc/src/architecture.xml @@ -0,0 +1,668 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE appendix PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + + <appendix id="bbv2.arch"> + <title>Boost.Build v2 architecture</title> + + <sidebar> + <para> + This document is work-in progress. Do not expect much from it yet. + </para> + </sidebar> + + <section id="bbv2.arch.overview"> + <title>Overview</title> + + <!-- FIXME: the below does not mention engine at all, making rest of the + text confusing. Things like 'kernel' and 'util' don't have to be + mentioned at all. --> + <para> + Boost.Build implementation is structured in four different components: + "kernel", "util", "build" and "tools". The first two are relatively + uninteresting, so we will focus on the remaining pair. The "build" component + provides classes necessary to declare targets, determining which properties + should be used for their building, and creating the dependency graph. The + "tools" component provides user-visible functionality. It mostly allows + declaring specific kinds of main targets, as well as registering available + tools, which are then used when creating the dependency graph. + </para> + </section> + + <section id="bbv2.arch.build"> + <title>The build layer</title> + + <para> + The build layer has just four main parts -- metatargets (abstract + targets), virtual targets, generators and properties. + + <itemizedlist> + <listitem><para> + Metatargets (see the "targets.jam" module) represent all the + user-defined entities that can be built. The "meta" prefix signifies + that they do not need to correspond to exact files or even files at all + -- they can produce a different set of files depending on the build + request. Metatargets are created when Jamfiles are loaded. Each has a + <code>generate</code> method which is given a property set and produces + virtual targets for the passed properties. + </para></listitem> + <listitem><para> + Virtual targets (see the "virtual-targets.jam" module) correspond to + actual atomic updatable entities -- most typically files. + </para></listitem> + <listitem><para> + Properties are just (name, value) pairs, specified by the user and + describing how targets should be built. Properties are stored using the + <code>property-set</code> class. + </para></listitem> + <listitem><para> + Generators are objects that encapsulate specific tools -- they can + take a list of source virtual targets and produce new virtual targets + from them. + </para></listitem> + </itemizedlist> + + </para> + + <para> + The build process includes the following steps: + + <orderedlist> + <listitem><para> + Top-level code calls the <code>generate</code> method of a metatarget + with some properties. + </para></listitem> + + <listitem><para> + The metatarget combines the requested properties with its requirements + and passes the result, together with the list of sources, to the + <code>generators.construct</code> function. + </para></listitem> + + <listitem><para> + A generator appropriate for the build properties is selected and its + <code>run</code> method is called. The method returns a list of virtual + targets. + </para></listitem> + + <listitem><para> + The virtual targets are returned to the top level code, and for each instance, + the <literal>actualize</literal> method is called to setup nodes and updating + actions in the depenendency graph kepts inside Boost.Build engine. This dependency + graph is then updated, which runs necessary commands. + </para></listitem> + </orderedlist> + </para> + + <section id="bbv2.arch.build.metatargets"> + <title>Metatargets</title> + + <para> + There are several classes derived from "abstract-target". The + "main-target" class represents a top-level main target, the + "project-target" class acts like a container holding multiple main + targets, and "basic-target" class is a base class for all further target + types. + </para> + + <para> + Since each main target can have several alternatives, all top-level + target objects are actually containers, referring to "real" main target + classes. The type of that container is "main-target". For example, given: +<programlisting> +alias a ; +lib a : a.cpp : <toolset>gcc ; +</programlisting> + we would have one-top level "main-target" instance, containing one + "alias-target" and one "lib-target" instance. "main-target"'s "generate" + method decides which of the alternative should be used, and calls + "generate" on the corresponding instance. + </para> + + <para> + Each alternative is an instance of a class derived from "basic-target". + "basic-target.generate" does several things that should always be done: + + <itemizedlist> + <listitem><para> + Determines what properties should be used for building the target. + This includes looking at requested properties, requirements, and usage + requirements of all sources. + </para></listitem> + + <listitem><para> + Builds all sources. + </para></listitem> + + <listitem><para> + Computes usage requirements that should be passed back to targets + depending on this one. + </para></listitem> + </itemizedlist> + + For the real work of constructing a virtual target, a new method + "construct" is called. + </para> + + <para> + The "construct" method can be implemented in any way by classes derived + from "basic-target", but one specific derived class plays the central role + -- "typed-target". That class holds the desired type of file to be + produced, and its "construct" method uses the generators module to do the + actual work. + </para> + + <para> + This means that a specific metatarget subclass may avoid using + generators all together. However, this is deprecated and we are trying to + eliminate all such subclasses at the moment. + </para> + + <para> + Note that the <filename>build/targets.jam</filename> file contains an + UML diagram which might help. + </para> + </section> + + <section id="bbv2.arch.build.virtual"> + <title>Virtual targets</title> + + <para> + Virtual targets are atomic updatable entities. Each virtual + target can be assigned an updating action -- instance of the + <code>action</code> class. The action class, in turn, contains a list of + source targets, properties, and a name of an action which + should be executed. + </para> + + <para> + We try hard to never create equal instances of the + <code>virtual-target</code> class. Code creating virtual targets passes + them though the <code>virtual-target.register</code> function, which + detects if a target with the same name, sources, and properties has + already been created. In that case, the preexisting target is returned. + </para> + + <!-- FIXME: the below 2 para are rubbish, must be totally rewritten. --> + <para> + When all virtual targets are produced, they are "actualized". This means + that the real file names are computed, and the commands that should be run + are generated. This is done by the <code>virtual-target.actualize</code> + and <code>action.actualize</code> methods. The first is conceptually + simple, while the second needs additional explanation. Commands in Boost.Build + are generated in a two-stage process. First, a rule with an appropriate + name (for example "gcc.compile") is called and is given a list of target + names. The rule sets some variables, like "OPTIONS". After that, the + command string is taken, and variable are substitutes, so use of OPTIONS + inside the command string gets transformed into actual compile options. + </para> + + <para> + Boost.Build added a third stage to simplify things. It is now possible + to automatically convert properties to appropriate variable assignments. + For example, <debug-symbols>on would add "-g" to the OPTIONS + variable, without requiring to manually add this logic to gcc.compile. + This functionality is part of the "toolset" module. + </para> + + <para> + Note that the <filename>build/virtual-targets.jam</filename> file + contains an UML diagram which might help. + </para> + </section> + + <section id="bbv2.arch.build.properties"> + <title>Properties</title> + + <para> + Above, we noted that metatargets are built with a set of properties. + That set is represented by the <code>property-set</code> class. An + important point is that handling of property sets can get very expensive. + For that reason, we make sure that for each set of (name, value) pairs + only one <code>property-set</code> instance is created. The + <code>property-set</code> uses extensive caching for all operations, so + most work is avoided. The <code>property-set.create</code> is the factory + function used to create instances of the <code>property-set</code> class. + </para> + </section> + </section> + + <section id="bbv2.arch.tools"> + <title>The tools layer</title> + + <para>Write me!</para> + </section> + + <section id="bbv2.arch.targets"> + <title>Targets</title> + + <para>NOTE: THIS SECTION IS NOT EXPECTED TO BE READ! + There are two user-visible kinds of targets in Boost.Build. First are + "abstract" — they correspond to things declared by the user, e.g. + projects and executable files. The primary thing about abstract targets is + that it is possible to request them to be built with a particular set of + properties. Each property combination may possibly yield different built + files, so abstract target do not have a direct correspondence to built + files. + </para> + + <para> + File targets, on the other hand, are associated with concrete files. + Dependency graphs for abstract targets with specific properties are + constructed from file targets. User has no way to create file targets but + can specify rules for detecting source file types, as well as rules for + transforming between file targets of different types. That information is + used in constructing the final dependency graph, as described in the <link + linkend="bbv2.arch.depends">next section</link>. + <emphasis role="bold">Note:</emphasis>File targets are not the same entities + as Jam targets; the latter are created from file targets at the latest + possible moment. + <emphasis role="bold">Note:</emphasis>"File target" is an originally + proposed name for what we now call virtual targets. It is more + understandable by users, but has one problem: virtual targets can + potentially be "phony", and not correspond to any file. + </para> + </section> + + <section id="bbv2.arch.depends"> + <title>Dependency scanning</title> + + <para> + Dependency scanning is the process of finding implicit dependencies, like + "#include" statements in C++. The requirements for correct dependency + scanning mechanism are: + </para> + + <itemizedlist> + <listitem><simpara> + <link linkend="bbv2.arch.depends.different-scanning-algorithms">Support + for different scanning algorithms</link>. C++ and XML have quite different + syntax for includes and rules for looking up the included files. + </simpara></listitem> + + <listitem><simpara> + <link linkend="bbv2.arch.depends.same-file-different-scanners">Ability + to scan the same file several times</link>. For example, a single C++ file + may be compiled using different include paths. + </simpara></listitem> + + <listitem><simpara> + <link linkend="bbv2.arch.depends.dependencies-on-generated-files">Proper + detection of dependencies on generated files.</link> + </simpara></listitem> + + <listitem><simpara> + <link + linkend="bbv2.arch.depends.dependencies-from-generatedfiles">Proper + detection of dependencies from a generated file.</link> + </simpara></listitem> + </itemizedlist> + + <section id="bbv2.arch.depends.different-scanning-algorithms"> + <title>Support for different scanning algorithms</title> + + <para> + Different scanning algorithm are encapsulated by objects called + "scanners". Please see the "scanner" module documentation for more + details. + </para> + </section> + + <section id="bbv2.arch.depends.same-file-different-scanners"> + <title>Ability to scan the same file several times</title> + + <para> + As stated above, it is possible to compile a C++ file multiple times, + using different include paths. Therefore, include dependencies for those + compilations can be different. The problem is that Boost.Build engine does + not allow multiple scans of the same target. To solve that, we pass the + scanner object when calling <literal>virtual-target.actualize</literal> + and it creates different engine targets for different scanners. + </para> + + <para> + For each engine target created with a specified scanner, a + corresponding one is created without it. The updating action is + associated with the scanner-less target, and the target with the scanner + is made to depend on it. That way if sources for that action are touched, + all targets — with and without the scanner are considered outdated. + </para> + + <para> + Consider the following example: "a.cpp" prepared from "a.verbatim", + compiled by two compilers using different include paths and copied into + some install location. The dependency graph would look like: + </para> + +<programlisting> +a.o (<toolset>gcc) <--(compile)-- a.cpp (scanner1) ----+ +a.o (<toolset>msvc) <--(compile)-- a.cpp (scanner2) ----| +a.cpp (installed copy) <--(copy) ----------------------- a.cpp (no scanner) + ^ + | + a.verbose --------------------------------+ +</programlisting> + </section> + + <section id="bbv2.arch.depends.dependencies-on-generated-files"> + <title>Proper detection of dependencies on generated files.</title> + + <para> + This requirement breaks down to the following ones. + </para> + + <orderedlist> + <listitem><simpara> + If when compiling "a.cpp" there is an include of "a.h", the "dir" + directory is on the include path, and a target called "a.h" will be + generated in "dir", then Boost.Build should discover the include, and create + "a.h" before compiling "a.cpp". + </simpara></listitem> + + <listitem><simpara> + Since Boost.Build almost always generates targets under the "bin" + directory, this should be supported as well. I.e. in the scenario above, + Jamfile in "dir" might create a main target, which generates "a.h". The + file will be generated to "dir/bin" directory, but we still have to + recognize the dependency. + </simpara></listitem> + </orderedlist> + + <para> + The first requirement means that when determining what "a.h" means when + found in "a.cpp", we have to iterate over all directories in include + paths, checking for each one: + </para> + + <orderedlist> + <listitem><simpara> + If there is a file named "a.h" in that directory, or + </simpara></listitem> + + <listitem><simpara> + If there is a target called "a.h", which will be generated in that + that directory. + </simpara></listitem> + </orderedlist> + + <para> + Classic Jam has built-in facilities for point (1) above, but that is not + enough. It is hard to implement the right semantics without builtin + support. For example, we could try to check if there exists a target + called "a.h" somewhere in the dependency graph, and add a dependency to + it. The problem is that without a file search in the include path, the + semantics may be incorrect. For example, one can have an action that + generated some "dummy" header, for systems which do not have a native one. + Naturally, we do not want to depend on that generated header on platforms + where a native one is included. + </para> + + <para> + There are two design choices for builtin support. Suppose we have files + a.cpp and b.cpp, and each one includes header.h, generated by some action. + Dependency graph created by classic Jam would look like: + +<programlisting> +a.cpp -----> <scanner1>header.h [search path: d1, d2, d3] + + <d2>header.h --------> header.y + [generated in d2] + +b.cpp -----> <scanner2>header.h [search path: d1, d2, d4] +</programlisting> + </para> + + <para> + In this case, Jam thinks all header.h target are not related. The + correct dependency graph might be: + +<programlisting> +a.cpp ---- + \ + >----> <d2>header.h --------> header.y + / [generated in d2] +b.cpp ---- +</programlisting> + + or + +<programlisting> +a.cpp -----> <scanner1>header.h [search path: d1, d2, d3] + | + (includes) + V + <d2>header.h --------> header.y + [generated in d2] + ^ + (includes) + | +b.cpp -----> <scanner2>header.h [ search path: d1, d2, d4] +</programlisting> + </para> + + <para> + The first alternative was used for some time. The problem however is: + what include paths should be used when scanning header.h? The second + alternative was suggested by Matt Armstrong. It has a similar effect: Any + target depending on <scanner1>header.h will also depend on + <d2>header.h. This way though we now have two different targets with + two different scanners, so those targets can be scanned independently. The + first alternative's problem is avoided, so the second alternative is + implemented now. + </para> + + <para> + The second sub-requirements is that targets generated under the "bin" + directory are handled as well. Boost.Build implements a semi-automatic + approach. When compiling C++ files the process is: + </para> + + <orderedlist> + <listitem><simpara> + The main target to which the compiled file belongs to is found. + </simpara></listitem> + + <listitem><simpara> + All other main targets that the found one depends on are found. These + include: main targets used as sources as well as those specified as + "dependency" properties. + </simpara></listitem> + + <listitem><simpara> + All directories where files belonging to those main targets will be + generated are added to the include path. + </simpara></listitem> + </orderedlist> + + <para> + After this is done, dependencies are found by the approach explained + previously. + </para> + + <para> + Note that if a target uses generated headers from another main target, + that main target should be explicitly specified using the dependency + property. It would be better to lift this requirement, but it does not + seem to be causing any problems in practice. + </para> + + <para> + For target types other than C++, adding of include paths must be + implemented anew. + </para> + </section> + + <section id="bbv2.arch.depends.dependencies-from-generated-files"> + <title>Proper detection of dependencies from generated files</title> + + <para> + Suppose file "a.cpp" includes "a.h" and both are generated by some + action. Note that classic Jam has two stages. In the first stage the + dependency graph is built and actions to be run are determined. In the + second stage the actions are executed. Initially, neither file exists, so + the include is not found. As the result, Jam might attempt to compile + a.cpp before creating a.h, causing the compilation to fail. + </para> + + <para> + The solution in Boost.Jam is to perform additional dependency scans + after targets are updated. This breaks separation between build stages in + Jam — which some people consider a good thing — but I am not + aware of any better solution. + </para> + + <para> + In order to understand the rest of this section, you better read some + details about Jam's dependency scanning, available at <ulink url= + "http://public.perforce.com:8080/@md=d&cd=//public/jam/src/&ra=s&c=kVu@//2614?ac=10"> + this link</ulink>. + </para> + + <para> + Whenever a target is updated, Boost.Jam rescans it for includes. + Consider this graph, created before any actions are run. +<programlisting> +A -------> C ----> C.pro + / +B --/ C-includes ---> D +</programlisting> + </para> + + <para> + Both A and B have dependency on C and C-includes (the latter dependency + is not shown). Say during building we have tried to create A, then tried + to create C and successfully created C. + </para> + + <para> + In that case, the set of includes in C might well have changed. We do + not bother to detect precisely which includes were added or removed. + Instead we create another internal node C-includes-2. Then we determine + what actions should be run to update the target. In fact this means that + we perform the first stage logic when already in the execution stage. + </para> + + <para> + After actions for C-includes-2 are determined, we add C-includes-2 to + the list of A's dependents, and stage 2 proceeds as usual. Unfortunately, + we can not do the same with target B, since when it is not visited, C + target does not know B depends on it. So, we add a flag to C marking it as + rescanned. When visiting the B target, the flag is noticed and + C-includes-2 is added to the list of B's dependencies as well. + </para> + + <para> + Note also that internal nodes are sometimes updated too. Consider this + dependency graph: +<programlisting> +a.o ---> a.cpp + a.cpp-includes --> a.h (scanned) + a.h-includes ------> a.h (generated) + | + | + a.pro <-------------------------------------------+ +</programlisting> + </para> + + <para> + Here, our handling of generated headers come into play. Say that a.h + exists but is out of date with respect to "a.pro", then "a.h (generated)" + and "a.h-includes" will be marked for updating, but "a.h (scanned)" will + not. We have to rescan "a.h" after it has been created, but since "a.h + (generated)" has no associated scanner, it is only possible to rescan + "a.h" after "a.h-includes" target has been updated. + </para> + + <para> + The above consideration lead to the decision to rescan a target whenever + it is updated, no matter if it is internal or not. + </para> + + </section> + </section> + + <warning> + <para> + The remainder of this document is not intended to be read at all. This + will be rearranged in the future. + </para> + </warning> + + <section> + <title>File targets</title> + + <para> + As described above, file targets correspond to files that Boost.Build + manages. Users may be concerned about file targets in three ways: when + declaring file target types, when declaring transformations between types + and when determining where a file target is to be placed. File targets can + also be connected to actions that determine how the target is to be created. + Both file targets and actions are implemented in the + <literal>virtual-target</literal> module. + </para> + + <section> + <title>Types</title> + + <para> + A file target can be given a type, which determines what transformations + can be applied to the file. The <literal>type.register</literal> rule + declares new types. File type can also be assigned a scanner, which is + then used to find implicit dependencies. See "<link + linkend="bbv2.arch.depends">dependency scanning</link>". + </para> + </section> + + <section> + <title>Target paths</title> + + <para> + To distinguish targets build with different properties, they are put in + different directories. Rules for determining target paths are given below: + </para> + + <orderedlist> + <listitem><simpara> + All targets are placed under a directory corresponding to the project + where they are defined. + </simpara></listitem> + + <listitem><simpara> + Each non free, non incidental property causes an additional element to + be added to the target path. That element has the the form + <literal><feature-name>-<feature-value></literal> for + ordinary features and <literal><feature-value></literal> for + implicit ones. [TODO: Add note about composite features]. + </simpara></listitem> + + <listitem><simpara> + If the set of free, non incidental properties is different from the + set of free, non incidental properties for the project in which the main + target that uses the target is defined, a part of the form + <literal>main_target-<name></literal> is added to the target path. + <emphasis role="bold">Note:</emphasis>It would be nice to completely + track free features also, but this appears to be complex and not + extremely needed. + </simpara></listitem> + </orderedlist> + + <para> + For example, we might have these paths: +<programlisting> +debug/optimization-off +debug/main-target-a +</programlisting> + </para> + </section> + </section> + + </appendix> + +<!-- + Local Variables: + mode: xml + sgml-indent-data: t + sgml-parent-document: ("userman.xml" "chapter") + sgml-set-face: t + End: +--> diff --git a/boost/tools/build/doc/src/basic-target.xml b/boost/tools/build/doc/src/basic-target.xml new file mode 100644 index 00000000..ae7c2795 --- /dev/null +++ b/boost/tools/build/doc/src/basic-target.xml @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<section id="bbv2.reference.class.basic-target"> + + <title>Class basic-target</title> + <indexterm> + <primary>basic-target</primary> + </indexterm> + +<programlisting language="jam"> +class basic-target : <link linkend="bbv2.reference.class.abstract-target">abstract-target</link> { + rule <link linkend="bbv2.reference.class.basic-target.__init__">__init__</link> ( name : project : sources * : requirements * : default-build * : usage-requirements * ) + rule <link linkend="bbv2.reference.class.basic-target.generate">generate</link> ( property-set ) + rule <link linkend="bbv2.reference.class.basic-target.construct">construct</link> ( name : source-targets * : property-set ) + + # Methods inherited from <link linkend="bbv2.reference.class.abstract-target">abstract-target</link> + rule <link linkend="bbv2.reference.class.abstract-target.name">name</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.project">project</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.location">location</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.full-name">full-name</link> ( ) +} +</programlisting> + + <para> + 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. + <!-- FIXME: Better description of sources. The sources can be either target + references or instances of abstract-target. --> + </para> + + <orderedlist> + + <listitem id="bbv2.reference.class.basic-target.__init__"> + <code language="jam">rule __init__ ( name : project : sources * : requirements * : default-build * : usage-requirements * )</code> + <para> + <variablelist> + <varlistentry> + <term><literal>name</literal></term> + <listitem><para>The name of the target</para></listitem> + </varlistentry> + <varlistentry> + <term><literal>project</literal></term> + <listitem> + <para> + The <link linkend="bbv2.reference.class.project-target">project</link> + in which the target is declared. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + + <listitem id="bbv2.reference.class.basic-target.generate"> + <indexterm zone="bbv2.reference.class.basic-target.generate"> + <primary>generate</primary> + <secondary>Basic Target Method</secondary> + </indexterm> + <code language="jam">rule generate ( property-set )</code> + <para> + Overrides + <link linkend="bbv2.reference.class.abstract-target.generate">abstract-target.generate</link>. + + Determines final build properties, generates sources, and calls + <link linkend="bbv2.reference.class.basic-target.construct">construct</link>. + This method should not be overridden. + </para> + + <para> + On success, returns: + <itemizedlist> + <listitem>a property-set with the usage requirements to be applied to dependents</listitem> + <listitem>a list of produced virtual targets, which may be empty.</listitem> + </itemizedlist> + </para> + </listitem> + + <listitem id="bbv2.reference.class.basic-target.construct"> + <indexterm zone="bbv2.reference.class.basic-target.construct"> + <primary>construct</primary> + <secondary>Basic Target Method</secondary> + </indexterm> + <code language="jam">rule construct ( name : source-targets * : property-set )</code> + <para> + 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. + </para> + </listitem> + + </orderedlist> + +</section> diff --git a/boost/tools/build/doc/src/extending.xml b/boost/tools/build/doc/src/extending.xml new file mode 100644 index 00000000..e03a22c2 --- /dev/null +++ b/boost/tools/build/doc/src/extending.xml @@ -0,0 +1,1216 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE appendix PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + + <chapter id="bbv2.extender"> + <title>Extender Manual</title> + + <section id="bbv2.extender.intro"> + <title>Introduction</title> + + <para> + This section explains how to extend Boost.Build to accomodate your + local requirements—primarily to add support for non-standard + tools you have. Before we start, be sure you have read and understoon + the concept of metatarget, <xref linkend="bbv2.overview.concepts"/>, + which is critical to understanding the remaining material. + </para> + + <para> + The current version of Boost.Build has three levels of targets, listed + below. + </para> + + <variablelist> + + <varlistentry> + <term>metatarget</term> + <listitem> + <para> + Object that is created from declarations in Jamfiles. May + be called with a set of properties to produce concrete + targets. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term>concrete target</term> + <listitem> + <para> + Object that corresponds to a file or an action. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term>jam target</term> + <listitem> + <para> + Low-level concrete target that is specific to Boost.Jam build + engine. Essentially a string—most often a name of file. + </para> + </listitem> + </varlistentry> + + </variablelist> + + <para> + In most cases, you will only have to deal with concrete targets and + the process that creates concrete targets from + metatargets. Extending metatarget level is rarely required. The jam + targets are typically only used inside the command line patterns. + </para> + + <warning> + <para>All of the Boost.Jam target-related builtin functions, like + <code>DEPENDS</code> or <code>ALWAYS</code> operate on jam + targets. Applying them to metatargets or concrete targets has no + effect.</para> + </warning> + + <section id="bbv2.extender.overview.metatargets"> + <title>Metatargets</title> + + <para>Metatarget is an object that records information specified + in Jamfile, such as metatarget kind, name, sources and properties, + and can be called with specific properties to generate concrete + targets. At the code level it is represented by an instance of + class derived from <link linkend="bbv2.reference.class.abstract-target">abstract-target</link>. + <footnote><para>This name is historic, and will be eventuall changed to + <code>metatarget</code></para></footnote> + </para> + + <para>The <link linkend="bbv2.reference.class.abstract-target.generate">generate</link> + method takes the build properties + (as an instance of the <link linkend="bbv2.reference.class.property-set"> + property-set</link> class) and returns + a list containing:</para> + <itemizedlist> + <listitem><para>As front element—Usage-requirements from this invocation + (an instance of <link linkend="bbv2.reference.class.property-set"> + property-set</link>)</para></listitem> + <listitem><para>As subsequent elements—created concrete targets ( + instances of the <classname>virtual-target</classname> class.)</para></listitem> + </itemizedlist> + + <para>It's possible to lookup a metataget by target-id using the + <code>targets.resolve-reference</code> function, and the + <code>targets.generate-from-reference</code> function can both + lookup and generate a metatarget.</para> + + <para>The <link linkend="bbv2.reference.class.abstract-target">abstract-target</link> + class has three immediate derived classes:</para> + <itemizedlist> + + <listitem><para><link linkend="bbv2.reference.class.project-target">project-target</link> that + corresponds to a project and is not intended for further + subclassing. The <link linkend="bbv2.reference.class.project-target.generate"> + generate</link> method of this + class builds all targets in the project that are not marked as + explicit.</para></listitem> + + <listitem><para><link linkend="bbv2.reference.class.main-target">main-target</link> + corresponds to a target in a project + and contains one or more target alternatives. This class also should not be + subclassed. The <link linkend="bbv2.reference.class.main-target.generate">generate</link> + method of this class selects an alternative to build, and calls the + <link linkend="bbv2.reference.class.basic-target.generate">generate</link> + method of that alternative.</para></listitem> + + <listitem><para><link linkend="bbv2.reference.class.basic-target">basic-target</link> + corresponds to a specific target alternative. This is base class, + with a number of derived classes. The + <link linkend="bbv2.reference.class.basic-target.generate">generate</link> method + processes the target requirements and requested build properties to + determine final properties for the target, builds all sources, and + finally calls the abstract + <link linkend="bbv2.reference.class.basic-target.construct">construct</link> + method with the list of source virtual targets, and the final properties. + </para></listitem> + + </itemizedlist> + + <para>The instances of the <link linkend="bbv2.reference.class.project-target">project-target</link> and + <link linkend="bbv2.reference.class.main-target">main-target</link> classes are created + implicitly—when loading a new Jamfiles, or when a new target + alternative with as-yet unknown name is created. The instances of the + classes derived from <link linkend="bbv2.reference.class.basic-target">basic-target</link> + are typically created when Jamfile calls a <firstterm>metatarget rule</firstterm>, + such as such as <code>exe</code>. + </para> + + <para>It it permissible to create a custom class derived from + <link linkend="bbv2.reference.class.basic-target">basic-target</link> and create new metatarget rule + that creates instance of such target. However, in the majority + of cases, a specific subclass of <link linkend="bbv2.reference.class.basic-target">basic-target</link>— + <link linkend="bbv2.reference.class.typed-target">typed-target</link> is used. That class is associated + with a <firstterm>type</firstterm> and relays to <firstterm>generators</firstterm> + to construct concrete targets of that type. This process will be explained below. + When a new type is declared, a new metatarget rule is automatically defined. + That rule creates new instance of type-target, associated with that type. + </para> + + </section> + + <section id="bbv2.extender.overview.targets"> + <title>Concrete targets</title> + + <para>Concrete targets are represented by instance of classes derived + from <classname>virtual-target</classname>. The most commonly used + subclass is <classname>file-target</classname>. A file target is associated + with an action that creates it— an instance of the <classname>action</classname> + class. The action, in turn, hold a list of source targets. It also holds the + <link linkend="bbv2.reference.class.property-set">property-set</link> + instance with the build properties that should be used for the action.</para> + + <para>Here's an example of creating a target from another target, <code>source</code></para> +<programlisting> +local a = [ new action $(source) : common.copy : $(property-set) ] ; +local t = [ new file-target $(name) : CPP : $(project) : $(a) ] ; +</programlisting> + <para>The first line creates an instance of the <classname>action</classname> class. + The first parameter is the list of sources. The second parameter is the name + a jam-level <link linkend="bbv2.overview.jam_language.actions">action</link>. + The third parameter is the property-set applying to this action. The second line + creates a target. We specifie a name, a type and a project. We also pass the + action object created earlier. If the action creates several targets, we can repeat + the second line several times.</para> + + <para>In some cases, code that creates concrete targets may be invoked more than + once with the same properties. Returning to different instance of <classname>file-target</classname> + that correspond to the same file clearly will result in problems. Therefore, whenever + returning targets you should pass them via the <code>virtual-target.register</code> + function, besides allowing Boost.Build to track which virtual targets + got created for each metatarget, this will also replace targets with previously created identical + ones, as necessary.<footnote><para>This create-then-register pattern is caused by limitations + of the Boost.Jam language. Python port is likely to never create duplicate targets.</para></footnote> + Here are a couple of examples: +<programlisting> +return [ virtual-target.register $(t) ] ; +return [ sequence.transform virtual-target.register : $(targets) ] ; +</programlisting> + </para> + + </section> + + <section id="bbv2.extender.overview.generators"> + <title>Generators</title> + + <para>In theory, every kind of metatarget in Boost.Build (like <code>exe</code>, + <code>lib</code> or <code>obj</code>) could be implemented + by writing a new metatarget class that, independently of the other code, figures + what files to produce and what commands to use. However, that would be rather inflexible. + For example, adding support for a new compiler would require editing several metatargets. + </para> + + <para>In practice, most files have specific types, and most tools + consume and produce files of specific type. To take advantage of this + fact, Boost.Build defines concept of target type and + <indexterm><primary>generators</primary></indexterm> + <firstterm>generators</firstterm>, and has special metatarget class + <link linkend="bbv2.reference.class.typed-target">typed-target</link>. Target type is merely an + identifier. It is associated with a set of file extensions that + correspond to that type. Generator is an abstraction of a tool. It advertises + the types it produces and, if called with a set of input target, tries to construct + output targets of the advertised types. Finally, + <link linkend="bbv2.reference.class.typed-target">typed-target</link> + is associated with specific target type, and relays the generator (or generators) + for that type. + </para> + + <para>A generator is an instance of a class derived from <classname>generator</classname>. + The <classname>generator</classname> class itself is suitable for common cases. + You can define derived classes for custom scenarios.</para> + + <!-- + <para>Given a set of generators, the fundamental operation is to + construct a target of a given type, with given properties, from a + set of targets. That operation is performed by rule + <literal>generators.construct</literal> and the used algorithm is described + below.</para> + + <section> + <title>Selecting and ranking viable generators</title> + + <para>Each generator, in addition to target types that it can + produce, have attribute that affects its applicability in + particular sitiation. Those attributes are:</para> + + <orderedlist> + <listitem> + <simpara> + Required properties, which are properties absolutely + necessary for the generator to work. For example, generator + encapsulating the gcc compiler would have <toolset>gcc as + required property. + </simpara> + </listitem> + + <listitem> + <simpara> + Optional properties, which increase the generators + suitability for a particual build. + </simpara> + </listitem> + </orderedlist> + + <para> + Generator's required and optional properties may not include + either free or incidental properties. (Allowing this would + greatly complicate caching targets). + </para> + + <para>When trying to construct a target, the first step is to select + all possible generators for the requested target type, which + required properties are a subset of requested properties. + Generators that were already selected up the call stack are + excluded. In addition, if any composing generators were selected + up the call stack, all other composing generators are ignored + (TODO: define composing generators). The found generators + are assigned a rank, which is the number of optional properties + present in requested properties. Finally, generators with highest + rank are selected for futher processing.</para> + + </section> + <section> + <title>Running generators</title> + + <para>When generators are selected, each is run to produce a list of + created targets. This list might include targets that are not of + requested types, because generators create the same targets as + some tool, and tool's behaviour is fixed. (Note: should specify + that in some cases we actually want extra targets). If generator + fails, it returns an empty list. Generator is free to call + 'construct' again, to convert sources to the types it can handle. + It also can pass modified properties to 'construct'. However, a + generator is not allowed to modify any propagated properties, + otherwise when actually consuming properties we might discover + that the set of propagated properties is different from what was + used for building sources.</para> + + <para>For all targets that are not of requested types, we try to + convert them to requested type, using a second call to + <literal>construct</literal>. This is done in order to support + transformation sequences where single source file expands to + several later. See <ulink url= + "http://groups.yahoo.com/group/jamboost/message/1667">this + message</ulink> for details.</para> + + </section> + + --> + + <!-- FIXME: review the below content. Maybe, some of it is + still useful. + <section> + <title>Property adjustment</title> + + <para>Because target location is determined by the build system, it + is sometimes necessary to adjust properties, in order to not + break actions. For example, if there's an action that generates + a header, say "a_parser.h", and a source file "a.cpp" which + includes that file, we must make everything work as if a_parser.h + is generated in the same directory where it would be generated + without any subvariants.</para> + + <para>Correct property adjustment can be done only after all targets + are created, so the approach taken is:</para> + + <orderedlist> + <listitem> + <para> + When dependency graph is constructed, each action can be + assigned a rule for property adjustment. + </para> + </listitem> + + <listitem> + <para> + When virtual target is actualized, that rule is run and + return the final set of properties. At this stage it can use + information of all created virtual targets. + </para> + </listitem> + </orderedlist> + + <para>In case of quoted includes, no adjustment can give 100% correct + results. If target dirs are not changed by build system, quoted + includes are searched in "." and then in include path, while angle + includes are searched only in include path. When target dirs are + changed, we'd want to make quoted includes to be search in "." then in + additional dirs and then in the include path and make angle includes + be searched in include path, probably with additional paths added at + some position. Unless, include path already has "." as the first + element, this is not possible. So, either generated headers should not + be included with quotes, or first element of include path should be + ".", which essentially erases the difference between quoted and angle + includes. <emphasis role="bold">Note:</emphasis> the only way to get + "." as include path into compiler command line is via verbatim + compiler option. In all other case, Boost.Build will convert "." into + directory where it occurs.</para> + + </section> + + --> + + </section> + + </section> + + <section id="bbv2.extender.example"> + <title>Example: 1-to-1 generator</title> + + <para>Say you're writing an application that generates C++ code. If + you ever did this, you know that it's not nice. Embedding large + portions of C++ code in string literals is very awkward. A much + better solution is:</para> + + <orderedlist> + <listitem> + <simpara> + Write the template of the code to be generated, leaving + placeholders at the points that will change + </simpara> + </listitem> + + <listitem> + <simpara> + Access the template in your application and replace + placeholders with appropriate text. + </simpara> + </listitem> + + <listitem> + <simpara>Write the result.</simpara> + </listitem> + </orderedlist> + + <para>It's quite easy to achieve. You write special verbatim files that are + just C++, except that the very first line of the file contains the name of a + variable that should be generated. A simple tool is created that takes a + verbatim file and creates a cpp file with a single <code>char*</code> variable + whose name is taken from the first line of the verbatim file and whose value + is the file's properly quoted content.</para> + + <para>Let's see what Boost.Build can do.</para> + + <para>First off, Boost.Build has no idea about "verbatim files". So, you must + register a new target type. The following code does it:</para> + +<programlisting> +import type ; +type.register VERBATIM : verbatim ; +</programlisting> + + <para>The first parameter to <link linkend="bbv2.reference.modules.type.register">type.register</link> gives + the name of the declared type. By convention, it's uppercase. The second + parameter is the suffix for files of this type. So, if Boost.Build sees + <filename>code.verbatim</filename> in a list of sources, it knows that it's of + type <code>VERBATIM</code>.</para> + + <para>Next, you tell Boost.Build that the verbatim files can be + transformed into C++ files in one build step. A + <firstterm>generator</firstterm> is a template for a build step that + transforms targets of one type (or set of types) into another. Our + generator will be called <code>verbatim.inline-file</code>; it + transforms <code>VERBATIM</code> files into <code>CPP</code> files: + +<programlisting> +import generators ; +generators.register-standard verbatim.inline-file : VERBATIM : CPP ; +</programlisting> + </para> + + <para>Lastly, you have to inform Boost.Build about the shell + commands used to make that transformation. That's done with an + <code>actions</code> declaration. + +<programlisting> +actions inline-file +{ + "./inline-file.py" $(<) $(>) +} +</programlisting> + +<!-- You need to explain all the parameters to an "actions" and + describe the accompanying rule declaration: the user has no clue + what $(<) and $(>) are, and doesn't know about the third + parameter that gets passed to the rule. --> + +<!-- We use verbatim.inline-file in one place and just inline-file in + another. Is this confusing for user? + --> +</para> + + <para> + Now, we're ready to tie it all together. Put all the code above in file + <filename>verbatim.jam</filename>, add <code>import verbatim ;</code> to + <filename>Jamroot.jam</filename>, and it's possible to write the following + in your Jamfile: + </para> + +<programlisting> +exe codegen : codegen.cpp class_template.verbatim usage.verbatim ; +</programlisting> + + <para> + The listed verbatim files will be automatically converted into C++ source + files, compiled and then linked to the codegen executable. + </para> + + <para> + In subsequent sections, we will extend this example, and review all the + mechanisms in detail. The complete code is available in the + <filename>example/customization</filename> directory. + </para> + </section> + + <section id="bbv2.extending.targets"> + <title>Target types</title> + <para>The first thing we did in the <link + linkend="bbv2.extender.intro">introduction</link> was declaring a + new target type: +<programlisting> +import type ; +type.register VERBATIM : verbatim ; +</programlisting> + 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. + </para> + + <para>The first two parameters for the <code>type.register</code> 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. + </para> + + <para>Sometimes you want to change the suffix used for generated targets + depending on build properties, such as toolset. For example, some compiler + uses extension <literal>elf</literal> for executable files. You can use the + <code>type.set-generated-target-suffix</code> rule: +<programlisting> +type.set-generated-target-suffix EXE : <toolset>elf : elf ; +</programlisting> + </para> + + <para>A new target type can be inherited from an existing one. +<programlisting> +type.register PLUGIN : : SHARED_LIB ; +</programlisting> + The above code defines a new type derived from + <code>SHARED_LIB</code>. Initially, the new type inherits all the + properties of the base type - in particular generators and suffix. + Typically, you'll change the new type in some way. For example, using + <code>type.set-generated-target-suffix</code> you can set the suffix for + the new type. Or you can write special a generator for the new type. For + example, it can generate additional metainformation for the plugin. + In either way, the <code>PLUGIN</code> type can be used whenever + <code>SHARED_LIB</code> can. For example, you can directly link plugins + to an application. + </para> + + <para>A type can be defined as "main", in which case Boost.Build will + automatically declare a main target rule for building targets of that + type. More details can be found <link + linkend="bbv2.extending.rules.main-type">later</link>. + </para> + + <section id="bbv2.extending.scanners"> + <title>Scanners</title> + <para> + Sometimes, a file can refer to other files via some include system. To + make Boost.Build track dependencies between included files, you need + to provide a scanner. The primary limitation is that only one scanner + can be assigned to a target type. + </para> + + <para>First, we need to declare a new class for the scanner: +<programlisting> +class verbatim-scanner : common-scanner +{ + rule pattern ( ) + { + return "//###include[ ]*\"([^\"]*)\"" ; + } +} +</programlisting> + All the complex logic is in the <code>common-scanner</code> + class, and you only need to override the method that returns + the regular expression to be used for scanning. The + parentheses in the regular expression indicate which part + of the string is the name of the included file. Only the + first parenthesized group in the regular expression will be + recognized; if you can't express everything you want that + way, you can return multiple regular expressions, each of + which contains a parenthesized group to be matched. + </para> + + <para>After that, we need to register our scanner class: +<programlisting> +scanner.register verbatim-scanner : include ; +</programlisting> + The value of the second parameter, in this case + <code>include</code>, specifies the properties that contain the list + of paths that should be searched for the included files. + </para> + + <para>Finally, we assign the new scanner to the <code>VERBATIM</code> + target type: +<programlisting> +type.set-scanner VERBATIM : verbatim-scanner ; +</programlisting> + That's enough for scanning include dependencies. + </para> + + </section> + + </section> + + <section id="bbv2.extending.tools"> + <title>Tools and generators</title> + <para> + This section will describe how Boost.Build can be extended to support + new tools. + </para> + + <para>For each additional tool, a Boost.Build object called generator + must be created. That object has specific types of targets that it + accepts and produces. Using that information, Boost.Build is able + to automatically invoke the generator. For example, if you declare a + generator that takes a target of the type <literal>D</literal> and + produces a target of the type <literal>OBJ</literal>, when placing a + file with extention <literal>.d</literal> in a list of sources will + cause Boost.Build to invoke your generator, and then to link the + resulting object file into an application. (Of course, this requires + that you specify that the <literal>.d</literal> extension corresponds + to the <literal>D</literal> type.) + </para> + + <para>Each generator should be an instance of a class derived from the + <code>generator</code> class. In the simplest case, you don't need to + create a derived class, but simply create an instance of the + <code>generator</code> class. Let's review the example we've seen in the + <link linkend="bbv2.extender.intro">introduction</link>. + <!-- Is the following supposed to be verbatim.jam? Tell the + user so. You also need to describe the meanings of $(<) + and $(>); this is the first time they're encountered. --> +<programlisting> +import generators ; +generators.register-standard verbatim.inline-file : VERBATIM : CPP ; +actions inline-file +{ + "./inline-file.py" $(<) $(>) +} +</programlisting> + </para> + + <para>We declare a standard generator, specifying its id, the source type + and the target type. When invoked, the generator will create a target + of type <literal>CPP</literal> with a source target of + type <literal>VERBATIM</literal> as the only source. But what command + will be used to actually generate the file? In Boost.Build, actions are + specified using named "actions" blocks and the name of the action + block should be specified when creating targets. By convention, + generators use the same name of the action block as their own id. So, + in above example, the "inline-file" actions block will be used to + convert the source into the target. + </para> + + <para> + There are two primary kinds of generators: standard and composing, + which are registered with the + <code>generators.register-standard</code> and the + <code>generators.register-composing</code> rules, respectively. For + example: +<programlisting> +generators.register-standard verbatim.inline-file : VERBATIM : CPP ; +generators.register-composing mex.mex : CPP LIB : MEX ; +</programlisting> + The first (standard) generator takes a <emphasis>single</emphasis> + source of type <code>VERBATIM</code> and produces a result. The second + (composing) generator takes any number of sources, which can have either + the <code>CPP</code> or the <code>LIB</code> type. Composing generators + are typically used for generating top-level target type. For example, + the first generator invoked when building an <code>exe</code> target is + a composing generator corresponding to the proper linker. + </para> + + <para>You should also know about two specific functions for registering + generators: <code>generators.register-c-compiler</code> and + <code>generators.register-linker</code>. The first sets up header + dependecy scanning for C files, and the seconds handles various + complexities like searched libraries. For that reason, you should always + use those functions when adding support for compilers and linkers. + </para> + + <para>(Need a note about UNIX)</para> + <!-- What kind of note? Either write the note or don't, but remove this dross. --> + <bridgehead>Custom generator classes</bridgehead> + + <para>The standard generators allows you to specify source and target + types, an action, and a set of flags. If you need anything more complex, + <!-- What sort of flags? Command-line flags? What does the system do with them? --> + you need to create a new generator class with your own logic. Then, + you have to create an instance of that class and register it. Here's + an example how you can create your own generator class: +<programlisting> +class custom-generator : generator +{ + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } +<!-- What is the point of this __init__ function?? --> +} + +generators.register + [ new custom-generator verbatim.inline-file : VERBATIM : CPP ] ; +</programlisting> + This generator will work exactly like the + <code>verbatim.inline-file</code> generator we've defined above, but + it's possible to customize the behaviour by overriding methods of the + <code>generator</code> class. + </para> + + <para>There are two methods of interest. The <code>run</code> method is + responsible for the overall process - it takes a number of source targets, + converts them to the right types, and creates the result. The + <code>generated-targets</code> method is called when all sources are + converted to the right types to actually create the result. + </para> + + <para>The <code>generated-targets</code> method can be overridden when you + want to add additional properties to the generated targets or use + additional sources. For a real-life example, suppose you have a program + analysis tool that should be given a name of executable and the list of + all sources. Naturally, you don't want to list all source files + manually. Here's how the <code>generated-targets</code> method can find + the list of sources automatically: +<programlisting> +class itrace-generator : generator { +.... + rule generated-targets ( sources + : property-set : project name ? ) + { + local leaves ; + local temp = [ virtual-target.traverse $(sources[1]) : : include-sources ] ;<!-- You must explain include-sources! --> + for local t in $(temp) + { + if ! [ $(t).action<!-- In what namespace is this evaluated? --> ] + { + leaves += $(t) ; + } + } + return [ generator.generated-targets $(sources) $(leafs) + : $(property-set) : $(project) $(name) ] ; + } +} +generators.register [ new itrace-generator nm.itrace : EXE : ITRACE ] ; +</programlisting> + The <code>generated-targets</code> method will be called with a single + source target of type <literal>EXE</literal>. The call to + <code>virtual-target.traverse</code> will return all targets the + executable depends on, and we further find files that are not + produced from anything. <!-- What does "not produced from anything" mean? --> + The found targets are added to the sources. + </para> + + <para>The <code>run</code> method can be overriden to completely + customize the way the generator works. In particular, the conversion of + sources to the desired types can be completely customized. Here's + another real example. Tests for the Boost Python library usually + consist of two parts: a Python program and a C++ file. The C++ file is + compiled to Python extension that is loaded by the Python + program. But in the likely case that both files have the same name, + the created Python extension must be renamed. Otherwise, the Python + program will import itself, not the extension. Here's how it can be + done: +<programlisting> +rule run ( project name ? : property-set : sources * ) +{ + local python ; + for local s in $(sources) + { + if [ $(s).type ] = PY + { + python = $(s) ; + } + } + <!-- This is horrible code. Use a filter function, or at _least_ consolidate the two loops! --> + local libs ; + for local s in $(sources) + { + if [ type.is-derived [ $(s).type ] LIB ] + { + libs += $(s) ; + } + } + + local new-sources ; + for local s in $(sources) + { + if [ type.is-derived [ $(s).type ] CPP ] + { + local name = [ $(s).name ] ; # get the target's basename + if $(name) = [ $(python).name ] + { + name = $(name)_ext ; # rename the target + } + new-sources += [ generators.construct $(project) $(name) : + PYTHON_EXTENSION : $(property-set) : $(s) $(libs) ] ; + } + } + + result = [ construct-result $(python) $(new-sources) : $(project) $(name) + : $(property-set) ] ; +} +</programlisting> + <!-- Why are we doing this with a generator??? It seems + insane. We could just use a nice front-end rule that + calls some normal target-creation rules. No? --> + + First, we separate all source into python files, libraries and C++ + sources. For each C++ source we create a separate Python extension by + calling <code>generators.construct</code> and passing the C++ source + and the libraries. At this point, we also change the extension's name, + if necessary. + </para> + + + </section> + + <section id="bbv2.extending.features"> + <title>Features</title> + <para> + Often, we need to control the options passed the invoked tools. This + is done with features. Consider an example: +<programlisting> +# Declare a new free feature +import feature : feature ; +feature verbatim-options : : free ; + +# Cause the value of the 'verbatim-options' feature to be +# available as 'OPTIONS' variable inside verbatim.inline-file +import toolset : flags ; +flags verbatim.inline-file OPTIONS <verbatim-options> ;<!-- You must tell the reader what the syntax of the flags rule is --> + +# Use the "OPTIONS" variable +actions inline-file +{ + "./inline-file.py" $(OPTIONS) $(<) $(>) +} +</programlisting> + We first define a new feature. Then, the <code>flags</code> invocation + says that whenever verbatin.inline-file action is run, the value of + the <code>verbatim-options</code> feature will be added to the + <code>OPTIONS</code> variable, and can be used inside the action body. + You'd need to consult online help (--help) to find all the features of + the <code>toolset.flags</code> rule. + <!-- It's been a while since I wrote these notes, so I don't + remember what I meant. But right here, I wrote "bad" and + circled it. Maybe you can figure out what I meant. ;-) + --> + </para> + + <para> + Although you can define any set of features and interpret their values + in any way, Boost.Build suggests the following coding standard for + designing features. + </para> + + <para>Most features should have a fixed set of values that is portable + (tool neutral) across the class of tools they are designed to work + with. The user does not have to adjust the values for a exact tool. For + example, <code><optimization>speed</code> has the same meaning for + all C++ compilers and the user does not have to worry about the exact + options passed to the compiler's command line. + </para> + + <para> + Besides such portable features there are special 'raw' features that + allow the user to pass any value to the command line parameters for a + particular tool, if so desired. For example, the + <code><cxxflags></code> feature allows you to pass any command line + options to a C++ compiler. The <code><include></code> feature + allows you to pass any string preceded by <code>-I</code> and the interpretation + is tool-specific. <!-- It's really tool-specific? That surprises me --> (See <xref + linkend="bbv2.faq.external"/> for an example of very smart usage of that + feature). Of course one should always strive to use portable + features, but these are still be provided as a backdoor just to make + sure Boost.Build does not take away any control from the user. + </para> + + <para> + Using portable features is a good idea because: + <itemizedlist> + <listitem> + <para>When a portable feature is given a fixed set of + values, you can build your project with two different + settings of the feature and Boost.Build will automatically + use two different directories for generated files. + Boost.Build does not try to separate targets built with + different raw options. + <!-- It's a computer program. It doesn't "care" about options --> + </para> + </listitem> + + <listitem> + <para>Unlike with “raw” features, you don't need to use + specific command-line flags in your Jamfile, and it will be + more likely to work with other tools. + </para> + </listitem> + </itemizedlist> + </para> + + <bridgehead>Steps for adding a feauture</bridgehead> + <!-- This section is redundant with the previous one --> + <para>Adding a feature requires three steps: + + <orderedlist> + <listitem><para>Declaring a feature. For that, the "feature.feature" + rule is used. You have to decide on the set of <link + linkend="bbv2.reference.features.attributes">feature + attributes</link>: + + <itemizedlist> + <listitem><para>if you want a feature value set for one target + to automaticaly propagate to its dependant targets then make it + “propagated”. <!-- Examples needed. --></para></listitem> + + <listitem><para>if a feature does not have a fixed list of + values, it must be “free.” For example, the <code>include + </code> feature is a free feature.</para></listitem> + + <listitem><para>if a feature is used to refer to a path relative + to the Jamfile, it must be a “path” feature. Such features will + also get their values automatically converted to Boost.Build's + internal path representation. For example, <code>include</code> + is a path feature.</para></listitem> + + <listitem><para>if feature is used to refer to some target, it + must be a “dependency” feature. <!-- for example? --></para> + + <!-- Any other feature attributes? --> + </listitem> + </itemizedlist> + </para> + </listitem> + + <listitem><para>Representing the feature value in a + target-specific variable. Build actions are command + templates modified by Boost.Jam variable expansions. The + <code>toolset.flags</code> rule sets a target-specific + variable to the value of a feature.</para></listitem> + + <listitem><para>Using the variable. The variable set in step 2 can + be used in a build action to form command parameters or + files.</para></listitem> + + </orderedlist> + </para> + + <bridgehead>Another example</bridgehead> + + <para>Here's another example. + Let's see how we can make a feature that refers to a target. For example, + when linking dynamic libraries on Windows, one sometimes needs to + specify a "DEF file", telling what functions should be exported. It + would be nice to use this file like this: +<programlisting> + lib a : a.cpp : <def-file>a.def ; +</programlisting> +<!-- Why would that be nice? It seems to me that having a.def in the sources is the obvious and much nicer thing to do: + + lib a : a.cpp a.def ; +--> + Actually, this feature is already supported, but anyway... + <!-- Something about saying that is very off-putting. I'm + sorry that I can't put my finger on it --> + </para> + + <orderedlist> + <listitem> + <para>Since the feature refers to a target, it must be "dependency". +<programlisting> +feature def-file : : free dependency ; +</programlisting> + </para></listitem> + + <listitem><para>One of the toolsets that cares about + <!-- The toolset doesn't "care." What do your really mean? --> + DEF files is msvc. The following line should be added to it. + <!-- Are you saying the msvc toolset is broken (or that it + doesn't use DEF files) as-shipped and the reader needs to + fix it? --> + +<programlisting> +flags msvc.link DEF_FILE <def-file> ; +</programlisting> + <!-- And that line does... what? --> + </para></listitem> + + <listitem><para>Since the DEF_FILE variable is not used by the +msvc.link action, +<!-- It's not? You just told us that MSVC "cares" about DEF files. I + presume that means that it uses them in some appropriate way? --> +we need to modify it to be: + +<programlisting> +actions link bind DEF_FILE +{ + $(.LD) .... /DEF:$(DEF_FILE) .... +} +</programlisting> + </para> + + + <para> Note the <code>bind DEF_FILE</code> part. It tells + Boost.Build to translate the internal target name in + <varname>DEF_FILE</varname> to a corresponding filename in + the <code>link</code> action. Without it the expansion of + <code>$(DEF_FILE)</code> would be a strange symbol that is + not likely to make sense for the linker. + </para> + + <!-- I have a note here that says: "none of this works for + targets in general, only source files." I'm not sure + what I meant by that; maybe you can figure it out. --> + <para> + We are almost done, except for adding the follwing code to <filename>msvc.jam</filename>: + +<programlisting> +rule link +{ + DEPENDS $(<) : [ on $(<) return $(DEF_FILE) ] ; +} +</programlisting> +<!-- You *must* explain the part in [...] above. It's completely opaque to the casual reader --> + + This is a workaround for a bug in Boost.Build engine, which will hopefully + be fixed one day. + <!-- This is *NOT* a bug!! Anyway, BBv2 shouild handle this automatically. Why doesn't it? --> +</para></listitem> + + </orderedlist> + + <bridgehead>Variants and composite features.</bridgehead> + + <para>Sometimes you want to create a shortcut for some set of + features. For example, <code>release</code> is a value of + <code><variant></code> and is a shortcut for a set of features. + </para> + + <para>It is possible to define your own build variants. For example: +<programlisting> +variant crazy : <optimization>speed <inlining>off + <debug-symbols>on <profiling>on ; +</programlisting> + will define a new variant with the specified set of properties. You + can also extend an existing variant: +<programlisting> +variant super_release : release : <define>USE_ASM ; +</programlisting> + In this case, <code>super_release</code> will expand to all properties + specified by <code>release</code>, and the additional one you've specified. + </para> + + <para>You are not restricted to using the <code>variant</code> feature + only. + <!-- What do you mean by that? How is defining a new feature related to what came before? --> + Here's example that defines a brand new feature: +<programlisting> +feature parallelism : mpi fake none : composite link-incompatible ; +feature.compose <parallelism>mpi : <library>/mpi//mpi/<parallelism>none ; +feature.compose <parallelism>fake : <library>/mpi//fake/<parallelism>none ; +</programlisting> +<!-- The use of the <library>/mpi//mpi/<parallelism>none construct + above is at best confusing and unexplained --> + This will allow you to specify the value of feature + <code>parallelism</code>, which will expand to link to the necessary + library. + </para> + + </section> + + <section id="bbv2.extending.rules"> + <title>Main target rules</title> + <para> + A main target rule (e.g “<link linkend="bbv2.tasks.programs">exe</link>” + Or “<link linkend="bbv2.tasks.libraries">lib</link>”) creates a top-level target. It's quite likely that you'll want to declare your own and + there are two ways to do that. + <!-- Why did "that" get changed to "this" above? --> + </para> + + <para id="bbv2.extending.rules.main-type">The first way applies when +<!-- This is not a "way of defining a main target rule." Rephrase this and the previous sentence. --> + your target rule should just produce a target of specific type. In that case, a + rule is already defined for you! When you define a new type, Boost.Build + automatically defines a corresponding rule. The name of the rule is + obtained from the name of the type, by downcasing all letters and + replacing underscores with dashes. + <!-- This strikes me as needless complexity, and confusing. Why + do we have the uppercase-underscore convention for target + types? If we just dropped that, the rule names could be + the same as the type names. --> + For example, if you create a module + <filename>obfuscate.jam</filename> containing: + +<programlisting> +import type ; +type.register OBFUSCATED_CPP : ocpp ; + +import generators ; +generators.register-standard obfuscate.file : CPP : OBFUSCATED_CPP ; +</programlisting> + and import that module, you'll be able to use the rule "obfuscated-cpp" + in Jamfiles, which will convert source to the OBFUSCATED_CPP type. + </para> + + <para> + The second way is to write a wrapper rule that calls any of the existing + rules. For example, suppose you have only one library per directory and + want all cpp files in the directory to be compiled into that library. You + can achieve this effect using: +<programlisting> +lib codegen : [ glob *.cpp ] ; +</programlisting> + If you want to make it even simpler, you could add the following + definition to the <filename>Jamroot.jam</filename> file: +<programlisting> +rule glib ( name : extra-sources * : requirements * ) +{ + lib $(name) : [ glob *.cpp ] $(extra-sources) : $(requirements) ; +} +</programlisting> + allowing you to reduce the Jamfile to just +<programlisting> +glib codegen ; +</programlisting> + </para> + + <para> + Note that because you can associate a custom generator with a target type, + the logic of building can be rather complicated. For example, the + <code>boostbook</code> module declares a target type + <code>BOOSTBOOK_MAIN</code> and a custom generator for that type. You can + use that as example if your main target rule is non-trivial. + </para> + </section> + + <section id="bbv2.extending.toolset_modules"> + + <title>Toolset modules</title> + + <para> + If your extensions will be used only on one project, they can be placed in + a separate <filename>.jam</filename> file and imported by your + <filename>Jamroot.jam</filename>. If the extensions will be used on many + projects, users will thank you for a finishing touch. + </para> + + <para>The <code>using</code> rule provides a standard mechanism + for loading and configuring extensions. To make it work, your module + <!-- "module" hasn't been defined yet. Furthermore you haven't + said anything about where that module file must be + placed. --> + should provide an <code>init</code> rule. The rule will be called + with the same parameters that were passed to the + <code>using</code> rule. The set of allowed parameters is + determined by you. For example, you can allow the user to specify + paths, tool versions, and other options. + <!-- But it's not entirely arbitrary. We have a standard + parameter order which you should describe here for + context. --> + </para> + + <para>Here are some guidelines that help to make Boost.Build more + consistent: + <itemizedlist> + <listitem><para>The <code>init</code> rule should never fail. Even if + the user provided an incorrect path, you should emit a warning and go + on. Configuration may be shared between different machines, and + wrong values on one machine can be OK on another. + <!-- So why shouldn't init fail on machines where it's wrong?? --> + </para></listitem> + + <listitem><para>Prefer specifying the command to be executed + to specifying the tool's installation path. First of all, this + gives more control: it's possible to specify +<programlisting> +/usr/bin/g++-snapshot +time g++ +<!-- Is this meant to be a single command? If not, insert "or" --> +</programlisting> + as the command. Second, while some tools have a logical + "installation root", it's better if the user doesn't have to remember whether + a specific tool requires a full command or a path. + <!-- But many tools are really collections: e.g. a + compiler, a linker, and others. The idea that the + "command to invoke" has any significance may be + completely bogus. Plus if you want to allow "time + /usr/bin/g++" the toolset may need to somehow parse + the command and find the path when it needs to invoke + some related executable. And in that case, will the + command be ignored? This scheme doesn't scale and + should be fixed. --> + </para></listitem> + + <listitem><para>Check for multiple initialization. A user can try to + initialize the module several times. You need to check for this + and decide what to do. Typically, unless you support several + versions of a tool, duplicate initialization is a user error. + <!-- Why should that be typical? --> + If the + tool's version can be specified during initialization, make sure the + version is either always specified, or never specified (in which + case the tool is initialied only once). For example, if you allow: +<programlisting> +using yfc ; +using yfc : 3.3 ; +using yfc : 3.4 ; +</programlisting> + Then it's not clear if the first initialization corresponds to + version 3.3 of the tool, version 3.4 of the tool, or some other + version. This can lead to building twice with the same version. + <!-- That would not be so terrible, and is much less harmful + than this restriction, IMO. It makes site-config + harder to maintain than necessary. --> + </para></listitem> + + <listitem><para>If possible, <code>init</code> must be callable + with no parameters. In which case, it should try to autodetect all + the necessary information, for example, by looking for a tool in + <envar>PATH</envar> or in common installation locations. Often this + is possible and allows the user to simply write: +<programlisting> +using yfc ; +</programlisting> + </para></listitem> + + <listitem><para>Consider using facilities in the + <code>tools/common</code> module. You can take a look at how + <code>tools/gcc.jam</code> uses that module in the <code>init</code> rule. + </para></listitem> + + </itemizedlist> + </para> + + + + + </section> + + </chapter> + +<!-- + Local Variables: + sgml-indent-data: t + sgml-parent-document: ("userman.xml" "chapter") + sgml-set-face: t + End: +--> diff --git a/boost/tools/build/doc/src/faq.xml b/boost/tools/build/doc/src/faq.xml new file mode 100644 index 00000000..3b6894b7 --- /dev/null +++ b/boost/tools/build/doc/src/faq.xml @@ -0,0 +1,489 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE chapter PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<chapter id="bbv2.faq"> + <title>Frequently Asked Questions</title> + + <section id="bbv2.faq.featurevalue"> + <title> + How do I get the current value of feature in Jamfile? + </title> + + <para> + This is not possible, since Jamfile does not have "current" value of any + feature, be it toolset, build variant or anything else. For a single + run of Boost.Build, any given main target can be + built with several property sets. For example, user can request two build + variants on the command line. Or one library is built as shared when used + from one application, and as static when used from another. Each Jamfile + is read only once so generally there is no single value of a feature you + can access in Jamfile. + </para> + + <para> + A feature has a specific value only when building a target, and there are + two ways you can use that value: + </para> + + <itemizedlist> + <listitem> + <simpara> + Use conditional requirements or indirect conditional requirements. See + <xref linkend="bbv2.overview.targets.requirements.conditional"/>. + </simpara> + </listitem> + <listitem> + Define a custom generator and a custom main target type. The custom + generator can do arbitrary processing or properties. See the <xref + linkend="bbv2.extender">extender manual</xref>. + </listitem> + </itemizedlist> + </section> + + <section id="bbv2.faq.duplicate"> + <title> + I am getting a "Duplicate name of actual target" error. What does that + mean? + </title> + + <para> + The most likely case is that you are trying to compile the same file + twice, with almost the same, but differing properties. For example: +<programlisting> +exe a : a.cpp : <include>/usr/local/include ; +exe b : a.cpp ; +</programlisting> + </para> + + <para> + The above snippet requires two different compilations of + <code>a.cpp</code>, which differ only in their <literal>include</literal> + property. Since the <literal>include</literal> feature is declared as + <literal>free</literal> Boost.Build does not create a separate build + directory for each of its values and those two builds would both produce + object files generated in the same build directory. Ignoring this and + compiling the file only once would be dangerous as different includes + could potentially cause completely different code to be compiled. + </para> + + <para> + To solve this issue, you need to decide if the file should be compiled + once or twice. + </para> + + <orderedlist> + <listitem> + <para> + To compile the file only once, make sure that properties are the same + for both target requests: +<programlisting> +exe a : a.cpp : <include>/usr/local/include ; +exe b : a.cpp : <include>/usr/local/include ; +</programlisting> + or: +<programlisting> +alias a-with-include : a.cpp : <include>/usr/local/include ; +exe a : a-with-include ; +exe b : a-with-include ; +</programlisting> + or if you want the <literal>includes</literal> property not to affect + how any other sources added for the built <code>a</code> and + <code>b</code> executables would be compiled: +<programlisting> +obj a-obj : a.cpp : <include>/usr/local/include ; +exe a : a-obj ; +exe b : a-obj ; +</programlisting> + </para> + <para> + Note that in both of these cases the <literal>include</literal> + property will be applied only for building these object files and not + any other sources that might be added for targets <code>a</code> and + <code>b</code>. + </para> + </listitem> + + <listitem> + <para> + To compile the file twice, you can tell Boost.Build to compile it to + two separate object files like so: +<programlisting> + obj a_obj : a.cpp : <include>/usr/local/include ; + obj b_obj : a.cpp ; + exe a : a_obj ; + exe b : b_obj ; +</programlisting> + or you can make the object file targets local to the main target: +<programlisting> + exe a : [ obj a_obj : a.cpp : <include>/usr/local/include ] ; + exe b : [ obj a_obj : a.cpp ] ; +</programlisting> + which will cause Boost.Build to actually change the generated object + file names a bit for you and thus avoid any conflicts. + </para> + <para> + Note that in both of these cases the <literal>include</literal> + property will be applied only for building these object files and not + any other sources that might be added for targets <code>a</code> and + <code>b</code>. + </para> + </listitem> + </orderedlist> + + <para> + A good question is why Boost.Build can not use some of the above + approaches automatically. The problem is that such magic would only help + in half of the cases, while in the other half it would be silently doing + the wrong thing. It is simpler and safer to ask the user to clarify his + intention in such cases. + </para> + </section> + + <section id="bbv2.faq.envar"> + <title> + Accessing environment variables + </title> + + <para> + Many users would like to use environment variables in Jamfiles, for + example, to control the location of external libraries. In many cases it + is better to declare those external libraries in the site-config.jam file, + as documented in the <link linkend="bbv2.recipies.site-config">recipes + section</link>. However, if the users already have the environment + variables set up, it may not be convenient for them to set up their + site-config.jam files as well and using the environment variables might be + reasonable. + </para> + + <para> + Boost.Jam automatically imports all environment variables into its + built-in .ENVIRON module so user can read them from there directly or by + using the helper os.environ rule. For example: +<programlisting> +import os ; +local unga-unga = [ os.environ UNGA_UNGA ] ; +ECHO $(unga-unga) ; +</programlisting> + or a bit more realistic: +<programlisting> +import os ; +local SOME_LIBRARY_PATH = [ os.environ SOME_LIBRARY_PATH ] ; +exe a : a.cpp : <include>$(SOME_LIBRARY_PATH) ; +</programlisting> + </para> + </section> + + <section id="bbv2.faq.proporder"> + <title> + How to control properties order? + </title> + + <para> + For internal reasons, Boost.Build sorts all the properties alphabetically. + This means that if you write: +<programlisting> +exe a : a.cpp : <include>b <include>a ; +</programlisting> + then the command line with first mention the <code>a</code> include + directory, and then <code>b</code>, even though they are specified in the + opposite order. In most cases, the user does not care. But sometimes the + order of includes, or other properties, is important. For such cases, a + special syntax is provided: +<programlisting> +exe a : a.cpp : <include>a&&b ; +</programlisting> + </para> + + <para> + The <code>&&</code> symbols separate property values and specify + that their order should be preserved. You are advised to use this feature + only when the order of properties really matters and not as a convenient + shortcut. Using it everywhere might negatively affect performance. + </para> + </section> + + <section id="bbv2.faq.liborder"> + <title> + How to control the library linking order on Unix? + </title> + + <para> + On Unix-like operating systems, the order in which static libraries are + specified when invoking the linker is important, because by default, the + linker uses one pass though the libraries list. Passing the libraries in + the incorrect order will lead to a link error. Further, this behaviour is + often used to make one library override symbols from another. So, + sometimes it is necessary to force specific library linking order. + </para> + + <para> + Boost.Build tries to automatically compute the right order. The primary + rule is that if library <code>a</code> "uses" library <code>b</code>, then + library <code>a</code> will appear on the command line before library + <code>b</code>. Library <code>a</code> is considered to use <code>b</code> + if <code>b</code> is present either in the <code>a</code> library's + sources or its usage is listed in its requirements. To explicitly specify + the <literal>use</literal> relationship one can use the + <literal><use></literal> feature. For example, both of the following + lines will cause <code>a</code> to appear before <code>b</code> on the + command line: +<programlisting> +lib a : a.cpp b ; +lib a : a.cpp : <use>b ; +</programlisting> + </para> + + <para> + The same approach works for searched libraries as well: +<programlisting> +lib z ; +lib png : : <use>z ; +exe viewer : viewer png z ; +</programlisting> + </para> + </section> + + <section id="bbv2.faq.external"> + <title> + Can I get capture external program output using a Boost.Jam variable? + </title> + + <para> + The <literal>SHELL</literal> builtin rule may be used for this purpose: +<programlisting> +local gtk_includes = [ SHELL "gtk-config --cflags" ] ; +</programlisting> + </para> + </section> + + <section id="bbv2.faq.projectroot"> + <title> + How to get the project root (a.k.a. Jamroot) location? + </title> + + <para> + You might want to use your project's root location in your Jamfiles. To + access it just declare a path constant in your Jamroot.jam file using: +<programlisting> +path-constant TOP : . ; +</programlisting> + After that, the <code>TOP</code> variable can be used in every Jamfile. + </para> + </section> + + <section id="bbv2.faq.flags"> + <title> + How to change compilation flags for one file? + </title> + + <para> + If one file must be compiled with special options, you need to explicitly + declare an <code>obj</code> target for that file and then use that target + in your <code>exe</code> or <code>lib</code> target: +<programlisting> +exe a : a.cpp b ; +obj b : b.cpp : <optimization>off ; +</programlisting> + Of course you can use other properties, for example to specify specific + C/C++ compiler options: +<programlisting> +exe a : a.cpp b ; +obj b : b.cpp : <cflags>-g ; +</programlisting> + You can also use <link linkend="bbv2.tutorial.conditions">conditional + properties</link> for finer control: +<programlisting> +exe a : a.cpp b ; +obj b : b.cpp : <variant>release:<optimization>off ; +</programlisting> + </para> + </section> + + <section id="bbv2.faq.dll-path"> + <title> + Why are the <literal>dll-path</literal> and <literal>hardcode-dll-paths + </literal> properties useful? + </title> + <note> + <para> + This entry is specific to Unix systems. + </para> + </note> + <para> + Before answering the questions, let us recall a few points about shared + libraries. Shared libraries can be used by several applications, or other + libraries, without physically including the library in the application + which can greatly decrease the total application size. It is also possible + to upgrade a shared library when the application is already installed. + </para> + + <para> + However, in order for application depending on shared libraries to be + started the OS may need to find the shared library when the application is + started. The dynamic linker will search in a system-defined list of paths, + load the library and resolve the symbols. Which means that you should + either change the system-defined list, given by the <envar>LD_LIBRARY_PATH + </envar> environment variable, or install the libraries to a system + location. This can be inconvenient when developing, since the libraries + are not yet ready to be installed, and cluttering system paths may be + undesirable. Luckily, on Unix there is another way. + </para> + + <para> + An executable can include a list of additional library paths, which will + be searched before system paths. This is excellent for development because + the build system knows the paths to all libraries and can include them in + the executables. That is done when the <literal>hardcode-dll-paths + </literal> feature has the <literal>true</literal> value, which is the + default. When the executables should be installed, the story is different. + </para> + + <para> + Obviously, installed executable should not contain hardcoded paths to your + development tree. <!-- Make the following parenthised sentence a footer + note --> (The <literal>install</literal> rule explicitly disables the + <literal>hardcode-dll-paths</literal> feature for that reason.) However, + you can use the <literal>dll-path</literal> feature to add explicit paths + manually. For example: +<programlisting> +install installed : application : <dll-path>/usr/lib/snake + <location>/usr/bin ; +</programlisting> + will allow the application to find libraries placed in the <filename> + /usr/lib/snake</filename> directory. + </para> + + <para> + If you install libraries to a nonstandard location and add an explicit + path, you get more control over libraries which will be used. A library of + the same name in a system location will not be inadvertently used. If you + install libraries to a system location and do not add any paths, the + system administrator will have more control. Each library can be + individually upgraded, and all applications will use the new library. + </para> + + <para> + Which approach is best depends on your situation. If the libraries are + relatively standalone and can be used by third party applications, they + should be installed in the system location. If you have lots of libraries + which can be used only by your application, it makes sense to install them + to a nonstandard directory and add an explicit path, like the example + above shows. Please also note that guidelines for different systems differ + in this respect. For example, the Debian GNU guidelines prohibit any + additional search paths while Solaris guidelines suggest that they should + always be used. + </para> + </section> + + <section id="bbv2.recipies.site-config"> + <title>Targets in site-config.jam</title> + + <para> + It is desirable to declare standard libraries available on a given system. + Putting target declaration in a specific project's Jamfile is not really + good, since locations of the libraries can vary between different + development machines and then such declarations would need to be + duplicated in different projects. The solution is to declare the targets + in Boost.Build's <filename>site-config.jam</filename> configuration file: +<programlisting> +project site-config ; +lib zlib : : <name>z ; +</programlisting> + </para> + + <para> + Recall that both <filename>site-config.jam</filename> and + <filename>user-config.jam</filename> are projects, and everything you can + do in a Jamfile you can do in those files as well. So, you declare a + project id and a target. Now, one can write: +<programlisting> +exe hello : hello.cpp /site-config//zlib ; +</programlisting> + in any Jamfile. + </para> + </section> + + <section id="bbv2.faq.header-only-libraries"> + <title>Header-only libraries</title> + + <para> + In modern C++, libraries often consist of just header files, without any + source files to compile. To use such libraries, you need to add proper + includes and possibly defines to your project. But with a large number of + external libraries it becomes problematic to remember which libraries are + header only, and which ones you have to link to. However, with Boost.Build + a header-only library can be declared as Boost.Build target and all + dependents can use such library without having to remember whether it is a + header-only library or not. + </para> + + <para> + Header-only libraries may be declared using the <code>alias</code> rule, + specifying their include path as a part of its usage requirements, for + example: +<programlisting> +alias my-lib + : # no sources + : # no build requirements + : # no default build + : <include>whatever ; +</programlisting> + The includes specified in usage requirements of <code>my-lib</code> are + automatically added to all of its dependants' build properties. The + dependants need not care if <code>my-lib</code> is a header-only or not, + and it is possible to later make <code>my-lib</code> into a regular + compiled library without having to that its dependants' declarations. + </para> + + <para> + If you already have proper usage requirements declared for a project where + a header-only library is defined, you do not need to duplicate them for + the <code>alias</code> target: +<programlisting> +project my : usage-requirements <include>whatever ; +alias mylib ; +</programlisting> + </para> + </section> + + <section id="bbv2.faq.names"> + <title> + What is the difference between Boost.Build, + <filename>b2</filename>, <filename>bjam</filename> and Perforce Jam? + </title> + + <para> + Boost.Build is the name of the complete build system. The executable that runs + it is <filename>b2</filename>. That executable is written in C and implements + performance-critical algorithms, like traversal of dependency graph and executing + commands. It also implements an interpreted language used to implement the rest of + Boost.Build. This executable is formally called "Boost.Build engine". + </para> + + <para> + The Boost.Build engine is derived from an earlier build tool called Perforce Jam. Originally, + there were just minor changes, and the filename was <filename>bjam</filename>. Later on, + with more and more changes, the similarity of names because a disservice to users, and as of + Boost 1.47.0, the official name of the executable was changed to <filename>b2</filename>. + A copy named <filename>bjam</filename> is still created for compatibility, + but you are encouraged to use the new name in all cases. + </para> + + <para> + Perforce Jam was an important foundation, and we gratefully acknowledge its influence, + but for users today, these tools share only some basics of the interpreted language. + </para> + + </section> + +</chapter> + +<!-- + Local Variables: + mode: nxml + sgml-indent-data: t + sgml-parent-document: ("userman.xml" "chapter") + sgml-set-face: t + End: +--> diff --git a/boost/tools/build/doc/src/fragments.xml b/boost/tools/build/doc/src/fragments.xml new file mode 100644 index 00000000..78438a0c --- /dev/null +++ b/boost/tools/build/doc/src/fragments.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE chapter PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<chapter> + <section id="root_option"> + <varlistentry> + <term><literal>root</literal></term> + + <!-- At present, this option is only used to set LD_LIBRARY_PATH when + running tests, and matters only if compiler's lib directory is not in + LD_LIBRARY_PATH. --> + + <listitem><para>Specifies 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.</para></listitem> + </varlistentry> + </section> + + <section id="common_options"> + + <!-- This most likely needs splitting into common_options, + common_cxx_options & common_fortran_options or something similar. We also + need to document the fortran specific fflags option. Possibly related Boost + Build code should be updated as well so that fortran options may not be + specified for non-fortran toolsets and C/C++ options may not be specified + for non-C/C++ ones. --> + + <varlistentry> + <term><literal>cflags</literal></term> + + <listitem><para>Specifies additional compiler flags that will be used when + compiling C sources.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>cxxflags</literal></term> + + <listitem><para>Specifies additional compiler flags that will be used when + compiling C++ sources.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>compileflags</literal></term> + + <listitem><para>Specifies additional compiler flags that will be used when + compiling both C and C++ sources.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>linkflags</literal></term> + + <listitem><para>Specifies additional command line options that will be + passed to the linker.</para> + </listitem> + </varlistentry> + </section> +</chapter> diff --git a/boost/tools/build/doc/src/howto.xml b/boost/tools/build/doc/src/howto.xml new file mode 100644 index 00000000..8ba571ab --- /dev/null +++ b/boost/tools/build/doc/src/howto.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE chapter PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + + <dedication id="bbv2.howto"> + + <title>How to use this document</title> + + <para> + Want to learn about Boost.Build features? Start with <xref linkend= + "bbv2.tutorial"/> and continue with <xref + linkend="bbv2.overview"/>. When you're ready to try Boost.Build + in practice, go to <xref linkend="bbv2.installation"/>. + </para> + + <para> + Building a project with Boost.Build? See <xref + linkend="bbv2.installation"/> and + then read <xref linkend="bbv2.overview.invocation"/>. + </para> + + <para> + Setting up Boost.Build on your project? Take a look at <xref + linkend="bbv2.overview"/> and <xref linkend="bbv2.extender"/>. + </para> + + <para> + If there's anything you find unclear in this documentation, report the + problem directly in the <ulink + url="https://github.com/boostorg/build/issues">issue tracker</ulink>. + For more general questions, please post them to our mailing list (<ulink + url="http://boost.org/more/mailing_lists.htm#jamboost"/>). The mailing list is + also mirrored to the newsgroup <ulink url="news://news.gmane.org/gmane.comp.lib.boost.build"/>. + </para> + + <para role="copyright"> + Copyright 2006, 2014 <ulink url="http://vladimirprus.com">Vladimir + Prus</ulink>. Distributed under the Boost Software License, Version 1.0. + (See accompanying file <filename>LICENSE_1_0.txt</filename> or copy at + <ulink + url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>) + </para> + + </dedication> diff --git a/boost/tools/build/doc/src/install.xml b/boost/tools/build/doc/src/install.xml new file mode 100644 index 00000000..8a272c73 --- /dev/null +++ b/boost/tools/build/doc/src/install.xml @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE chapter PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + + <chapter id="bbv2.installation"> + <title>Installation</title> + + <para> + To install Boost.Build from an official release or a nightly build, as + available on the <ulink url="http://boost.org/boost-build2">official web site</ulink>, + follow these steps: + </para> + + <orderedlist> + <listitem> + <simpara> + Unpack the release. On the command line, go to the root of the + unpacked tree. + </simpara> + </listitem> + + <listitem> + <simpara> + Run either <command>.\bootstrap.bat</command> (on Windows), or + <command>./bootstrap.sh</command> (on other operating systems). + </simpara> + </listitem> + + <listitem> + <simpara> + Run + <screen>./b2 install --prefix=<replaceable>PREFIX</replaceable></screen> + where <replaceable>PREFIX</replaceable> is a directory where you + want Boost.Build to be installed. + </simpara> + </listitem> + + <listitem> + <simpara> + Optionally, add <filename><replaceable>PREFIX</replaceable>/bin</filename> + to your <envar>PATH</envar> environment variable. + </simpara> + </listitem> + </orderedlist> + + <para>If you are not using a Boost.Build package, but rather the version + bundled with the Boost C++ Libraries, the above commands should be run + in the <filename>tools/build</filename> directory.</para> + + <para> + Now that Boost.Build is installed, you can try some of the examples. Copy + <filename><replaceable>PREFIX</replaceable>/share/boost-build/examples/hello</filename> + to a different directory, then change to that directory and run: +<screen><filename><replaceable>PREFIX</replaceable>/bin/b2</filename></screen> + A simple executable should be built. + </para> + + <!-- + <simpara> + Configure Boost.Build to recognize the build resources (such + as compilers and libraries) you have installed on your + system. Open the + <filename>user-config.jam</filename> file in the Boost.Build + root directory and follow the instructions there to describe + your toolsets and libraries, and, if necessary, where they + are located. + </simpara> + </listitem> + --> + + <!-- This part should not go into intoduction docs, but we need to + place it somewhere. + + <para>It is slighly better way is to copy + <filename>new/user-config.jam</filename> into one of the locations + where it can be found (given in <link linkend= + "bbv2.reference.init.config">this table</link>). This prevent you + from accidentally overwriting your config when updating.</para> + + --> + + <!-- + <bridgehead>Information for distributors</bridgehead> + + <para> + If you're planning to package Boost.Build for a Linux distribution, + please follow these guidelines: + + <itemizedlist> + <listitem><para>Create a separate package for Boost.Jam.</para></listitem> + + <listitem> + <para>Create another package for Boost.Build, and make + this package install all Boost.Build files to + <filename>/usr/share/boost-build</filename> directory. After + install, that directory should contain everything you see in + Boost.Build release package, except for + <filename>jam_src</filename> directory. If you're using Boost CVS + to obtain Boost.Build, as opposed to release package, take + everything from the <filename>tools/build</filename> directory. + For a check, make sure that + <filename>/usr/share/boost-build/boost-build.jam</filename> is installed. + </para> + + <para>Placing Boost.Build into <filename>/usr/share/boost-build</filename> + will make sure that <command>b2</command> will find Boost.Build + without any additional setup.</para> + </listitem> + + <listitem><para>Provide a + <filename>/etc/site-config.jam</filename> configuration file that will + contain: +<programlisting> +using gcc ; +</programlisting> + You might want to add dependency from Boost.Build package to gcc, + to make sure that users can always build Boost.Build examples. + </para></listitem> + </itemizedlist> + </para> + + <para>If those guidelines are met, users will be able to invoke + <command>b2/command> without any explicit configuration. + </para> + + + --> + + + </chapter> + +<!-- + Local Variables: + mode: nxml + sgml-indent-data:t + sgml-parent-document:("userman.xml" "chapter") + sgml-set-face: t + sgml-omittag:nil + sgml-shorttag:nil + sgml-namecase-general:t + sgml-general-insert-case:lower + sgml-minimize-attributes:nil + sgml-always-quote-attributes:t + sgml-indent-step:2 + sgml-exposed-tags:nil + sgml-local-catalogs:nil + sgml-local-ecat-files:nil + End: +--> + diff --git a/boost/tools/build/doc/src/main-target.xml b/boost/tools/build/doc/src/main-target.xml new file mode 100644 index 00000000..84afac14 --- /dev/null +++ b/boost/tools/build/doc/src/main-target.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<section id="bbv2.reference.class.main-target"> + + <title>Class main-target</title> + <indexterm> + <primary>main-target</primary> + </indexterm> + +<programlisting language="jam"> +class main-target : <link linkend="bbv2.reference.class.abstract-target">abstract-target</link> { + rule <link linkend="bbv2.reference.class.main-target.generate">generate</link> ( property-set ) + + # Methods inherited from <link linkend="bbv2.reference.class.abstract-target">abstract-target</link> + rule <link linkend="bbv2.reference.class.abstract-target.name">name</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.project">project</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.location">location</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.full-name">full-name</link> ( ) +} +</programlisting> + + <para> + A <link linkend="bbv2.reference.class.main-target">main-target</link> + represents a named top-level target in a Jamfile. + </para> + + <orderedlist> + + <listitem id="bbv2.reference.class.main-target.generate"> + <indexterm zone="bbv2.reference.class.main-target.generate"> + <primary>generate</primary> + <secondary>Main Target Method</secondary> + </indexterm> + <code language="jam">rule generate ( property-set )</code> + <para> + Overrides + <link linkend="bbv2.reference.class.abstract-target.generate">abstract-target.generate</link>. + + Select an alternative for this main target, by finding all alternatives + whose requirements are satisfied by <literal>property-set</literal> and + picking the one with the longest requirements set. Returns the result + of calling <link linkend="bbv2.reference.class.basic-target.generate">generate</link> + on that alternative. + </para> + + <para> + On success, returns: + <itemizedlist> + <listitem>a property-set with the usage requirements to be applied to dependents</listitem> + <listitem>a list of produced virtual targets, which may be empty.</listitem> + </itemizedlist> + </para> + </listitem> + + </orderedlist> + +</section> diff --git a/boost/tools/build/doc/src/overview.xml b/boost/tools/build/doc/src/overview.xml new file mode 100644 index 00000000..37bae1c9 --- /dev/null +++ b/boost/tools/build/doc/src/overview.xml @@ -0,0 +1,1700 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE chapter PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + + <chapter id="bbv2.overview"> + <title>Overview</title> + + <para> + This section will provide the information necessary to create your own + projects using Boost.Build. The information provided here is relatively + high-level, and <xref linkend="bbv2.reference"/> as well as the on-line + help system must be used to obtain low-level documentation (see <xref + linkend="bbv2.reference.init.options.help"/>). + </para> + + <para> + Boost.Build has two parts—a build engine + with its own interpreted language, and Boost.Build itself, implemented in + that language. The chain of events when you type + <command>b2</command> on the command line is as follows: + <orderedlist> + <listitem> + <para> + The Boost.Build executable tries to find Boost.Build modules and + loads the top-level module. The exact process is described in <xref linkend= + "bbv2.reference.init"/> + </para> + </listitem> + <listitem> + <para> + The top-level module loads user-defined configuration files, + <filename>user-config.jam</filename> and + <filename>site-config.jam</filename>, which define available toolsets. + </para> + </listitem> + <listitem> + <para> + The Jamfile in the current directory is read. That in turn might + cause reading of further Jamfiles. As a result, a tree of projects + is created, with targets inside projects. + </para> + </listitem> + <listitem> + <para> + Finally, using the build request specified on the command line, + Boost.Build decides which targets should be built and how. That + information is passed back to Boost.Jam, which takes care of + actually running the scheduled build action commands. + </para> + </listitem> + </orderedlist> + </para> + + <para> + So, to be able to successfully use Boost.Build, you need to know only four + things: + <itemizedlist> + <listitem> + <para> + <link linkend="bbv2.overview.configuration">How to configure + Boost.Build</link> + </para> + </listitem> + <listitem> + <para> + <link linkend="bbv2.overview.targets">How to declare targets in + Jamfiles</link> + </para> + </listitem> + <listitem> + <para> + <link linkend="bbv2.overview.build_process">How the build process + works</link> + </para> + </listitem> + <listitem> + <para> + Some Basics about the Boost.Jam language. See <xref linkend= + "bbv2.overview.jam_language"/>. + </para> + </listitem> + </itemizedlist> + </para> + + <section id="bbv2.overview.concepts"> + <title>Concepts</title> + + <para>Boost.Build has a few unique concepts that are introduced in this section. The best + way to explain the concepts is by comparison with more classical build tools.</para> + + <para> + When using any flavour of make, you directly specify <firstterm>targets</firstterm> + and commands that are used to create them from other target. The below example + creates <filename>a.o</filename> from <filename>a.c</filename> using a hardcoded + compiler invocation command. +<programlisting> +a.o: a.c + g++ -o a.o -g a.c +</programlisting> + This is a rather low-level description mechanism and it's hard to adjust commands, options, + and sets of created targets depending on the compiler and operating system used. + </para> + + <para> + To improve portability, most modern build system provide a set of higher-level + functions that can be used in build description files. Consider this example: +<programlisting> +add_program ("a", "a.c") +</programlisting> + This is a function call that creates the targets necessary to create an executable file + from the source file <filename>a.c</filename>. Depending on configured properties, + different command lines may be used. However, <code>add_program</code> is higher-level, + but rather thin level. All targets are created immediately when the build description + is parsed, which makes it impossible to perform multi-variant builds. Often, change + in any build property requires a complete reconfiguration of the build tree. + </para> + + <para> + In order to support true multivariant builds, Boost.Build introduces the concept of a + <indexterm> <primary>metatarget</primary> <secondary>definition</secondary></indexterm> + <indexterm> <primary>main target</primary> <see>metataget</see> </indexterm> + <firstterm>metatarget</firstterm>—an object that is created when the build description + is parsed and can be called later with specific build properties to generate + actual targets. + </para> + + <para> + Consider an example: +<programlisting> +exe a : a.cpp ; +</programlisting> + When this declaration is parsed, Boost.Build creates a metatarget, but does not + yet decide what files must be created, or what commands must be used. After + all build files are parsed, Boost.Build considers the properties requested on the + command line. Supposed you have invoked Boost.Build with: +<screen> +b2 toolset=gcc toolset=msvc +</screen> + In that case, the metatarget will be called twice, once with <code>toolset=gcc</code> + and once with <code>toolset=msvc</code>. Both invocations will produce concrete + targets, that will have different extensions and use different command lines. + </para> + + <para> + Another key concept is + <indexterm><primary>property</primary><secondary>definition</secondary></indexterm> + <firstterm>build property</firstterm>. A build property is a variable + that affects the build process. It can be specified on the command line, and is + passed when calling a metatarget. While all build tools have a similar mechanism, + Boost.Build differs by requiring that all build properties are declared in advance, + and providing a large set of properties with portable semantics. + </para> + + <para> + The final concept is <indexterm><primary>property</primary><secondary>propagation</secondary></indexterm> + <firstterm>property propagation</firstterm>. Boost.Build does not require that every + metatarget is called with the same properties. Instead, the + "top-level" metatargets are called with the properties specified on the command line. + Each metatarget can elect to augment or override some properties (in particular, + using the requirements mechanism, see <xref linkend="bbv2.overview.targets.requirements"/>). + Then, the dependency metatargets are called with the modified properties and produce + concrete targets that are then used in the build process. Of course, dependency metatargets + maybe in turn modify build properties and have dependencies of their own. + </para> + + <para>For a more in-depth treatment of the requirements and concepts, you may refer + to <ulink url="http://syrcose.ispras.ru/2009/files/04_paper.pdf">SYRCoSE 2009 Boost.Build article</ulink>. + </para> + + </section> + + <section id="bbv2.overview.jam_language"> + <title>Boost.Jam Language</title> + + <para> + This section will describe the basics of the Boost.Jam language—just + enough for writing Jamfiles. For more information, please see the + <link linkend="bbv2.jam">Boost.Jam</link> documentation. + </para> + + <para> + <link linkend="bbv2.jam">Boost.Jam</link> has an interpreted, procedural + language. On the lowest level, a <link linkend="bbv2.jam">Boost.Jam + </link> program consists of variables and <indexterm><primary>rule + </primary></indexterm> <firstterm>rules</firstterm> (the Jam term for + functions). They are grouped into modules—there is one global + module and a number of named modules. Besides that, a <link linkend= + "bbv2.jam">Boost.Jam</link> program contains classes and class + instances. + </para> + + <para> + Syntantically, a <link linkend="bbv2.jam">Boost.Jam</link> program + consists of two kind of elements—keywords (which have a special + meaning to <link linkend="bbv2.jam">Boost.Jam</link>) and literals. + Consider this code: +<programlisting> +a = b ; +</programlisting> + which assigns the value <literal>b</literal> to the variable <literal>a + </literal>. Here, <literal>=</literal> and <literal>;</literal> are + keywords, while <literal>a</literal> and <literal>b</literal> are + literals. + <warning> + <para> + All syntax elements, even keywords, must be separated by spaces. For + example, omitting the space character before <literal>;</literal> + will lead to a syntax error. + </para> + </warning> + If you want to use a literal value that is the same as some keyword, the + value can be quoted: +<programlisting> +a = "=" ; +</programlisting> + </para> + + <para> + All variables in <link linkend="bbv2.jam">Boost.Jam</link> have the same + type—list of strings. To define a variable one assigns a value to + it, like in the previous example. An undefined variable is the same as a + variable with an empty value. Variables can be accessed using the + <code>$(<replaceable>variable</replaceable>)</code> syntax. For example: +<programlisting> +a = $(b) $(c) ; +</programlisting> + </para> + + <para> + Rules are defined by specifying the rule name, the parameter names, and + the allowed value list size for each parameter. +<programlisting> +rule <replaceable>example</replaceable> + ( + <replaceable>parameter1</replaceable> : + <replaceable>parameter2 ?</replaceable> : + <replaceable>parameter3 +</replaceable> : + <replaceable>parameter4 *</replaceable> + ) + { + # rule body + } + </programlisting> + When this rule is called, the list passed as the first argument must + have exactly one value. The list passed as the second argument can + either have one value of be empty. The two remaining arguments can be + arbitrarily long, but the third argument may not be empty. + </para> + + <para> + The overview of <link linkend="bbv2.jam">Boost.Jam</link> language + statements is given below: +<programlisting> +helper 1 : 2 : 3 ; +x = [ helper 1 : 2 : 3 ] ; +</programlisting> + This code calls the named rule with the specified arguments. When the + result of the call must be used inside some expression, you need to add + brackets around the call, like shown on the second line. +<programlisting> +if cond { statements } [ else { statements } ] +</programlisting> + This is a regular if-statement. The condition is composed of: + <itemizedlist> + <listitem> + <para> + Literals (true if at least one string is not empty) + </para> + </listitem> + <listitem> + <para> + Comparisons: <code>a <replaceable>operator</replaceable> b</code> + where <replaceable>operator</replaceable> is one of + <code>=</code>, <code>!=</code>, <code><</code>, + <code>></code>, <code><=</code> or <code>>=</code>. The + comparison is done pairwise between each string in the left and + the right arguments. + </para> + </listitem> + <listitem> + <para> + Logical operations: <code>! a</code>, <code>a && b</code>, + <code>a || b</code> + </para> + </listitem> + <listitem> + <para> + Grouping: <code>( cond )</code> + </para> + </listitem> + </itemizedlist> +<programlisting> +for var in list { statements } +</programlisting> + Executes statements for each element in list, setting the variable + <varname>var</varname> to the element value. +<programlisting> +while cond { statements } +</programlisting> + Repeatedly execute statements while cond remains true upon entry. +<programlisting> +return values ; +</programlisting> + This statement should be used only inside a rule and assigns + <code>values</code> to the return value of the rule. + <warning> + <para> + The <code>return</code> statement does not exit the rule. For + example: +<programlisting> +rule test ( ) +{ + if 1 = 1 + { + return "reasonable" ; + } + return "strange" ; +} +</programlisting> + will return <literal>strange</literal>, not + <literal>reasonable</literal>. + </para> + </warning> +<programlisting> +import <replaceable>module</replaceable> ; +import <replaceable>module</replaceable> : <replaceable>rule</replaceable> ; +</programlisting> + The first form imports the specified module. All rules from that + module are made available using the qualified name: <code><replaceable> + module</replaceable>.<replaceable>rule</replaceable></code>. The second + form imports the specified rules only, and they can be called using + unqualified names. + </para> + + <para id="bbv2.overview.jam_language.actions"> + Sometimes, you need to specify the actual command lines to be used + when creating targets. In the jam language, you use named actions to do + this. For example: +<programlisting> +actions create-file-from-another +{ + create-file-from-another $(<) $(>) +} +</programlisting> + This specifies a named action called <literal> + create-file-from-another</literal>. The text inside braces is the + command to invoke. The <literal>$(<)</literal> variable will be + expanded to a list of generated files, and the <literal>$(>) + </literal> variable will be expanded to a list of source files. + </para> + + <para> + To adjust the command line flexibly, you can define a rule with the same + name as the action and taking three parameters—targets, sources and + properties. For example: +<programlisting> +rule create-file-from-another ( targets * : sources * : properties * ) +{ + if <variant>debug in $(properties) + { + OPTIONS on $(targets) = --debug ; + } +} +actions create-file-from-another +{ + create-file-from-another $(OPTIONS) $(<) $(>) +} +</programlisting> + In this example, the rule checks if a certain build property is specified. + If so, it sets the variable <varname>OPTIONS</varname> that is then used + inside the action. Note that the variables set "on a target" will be + visible only inside actions building that target, not globally. Were + they set globally, using variable named <varname>OPTIONS</varname> in + two unrelated actions would be impossible. + </para> + + <para> + More details can be found in the Jam reference, <xref + linkend="jam.language.rules"/>. + </para> + </section> + + <section id="bbv2.overview.configuration"> + <title>Configuration</title> + + <para> + On startup, Boost.Build searches and reads two configuration files: + <filename>site-config.jam</filename> and <filename>user-config.jam</filename>. + The first one is usually installed and maintained by a system administrator, and + the second is for the user to modify. You can edit the one in the top-level + directory of your Boost.Build installation or create a copy in your home + directory and edit the copy. The following table explains where both files + are searched. + </para> + + <table id="bbv2.reference.init.config"> + <title>Search paths for configuration files</title> + + <tgroup cols="3"> + <thead> + + <row> + <entry></entry> + + <entry>site-config.jam</entry> + + <entry>user-config.jam</entry> + </row> + + </thead> + <tbody> + + <row> + <entry>Linux</entry> + + <entry> + <simpara><code>/etc</code></simpara> + <simpara><code>$HOME</code></simpara> + <simpara><code>$BOOST_BUILD_PATH</code></simpara> + </entry> + + <entry> + <simpara><code>$HOME</code></simpara> + <simpara><code>$BOOST_BUILD_PATH</code></simpara> + </entry> + </row> + + <row> + <entry>Windows</entry> + + <entry> + <simpara><code>%SystemRoot%</code></simpara> + <simpara><code>%HOMEDRIVE%%HOMEPATH%</code></simpara> + <simpara><code>%HOME%</code></simpara> + <simpara><code>%BOOST_BUILD_PATH%</code></simpara> + </entry> + + <entry> + <simpara><code>%HOMEDRIVE%%HOMEPATH%</code></simpara> + <simpara><code>%HOME%</code></simpara> + <simpara><code>%BOOST_BUILD_PATH%</code></simpara> + </entry> + </row> + </tbody> + </tgroup> + </table> + + <tip> + <para> + You can use the <command>--debug-configuration</command> option to + find which configuration files are actually loaded. + </para> + </tip> + + <para> + Usually, <filename>user-config.jam</filename> just defines the available compilers + and other tools (see <xref linkend="bbv2.recipies.site-config"/> for more advanced + usage). A tool is configured using the following syntax: + </para> + +<programlisting> +using <replaceable>tool-name</replaceable> : ... ; +</programlisting> +<para> + The <code language="jam">using</code> rule is given the name of tool, and + will make that tool available to Boost.Build. For example, +<programlisting> +using gcc ; +</programlisting> will make the <ulink url="http://gcc.gnu.org">GCC</ulink> compiler available. + </para> + + <para> + All the supported tools are documented in <xref linkend="bbv2.reference.tools"/>, + including the specific options they take. Some general notes that apply to most + C++ compilers are below. + </para> + + <para> + For all the C++ compiler toolsets that Boost.Build supports + out-of-the-box, the list of parameters to + <code language="jam">using</code> is the same: <parameter + class="function">toolset-name</parameter>, <parameter + class="function">version</parameter>, <parameter + class="function">invocation-command</parameter>, and <parameter + class="function">options</parameter>. + </para> + + <para>If you have a single compiler, and the compiler executable + <itemizedlist> + <listitem><para>has its “usual name” and is in the + <envar>PATH</envar>, or</para></listitem> + <listitem><para>was installed in a standard “installation + directory”, or</para></listitem> + <listitem><para>can be found using a global system like the Windows + registry.</para></listitem> + </itemizedlist> + it can be configured by simply:</para> +<programlisting> +using <replaceable>tool-name</replaceable> ; +</programlisting> + <!-- TODO: mention auto-configuration? --> + + <para>If the compiler is installed in a custom directory, you should provide the + command that invokes the compiler, for example:</para> +<programlisting> +using gcc : : g++-3.2 ; +using msvc : : "Z:/Programs/Microsoft Visual Studio/vc98/bin/cl" ; +</programlisting> + <para> + Some Boost.Build toolsets will use that path to take additional actions + required before invoking the compiler, such as calling vendor-supplied + scripts to set up its required environment variables. When the compiler + executables for C and C++ are different, the path to the C++ compiler + executable must be specified. The command can + be any command allowed by the operating system. For example: +<programlisting> +using msvc : : echo Compiling && foo/bar/baz/cl ; +</programlisting> + will work. + </para> + + <para> + To configure several versions of a toolset, simply invoke the + <code language="jam">using</code> rule multiple times: +<programlisting> +using gcc : 3.3 ; +using gcc : 3.4 : g++-3.4 ; +using gcc : 3.2 : g++-3.2 ; +</programlisting> + Note that in the first call to <code language="jam">using</code>, the + compiler found in the <envar>PATH</envar> will be used, and there is no + need to explicitly specify the command. + </para> + +<!-- TODO: This is not actually relevant for gcc now, and we need to rethink this + <para>As shown above, both the <parameter + class="function">version</parameter> and <parameter + class="function">invocation-command</parameter> parameters are + optional, but there's an important restriction: if you configure + the same toolset more than once, you must pass the <parameter + class="function">version</parameter> + parameter every time. For example, the following is not allowed: +<programlisting> +using gcc ; +using gcc : 3.4 : g++-3.4 ; +</programlisting> + because the first <functionname>using</functionname> call does + not specify a <parameter class="function">version</parameter>. + </para> --> + + <para> + Many of toolsets have an <parameter class="function">options</parameter> + parameter to fine-tune the configuration. All of + Boost.Build's standard compiler toolsets accept four options + <varname>cflags</varname>, <varname>cxxflags</varname>, + <varname>compileflags</varname> and <varname>linkflags</varname> as <parameter + class="function">options</parameter> specifying flags that will be + always passed to the corresponding tools. Values of the + <varname>cflags</varname> feature are passed directly to the C + compiler, values of the <varname>cxxflags</varname> feature are + passed directly to the C++ compiler, and values of the + <varname>compileflags</varname> feature are passed to both. For + example, to configure a <command>gcc</command> toolset so that it + always generates 64-bit code you could write: +<programlisting> + using gcc : 3.4 : : <compileflags>-m64 <linkflags>-m64 ; +</programlisting> + </para> + + <warning> + <para> + Although the syntax used to specify toolset options is very similar + to syntax used to specify requirements in Jamfiles, the toolset options + are not the same as features. Don't try to specify a feature value + in toolset initialization. + </para> + </warning> + + </section> + + <section id="bbv2.overview.invocation"> + <title>Invocation</title> + + <para>To invoke Boost.Build, type <command>b2</command> on the command line. Three kinds + of command-line tokens are accepted, in any order:</para> + <variablelist> + <varlistentry> + <term>options</term> + + <listitem><para>Options start with either one or two dashes. The standard options + are listed below, and each project may add additional options</para></listitem> + </varlistentry> + + <varlistentry> + <term>properties</term> + + <listitem><para>Properties specify details of what you want to build (e.g. debug + or release variant). Syntactically, all command line tokens with an equal sign in them + are considered to specify properties. In the simplest form, a property looks like + <command><replaceable>feature</replaceable>=<replaceable>value</replaceable></command> + </para></listitem> + </varlistentry> + + <varlistentry> + <term>target</term> + + <listitem><para>All tokens that are neither options nor properties specify + what targets to build. The available targets entirely depend on the project + you are building.</para></listitem> + </varlistentry> + </variablelist> + + <section id="bbv2.overview.invocation.examples"> + <title>Examples</title> + + <para>To build all targets defined in the Jamfile in the current directory with the default properties, run: +<screen> +b2 +</screen> + </para> + + <para>To build specific targets, specify them on the command line: +<screen> +b2 lib1 subproject//lib2 +</screen> + </para> + + <para>To request a certain value for some property, add <literal> + <replaceable>property</replaceable>=<replaceable>value</replaceable></literal> to the command line: +<screen> +b2 toolset=gcc variant=debug optimization=space +</screen> + </para> + </section> + + <section id="bbv2.overview.invocation.options"> + <title>Options</title> + + <para>Boost.Build recognizes the following command line options.</para> + + <variablelist> + + <varlistentry id="bbv2.reference.init.options.help"> + <term><option>--help</option></term> + <listitem> + <para>Invokes the online help system. This prints general + information on how to use the help system with additional + --help* options. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--clean</option></term> + <listitem> + <para>Cleans all targets in the current directory and + in any subprojects. Note that unlike the <literal>clean</literal> + target in make, you can use <literal>--clean</literal> + together with target names to clean specific targets.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--clean-all</option></term> + <listitem> + <para>Cleans all targets, + no matter where they are defined. In particular, it will clean targets + in parent Jamfiles, and targets defined under other project roots. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--build-dir</option></term> + <listitem> + <para>Changes the build directories for all project roots being built. When + this option is specified, all Jamroot files must declare a project name. + The build directory for the project root will be computed by concatenating + the value of the <option>--build-dir</option> option, the project name + specified in Jamroot, and the build dir specified in Jamroot + (or <literal>bin</literal>, if none is specified). + </para> + + <para>The option is primarily useful when building from read-only + media, when you can't modify Jamroot. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--abbreviate-paths</option></term> + <listitem> + <para>Compresses target paths by abbreviating each component. + This option is useful to keep paths from becoming longer than + the filesystem supports. See also <xref linkend="bbv2.reference.buildprocess.targetpath"/>. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--hash</option></term> + <listitem> + <para>Compresses target paths using an MD5 hash. This option is + useful to keep paths from becoming longer than the filesystem + supports. This option produces shorter paths than --abbreviate-paths + does, but at the cost of making them less understandable. + See also <xref linkend="bbv2.reference.buildprocess.targetpath"/>. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--version</option></term> + <listitem> + <para>Prints information on the Boost.Build and Boost.Jam + versions. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>-a</option></term> + <listitem> + <para>Causes all files to be rebuilt.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>-n</option></term> + <listitem> + <para>Do not execute the commands, only print them.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>-q</option></term> + <listitem> + <para>Stop at the first error, as opposed to continuing to build targets + that don't depend on the failed ones.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>-j <replaceable>N</replaceable></option></term> + <listitem> + <para>Run up to <replaceable>N</replaceable> commands in parallel.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--debug-configuration</option></term> + <listitem> + <para>Produces debug information about the loading of Boost.Build + and toolset files.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--debug-building</option></term> + <listitem> + <para>Prints what targets are being built and with what properties. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--debug-generators</option></term> + <listitem> + <para>Produces debug output from the generator search process. + Useful for debugging custom generators. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>-d0</option></term> + <listitem> + <para>Suppress all informational messages.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>-d <replaceable>N</replaceable></option></term> + <listitem> + <para>Enable cumulative debugging levels from 1 to n. Values are: + <orderedlist> + <listitem>Show the actions taken for building targets, as they are executed (the default).</listitem> + <listitem>Show "quiet" actions and display all action text, as they are executed.</listitem> + <listitem>Show dependency analysis, and target/source timestamps/paths.</listitem> + <listitem>Show arguments and timing of shell invocations.</listitem> + <listitem>Show rule invocations and variable expansions.</listitem> + <listitem>Show directory/header file/archive scans, and attempts at binding to targets.</listitem> + <listitem>Show variable settings.</listitem> + <listitem>Show variable fetches, variable expansions, and evaluation of '"if"' expressions.</listitem> + <listitem>Show variable manipulation, scanner tokens, and memory usage.</listitem> + <listitem>Show profile information for rules, both timing and memory.</listitem> + <listitem>Show parsing progress of Jamfiles.</listitem> + <listitem>Show graph of target dependencies.</listitem> + <listitem>Show change target status (fate).</listitem> + </orderedlist> + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>-d +<replaceable>N</replaceable></option></term> + <listitem> + <para>Enable debugging level <replaceable>N</replaceable>.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>-o <replaceable>file</replaceable></option></term> + <listitem> + <para>Write the updating actions to the specified file instead of running them. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>-s <replaceable>var</replaceable>=<replaceable>value</replaceable></option></term> + <listitem> + <para>Set the variable <replaceable>var</replaceable> to + <replaceable>value</replaceable> in the global scope of the jam + language interpreter, overriding variables imported from the + environment. + </para> + </listitem> + </varlistentry> + </variablelist> + </section> + + <section id="bbv2.overview.invocation.properties"> + <title>Properties</title> + + <para>In the simplest case, the build is performed with a single set of properties, + that you specify on the command line with elements in the form + <command><replaceable>feature</replaceable>=<replaceable>value</replaceable></command>. + The complete list of features can be found in <xref linkend="bbv2.overview.builtins.features"/>. + The most common features are summarized below.</para> + + <table> + <tgroup cols="3"> + <thead> + + <row> + <entry>Feature</entry> + + <entry>Allowed values</entry> + + <entry>Notes</entry> + </row> + + </thead> + <tbody> + + <row> + <entry>variant</entry> + + <entry>debug,release</entry> + + <entry></entry> + </row> + + <row> + <entry>link</entry> + + <entry>shared,static</entry> + + <entry>Determines if Boost.Build creates shared or static libraries</entry> + </row> + + <row> + <entry>threading</entry> + + <entry>single,multi</entry> + + <entry>Cause the produced binaries to be thread-safe. This requires proper support in the source code itself.</entry> + </row> + + <row> + <entry>address-model</entry> + + <entry>32,64</entry> + + <entry>Explicitly request either 32-bit or 64-bit code generation. This typically + requires that your compiler is appropriately configured. Please refer to + <xref linkend="bbv2.reference.tools.compilers"/> and your compiler documentation + in case of problems.</entry> + </row> + + <row> + <entry>toolset</entry> + + <entry>(Depends on configuration)</entry> + + <entry>The C++ compiler to use. See <xref linkend="bbv2.reference.tools.compilers"/> for a detailed list.</entry> + </row> + + <row> + <entry>include</entry> + + <entry>(Arbitrary string)</entry> + + <entry>Additional include paths for C and C++ compilers.</entry> + </row> + + <row> + <entry>define</entry> + + <entry>(Arbitrary string)</entry> + + <entry>Additional macro definitions for C and C++ compilers. The string should be either + <code>SYMBOL</code> or <code>SYMBOL=VALUE</code></entry> + </row> + + <row> + <entry>cxxflags</entry> + + <entry>(Arbitrary string)</entry> + + <entry>Custom options to pass to the C++ compiler.</entry> + </row> + + <row> + <entry>cflags</entry> + + <entry>(Arbitrary string)</entry> + + <entry>Custom options to pass to the C compiler.</entry> + </row> + + <row> + <entry>linkflags</entry> + + <entry>(Arbitrary string)</entry> + + <entry>Custom options to pass to the C++ linker.</entry> + </row> + + <row> + <entry>runtime-link</entry> + + <entry>shared,static</entry> + + <entry>Determines if shared or static version of C and C++ runtimes should be used.</entry> + </row> + + </tbody> + </tgroup> + </table> + + <para>If you have more than one version of a given C++ toolset (e.g. configured in + <filename>user-config.jam</filename>, or autodetected, as happens with msvc), you can + request the specific version by passing + <code><replaceable>toolset</replaceable>-<replaceable>version</replaceable></code> as + the value of the <code>toolset</code> feature, for example <code>toolset=msvc-8.0</code>. + </para> + + + <para> + If a feature has a fixed set of values it can be specified more than + once on the command line. <!-- define 'base' and link to it --> + In which case, everything will be built several times -- + once for each specified value of a feature. For example, if you use + </para> +<screen> +b2 link=static link=shared threading=single threading=multi +</screen> + <para> + Then a total of 4 builds will be performed. For convenience, + instead of specifying all requested values of a feature in separate command line elements, + you can separate the values with commas, for example: + </para> +<screen> +b2 link=static,shared threading=single,multi +</screen> + <para> + The comma has this special meaning only if the feature has a fixed set of values, so + </para> +<screen> +b2 include=static,shared +</screen> + <para>is not treated specially.</para> + + </section> + + <section id="bbv2.overview.invocation.targets"> + <title>Targets</title> + + <para>All command line elements that are neither options nor properties are the names of the + targets to build. See <xref linkend="bbv2.reference.ids"/>. If no target is specified, + the project in the current directory is built.</para> + </section> + + </section> + + <section id="bbv2.overview.targets"> + <title>Declaring Targets</title> + + <para id="bbv2.overview.targets.main"> + A <firstterm>Main target</firstterm> is a user-defined named + entity that can be built, for example an executable file. + Declaring a main target is usually done using one of the main + target rules described in <xref linkend= + "bbv2.reference.rules"/>. The user can also declare + custom main target rules as shown in <xref + linkend="bbv2.extending.rules"/>. + </para> + + <indexterm><primary>main target</primary><secondary>declaration + syntax</secondary></indexterm> + <para>Most main target rules in Boost.Build have the same common + signature:</para> + + <!-- I think we maybe ought to be talking about a common + _signature_ here, having already explained Boost.Jam function + signatures at the beginning of this chapter. Then we could show + ( main-target-name : sources * : requirements * : default-build * : usage-requirements * ) + instead. More precise. + + Also, I suggest replacing "default-build" by "default-properties" everywhere. + --> + +<indexterm><primary>common signature</primary></indexterm> +<anchor id="bbv2.main-target-rule-syntax"/> +<programlisting> +rule <replaceable>rule-name</replaceable> ( + main-target-name : + sources + : + requirements * : + default-build * : + usage-requirements * ) +</programlisting> + + <itemizedlist> + <listitem> + <simpara> + <parameter>main-target-name</parameter> is the name used + to request the target on command line and to use it from + other main targets. A main target name may contain + alphanumeric characters, dashes + (‘<code>-</code>’), and underscores + (‘<code>_</code>’). + </simpara> + </listitem> + + <listitem> + <simpara> + <parameter>sources</parameter> is the list of source files and other main + targets that must be combined. + </simpara> + </listitem> + + <listitem> + <simpara> + <parameter>requirements</parameter> is the list of properties that must always + be present when this main target is built. + </simpara> + </listitem> + + <listitem> + <simpara> + <parameter>default-build</parameter> is the list of properties that will be used + unless some other value of the same feature is already + specified, e.g. on the command line or by propagation from a dependent target. + </simpara> + </listitem> + + <listitem> + <simpara> + <parameter>usage-requirements</parameter> is the list of properties that will be + propagated to all main targets that use this one, i.e. to all its + dependents. + </simpara> + </listitem> + </itemizedlist> + + <para> + Some main target rules have a different list of parameters as explicitly + stated in their documentation. + </para> + + <para>The actual requirements for a target are obtained by refining + the requirements of the project where the target is declared with the + explicitly specified requirements. The same is true for + usage-requirements. More details can be found in + <xref linkend="bbv2.reference.variants.proprefine"/> + </para> + + <section> + <title>Name</title> + + <!-- perphaps we should use 'name-target-name' to closer + bind this description to the rule's signature. Here, and for + other parameters. --> + <para>The name of main target has two purposes. First, it's used to refer to this target from + other targets and from command line. Second, it's used to compute the names of the generated files. + Typically, filenames are obtained from main target name by appending system-dependent suffixes and + prefixes. + </para> + + <para>The name of a main target can contain alphanumeric characters, + dashes, undescores and dots. The entire + name is significant when resolving references from other targets. For determining filenames, only the + part before the first dot is taken. For example:</para> +<programlisting> +obj test.release : test.cpp : <variant>release ; +obj test.debug : test.cpp : <variant>debug ; +</programlisting> + <para>will generate two files named <filename>test.obj</filename> (in two different directories), not + two files named <filename>test.release.obj</filename> and <filename>test.debug.obj</filename>. + </para> + + </section> + + <section> + <title>Sources</title> + + <para>The list of sources specifies what should be processed to + get the resulting targets. Most of the time, it's just a list of + files. Sometimes, you'll want to automatically construct the + list of source files rather than having to spell it out + manually, in which case you can use the + <link linkend="bbv2.reference.rules.glob">glob</link> rule. + Here are two examples:</para> +<programlisting> +exe a : a.cpp ; # a.cpp is the only source file +exe b : [ glob *.cpp ] ; # all .cpp files in this directory are sources +</programlisting> + <para> + Unless you specify a file with an absolute path, the name is + considered relative to the source directory — which is typically + the directory where the Jamfile is located, but can be changed as + described in <xref linkend= + "bbv2.overview.projects.attributes.projectrule"/>. + </para> + + <para> + <!-- use "project-id" here? --> + The list of sources can also refer to other main targets. Targets in + the same project can be referred to by name, while targets in other + projects must be qualified with a directory or a symbolic project + name. The directory/project name is separated from the target name by + a double forward slash. There is no special syntax to distinguish the + directory name from the project name—the part before the double + slash is first looked up as project name, and then as directory name. + For example: + </para> +<programlisting> +lib helper : helper.cpp ; +exe a : a.cpp helper ; +# Since all project ids start with slash, ".." is a directory name. +exe b : b.cpp ..//utils ; +exe c : c.cpp /boost/program_options//program_options ; +</programlisting> + <para> + The first exe uses the library defined in the same project. The second + one uses some target (most likely a library) defined by a Jamfile one + level higher. Finally, the third target uses a <ulink url= + "http://boost.org">C++ Boost</ulink> library, referring to it using + its absolute symbolic name. More information about target references + can be found in <xref linkend="bbv2.tutorial.libs"/> and <xref + linkend="bbv2.reference.ids"/>. + </para> + </section> + + <section id="bbv2.overview.targets.requirements"> + <title>Requirements</title> + <indexterm><primary>requirements</primary></indexterm> + <para>Requirements are the properties that should always be present when + building a target. Typically, they are includes and defines: +<programlisting> +exe hello : hello.cpp : <include>/opt/boost <define>MY_DEBUG ; +</programlisting> + There are a number of other features, listed in + <xref linkend="bbv2.overview.builtins.features"/>. For example if + a library can only be built statically, or a file can't be compiled + with optimization due to a compiler bug, one can use +<programlisting> +lib util : util.cpp : <link>static ; +obj main : main.cpp : <optimization>off ; +</programlisting> + </para> + + <para id="bbv2.overview.targets.requirements.conditional"> + <indexterm><primary>requirements</primary><secondary>conditional</secondary></indexterm> + Sometimes, particular relationships need to be maintained + among a target's build properties. This can be achieved with + <firstterm>conditional + requirements</firstterm>. For example, you might want to set + specific <code>#defines</code> when a library is built as shared, + or when a target's <code>release</code> variant is built in + release mode. +<programlisting> +lib network : network.cpp + : <emphasis role="bold"><link>shared:<define>NETWORK_LIB_SHARED</emphasis> + <variant>release:<define>EXTRA_FAST + ; +</programlisting> + + In the example above, whenever <filename>network</filename> is + built with <code><link>shared</code>, + <code><define>NETWORK_LIB_SHARED</code> will be in its + properties, too. + </para> + + <para>You can use several properties in the condition, for example: +<programlisting> +lib network : network.cpp + : <toolset>gcc,<optimization>speed:<define>USE_INLINE_ASSEMBLER + ; +</programlisting> + </para> + + <para id="bbv2.overview.targets.requirements.indirect"> + <indexterm><primary>requirements</primary><secondary>indirect</secondary></indexterm> + A more powerful variant of conditional requirements + is <firstterm>indirect conditional requirements</firstterm>. + You can provide a rule that will be called with the current build properties and can compute additional properties + to be added. For example: +<programlisting> +lib network : network.cpp + : <conditional>@my-rule + ; +rule my-rule ( properties * ) +{ + local result ; + if <toolset>gcc <optimization>speed in $(properties) + { + result += <define>USE_INLINE_ASSEMBLER ; + } + return $(result) ; +} +</programlisting> + This example is equivalent to the previous one, but for complex cases, indirect conditional + requirements can be easier to write and understand. + </para> + + <para>Requirements explicitly specified for a target are usually + combined with the requirements specified for the containing project. You + can cause a target to completely ignore a specific project requirement + using the syntax by adding a minus sign before the property, for example: +<programlisting> +exe main : main.cpp : <emphasis role="bold">-<define>UNNECESSARY_DEFINE</emphasis> ; +</programlisting> + This syntax is the only way to ignore free properties, such as defines, + from a parent. It can be also useful for ordinary properties. Consider + this example: +<programlisting> +project test : requirements <threading>multi ; +exe test1 : test1.cpp ; +exe test2 : test2.cpp : <threading>single ; +exe test3 : test3.cpp : -<threading>multi ; +</programlisting> + Here, <code>test1</code> inherits the project requirements and will always + be built in multi-threaded mode. The <code>test2</code> target + <emphasis>overrides</emphasis> the project's requirements and will + always be built in single-threaded mode. In contrast, the + <code>test3</code> target <emphasis>removes</emphasis> a property + from the project requirements and will be built either in single-threaded or + multi-threaded mode depending on which variant is requested by the + user.</para> + + <para>Note that the removal of requirements is completely textual: + you need to specify exactly the same property to remove it.</para> + + </section> + + <section> + <title>Default Build</title> + + <para>The <varname>default-build</varname> parameter + is a set of properties to be used if the build request does + not otherwise specify a value for features in the set. For example: +<programlisting> +exe hello : hello.cpp : : <threading>multi ; +</programlisting> + would build a multi-threaded target unless the user + explicitly requests a single-threaded version. The difference between + the requirements and the default-build is that the requirements cannot be + overridden in any way. + </para> + </section> + + <section> + <title>Additional Information</title> + + <para> + The ways a target is built can be so different that + describing them using conditional requirements would be + hard. For example, imagine that a library actually uses + different source files depending on the toolset used to build + it. We can express this situation using <firstterm>target + alternatives</firstterm>: +<programlisting> +lib demangler : dummy_demangler.cpp ; # alternative 1 +lib demangler : demangler_gcc.cpp : <toolset>gcc ; # alternative 2 +lib demangler : demangler_msvc.cpp : <toolset>msvc ; # alternative 3 +</programlisting> + In the example above, when built with <literal>gcc</literal> + or <literal>msvc</literal>, <filename>demangler</filename> + will use a source file specific to the toolset. Otherwise, it + will use a generic source file, + <filename>dummy_demangler.cpp</filename>. + </para> + + <para>It is possible to declare a target inline, i.e. the "sources" + parameter may include calls to other main rules. For example:</para> + +<programlisting> +exe hello : hello.cpp + [ obj helpers : helpers.cpp : <optimization>off ] ;</programlisting> + + <para> + Will cause "helpers.cpp" to be always compiled without + optimization. When referring to an inline main target, its declared + name must be prefixed by its parent target's name and two dots. In + the example above, to build only helpers, one should run + <code>b2 hello..helpers</code>. + </para> + + <para>When no target is requested on the command line, all targets in the + current project will be built. If a target should be built only by + explicit request, this can be expressed by the + <link linkend="bbv2.reference.rules.explicit">explicit</link> rule: + <programlisting> +explicit install_programs ;</programlisting> + </para> + + </section> + </section> + + <section id="bbv2.overview.projects"> + <title>Projects</title> + + <para>As mentioned before, targets are grouped into projects, + and each Jamfile is a separate project. Projects are useful + because they allow us to group related targets together, define + properties common to all those targets, and assign a symbolic + name to the project that can be used in referring to its + targets. + </para> + + <para>Projects are named using the + <code language="jam">project</code> rule, which has the + following syntax: +<programlisting> +project <replaceable>id</replaceable> : <replaceable>attributes</replaceable> ; +</programlisting> + Here, <replaceable>attributes</replaceable> is a sequence of + rule arguments, each of which begins with an attribute-name + and is followed by any number of build properties. The list + of attribute names along with its handling is also shown in + the table below. For example, it is possible to write: +<programlisting> +project tennis + : requirements <threading>multi + : default-build release + ; +</programlisting> + </para> + + <para>The possible attributes are listed below.</para> + + <para><emphasis>Project id</emphasis> is a short way to denote a project, as + opposed to the Jamfile's pathname. It is a hierarchical path, + unrelated to filesystem, such as "boost/thread". <link linkend= + "bbv2.reference.ids">Target references</link> make use of project ids to + specify a target.</para> + <!-- + This is actually spelled "project-id," isn't it? You + have to fix all of these and use a code font. Also below + in the table. + --> + + <para><emphasis>Source location</emphasis> specifies the directory where sources + for the project are located.</para> + + <para><emphasis>Project requirements</emphasis> are requirements that apply to + all the targets in the projects as well as all subprojects.</para> + + <para><emphasis>Default build</emphasis> is the build request that should be + used when no build request is specified explicitly.</para> + <!-- + This contradicts your earlier description of default + build and I believe it is incorrect. Specifying a build + request does not neccessarily render default build + ineffective, because it may cover different features. + This description is repeated too many times in the + documentation; you almost *had* to get it wrong once. + --> + + <para id="bbv2.overview.projects.attributes.projectrule"> + The default values for those attributes are + given in the table below. + + <table> + <title/> + <tgroup cols="4"> + <thead> + <row> + <entry>Attribute</entry> + + <entry>Name</entry> + + <entry>Default value</entry> + + <entry>Handling by the <code language="jam">project</code> + rule</entry> + + </row> + </thead> + + <tbody> + + <row> + <entry>Project id</entry> + + <entry>none</entry> + + <entry>none</entry> + + <entry>Assigned from the first parameter of the 'project' rule. + It is assumed to denote absolute project id.</entry> + </row> + + <row> + <entry>Source location</entry> + + <entry><literal>source-location</literal></entry> + + <entry>The location of jamfile for the project</entry> + + <entry>Sets to the passed value</entry> + </row> + + <row> + <entry>Requirements</entry> + + <entry><literal>requirements</literal></entry> + + <entry>The parent's requirements</entry> + + <entry>The parent's requirements are refined with the passed + requirement and the result is used as the project + requirements.</entry> + </row> + + <row> + <entry>Default build</entry> + + <entry><literal>default-build</literal></entry> + + <entry>none</entry> + + <entry>Sets to the passed value</entry> + </row> + + <row> + <entry>Build directory</entry> + + <entry><literal>build-dir</literal></entry> + + <entry>Empty if the parent has no build directory set. + Otherwise, the parent's build directory with the + relative path from parent to the current project + appended to it. + </entry> + + <entry>Sets to the passed value, interpreted as relative to the + project's location.</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + + <para>Besides defining projects and main targets, Jamfiles + often invoke various utility rules. For the full list of rules + that can be directly used in Jamfile see + <xref linkend="bbv2.reference.rules"/>. + </para> + + <para>Each subproject inherits attributes, constants and rules + from its parent project, which is defined by the nearest + Jamfile in an ancestor directory above + the subproject. The top-level project is declared in a file + called <filename>Jamroot</filename> rather than + <filename>Jamfile</filename>. When loading a project, + Boost.Build looks for either <filename>Jamroot</filename> or + <code>Jamfile</code>. They are handled identically, except + that if the file is called <filename>Jamroot</filename>, the + search for a parent project is not performed. + </para> + + <para>Even when building in a subproject directory, parent + project files are always loaded before those of their + subprojects, so that every definition made in a parent project + is always available to its children. The loading order of any + other projects is unspecified. Even if one project refers to + another via the <code>use-project</code> or a target reference, + no specific order should be assumed. + </para> + + <note> + <para>Giving the root project the special name + “<filename>Jamroot</filename>” ensures that + Boost.Build won't misinterpret a directory above it as the + project root just because the directory contains a Jamfile. + <!-- The logic of the previous reasoning didn't hang together --> + </para> + </note> + + <!-- All this redundancy with the tutorial is bad. The tutorial + should just be made into the introductory sections of this + document, which should be called the "User Guide." It's + perfectly appropriate to start a user guide with that kind + of material. --> + </section> + + <section id="bbv2.overview.build_process"> + <title>The Build Process</title> + + <para>When you've described your targets, you want Boost.Build to run the + right tools and create the needed targets. + <!-- That sentence is awkward and doesn't add much. --> + This section will describe + two things: how you specify what to build, and how the main targets are + actually constructed. + </para> + + <para>The most important thing to note is that in Boost.Build, unlike + other build tools, the targets you declare do not correspond to specific + files. What you declare in a Jamfile is more like a “metatarget.” + <!-- Do we need a new word? We already have “main target.” If + you're going to introduce “metatarget” you should at least + tie it together with the main target concept. It's too + strange to have been saying “main target” all along and now + suddenly start saying “what you declare in a jamfile” --> + Depending on the properties you specify on the command line, + each metatarget will produce a set of real targets corresponding + to the requested properties. It is quite possible that the same + metatarget is built several times with different properties, + producing different files. + </para> + <tip> + <para> + This means that for Boost.Build, you cannot directly obtain a build + variant from a Jamfile. There could be several variants requested by the + user, and each target can be built with different properties. + </para> + </tip> + + <section id="bbv2.overview.build_request"> + <title>Build Request</title> + + <para> + The command line specifies which targets to build and with which + properties. For example: +<programlisting> +b2 app1 lib1//lib1 toolset=gcc variant=debug optimization=full +</programlisting> + would build two targets, "app1" and "lib1//lib1" with the specified + properties. You can refer to any targets, using + <link linkend="bbv2.reference.ids">target id</link> and specify arbitrary + properties. Some of the properties are very common, and for them the name + of the property can be omitted. For example, the above can be written as: +<programlisting> +b2 app1 lib1//lib1 gcc debug optimization=full +</programlisting> + The complete syntax, which has some additional shortcuts, is + described in <xref linkend="bbv2.overview.invocation"/>. + </para> + </section> + + <section><title>Building a main target</title> + + <para>When you request, directly or indirectly, a build of a main target + with specific requirements, the following steps are done. Some brief + explanation is provided, and more details are given in <xref + linkend="bbv2.reference.buildprocess"/>. + <orderedlist> + + <listitem><para>Applying default build. If the default-build + property of a target specifies a value of a feature that is not + present in the build request, that value is added.</para> + <!-- + Added to what? Don't say “the build request!” The + request is what was requested; if its meaning changes + the reader will be confused. + --> + </listitem> + + <listitem><para>Selecting the main target alternative to use. For + each alternative we look how many properties are present both in + alternative's requirements, and in build request. The + alternative with largest number of matching properties is selected. + </para></listitem> + + <listitem><para>Determining "common" properties. + <!-- It would be nice to have a better name for this. But + even more importantly, unless you say something about + the reason for choosing whatever term you use, the + reader is going to wonder what it means. --> + The build request + is <link linkend="bbv2.reference.variants.proprefine">refined</link> + with target's requirements. + <!-- It's good that you have the links here and below, + but I'm concerned that it doesn't communicate well + in print and there's not enough information for the + print reader. Maybe we need separate XSL for PDF + printing that generates a readable footnote. --> + The conditional properties in + requirements are handled as well. Finally, default values of + features are added. + </para></listitem> + + <listitem><para>Building targets referred by the sources list and + dependency properties. The list of sources and the properties + can refer to other target using <link + linkend="bbv2.reference.ids">target references</link>. For each + reference, we take all <link + linkend="bbv2.reference.features.attributes.propagated">propagated</link> + properties, refine them by explicit properties specified in the + target reference, and pass the resulting properties as build + request to the other target. + </para></listitem> + + <listitem><para>Adding the usage requirements produced when building + dependencies to the "common" properties. When dependencies are + built in the previous step, they return + <!-- don't assume reader has a mental model for BB internals! --> + both the set of created + "real" targets, and usage requirements. The usage requirements + are added to the common properties and the resulting property + set will be used for building the current target. + </para></listitem> + + <listitem><para>Building the target using generators. To convert the + sources to the desired type, Boost.Build uses "generators" --- + objects that correspond to tools like compilers and linkers. Each + generator declares what type of targets it can produce and what + type of sources it requires. Using this information, Boost.Build + determines which generators must be run to produce a specific + target from specific sources. When generators are run, they return + the "real" targets. + </para></listitem> + + <listitem><para>Computing the usage requirements to be returned. The + conditional properties in usage requirements are expanded + <!-- what does "expanded" mean? --> + and the result is returned.</para></listitem> + </orderedlist> + </para> + </section> + + <section><title>Building a Project</title> + + <para>Often, a user builds a complete project, not just one main + target. In fact, invoking <command>b2</command> without + arguments + <!-- do you know the difference between parameters and + arguments? I only learned this year --> + builds the project defined in the current + directory.</para> + + <para>When a project is built, the build request is passed without + modification to all main targets in that project. + <!-- What does it mean to pass a build request to a target? + --> + It's is possible to + prevent implicit building of a target in a project with the + <code>explicit</code> rule: +<programlisting> +explicit hello_test ; +</programlisting> + would cause the <code>hello_test</code> target to be built only if + explicitly requested by the user or by some other target. + </para> + + <para>The Jamfile for a project can include a number of + <code>build-project</code> rule calls that specify additional projects to + be built. + </para> + + </section> + + </section> + + </chapter> + +<!-- + Local Variables: + mode: nxml + sgml-indent-data: t + sgml-parent-document: ("userman.xml" "chapter") + sgml-set-face: t + End: +--> diff --git a/boost/tools/build/doc/src/path.xml b/boost/tools/build/doc/src/path.xml new file mode 100644 index 00000000..f11906db --- /dev/null +++ b/boost/tools/build/doc/src/path.xml @@ -0,0 +1,249 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<section id="bbv2.reference.modules.path"> + + <title>path</title> + <indexterm> + <primary>path</primary> + <secondary>module</secondary> + </indexterm> + + <para> + Performs various path manipulations. Paths are always in a 'normalized' + representation. In it, a path may be either: + + <itemizedlist> + <listitem><para><code>'.'</code>, or</para></listitem> + <listitem> + <para> + <code>['/'] [ ( '..' '/' )* (token '/')* token ]</code> + </para> + </listitem> + </itemizedlist> + + In plain english, a path can be rooted, <code>'..'</code> + elements are allowed only at the beginning, and it never + ends in slash, except for the path consisting of slash only. + </para> + + <orderedlist> + + <listitem id="bbv2.reference.modules.path.make"> + <indexterm zone="bbv2.reference.modules.path.make"> + <primary>make</primary> + <secondary>path</secondary> + </indexterm> + <code language="jam">rule make ( native )</code> + <para>Converts the native path into normalized form.</para> + </listitem> + + <listitem id="bbv2.reference.modules.path.native"> + <indexterm zone="bbv2.reference.modules.path.native"> + <primary>native</primary> + </indexterm> + <code language="jam">rule native ( path )</code> + <para>Builds the native representation of the path.</para> + </listitem> + + <listitem id="bbv2.reference.modules.path.is-rooted"> + <indexterm zone="bbv2.reference.modules.path.is-rooted"> + <primary>is-rooted</primary> + </indexterm> + <code language="jam">rule is-rooted ( path )</code> + <para>Tests if a path is rooted.</para> + </listitem> + + <listitem id="bbv2.reference.modules.path.has-parent"> + <indexterm zone="bbv2.reference.modules.path.has-parent"> + <primary>has-parent</primary> + </indexterm> + <code language="jam">rule has-parent ( path )</code> + <para>Tests if a path has a parent.</para> + </listitem> + + <listitem id="bbv2.reference.modules.path.basename"> + <indexterm zone="bbv2.reference.modules.path.basename"> + <primary>basename</primary> + </indexterm> + <code language="jam">rule basename ( path )</code> + <para>Returns the path without any directory components.</para> + </listitem> + + <listitem id="bbv2.reference.modules.path.parent"> + <indexterm zone="bbv2.reference.modules.path.parent"> + <primary>parent</primary> + </indexterm> + <code language="jam">rule parent ( path )</code> + <para>Returns the parent directory of the path. If no parent exists, an error is issued.</para> + </listitem> + + <listitem id="bbv2.reference.modules.path.reverse"> + <indexterm zone="bbv2.reference.modules.path.reverse"> + <primary>reverse</primary> + </indexterm> + <code language="jam">rule reverse ( path )</code> + <para> + Returns <code language="jam">path2</code> such that + <code language="jam">[ join path path2 ] = "."</code>. + The path may not contain <code language="jam">".."</code> + element or be rooted. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.path.join"> + <indexterm zone="bbv2.reference.modules.path.join"> + <primary>join</primary> + </indexterm> + <code language="jam">rule join ( elements + )</code> + <para> + 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. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.path.root"> + <indexterm zone="bbv2.reference.modules.path.root"> + <primary>root</primary> + </indexterm> + <code language="jam">rule root ( path root )</code> + <para> + If <code language="jam">path</code> is relative, it is rooted at + <code language="jam">root</code>. Otherwise, it is unchanged. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.path.pwd"> + <indexterm zone="bbv2.reference.modules.path.pwd"> + <primary>pwd</primary> + </indexterm> + <code language="jam">rule pwd ( )</code> + <para>Returns the current working directory.</para> + </listitem> + + <listitem id="bbv2.reference.modules.path.glob"> + <indexterm zone="bbv2.reference.modules.path.glob"> + <primary>glob</primary> + </indexterm> + <code language="jam">rule glob ( dirs * : patterns + : exclude-patterns * )</code> + <para> + 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: + <itemizedlist> + <listitem> + <para>'?' matches any character</para> + </listitem> + <listitem> + <para>'*' matches an arbitrary number of characters</para> + </listitem> + </itemizedlist> + 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: +<programlisting language="jam"> +[ glob . : *.cpp ] +[ glob . : */build/Jamfile ] +</programlisting> + </para> + </listitem> + + <listitem id="bbv2.reference.modules.path.glob-tree"> + <indexterm zone="bbv2.reference.modules.path.glob-tree"> + <primary>glob-tree</primary> + </indexterm> + <code language="jam">rule glob-tree ( roots * : patterns + : exclude-patterns * )</code> + <para> + Recursive version of <link linkend="bbv2.reference.modules.path.glob">glob</link>. + 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. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.path.exists"> + <indexterm zone="bbv2.reference.modules.path.exists"> + <primary>exists</primary> + </indexterm> + <code language="jam">rule exists ( file )</code> + <para>Returns true if the specified file exists.</para> + </listitem> + + <listitem id="bbv2.reference.modules.path.all-parents"> + <indexterm zone="bbv2.reference.modules.path.all-parents"> + <primary>all-parents</primary> + </indexterm> + <code language="jam">rule all-parents ( path : upper_limit ? : cwd ? )</code> + <para> + 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 + <code language="jam">upper_limit</code> is specified, directories above it + will be pruned. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.path.glob-in-parents"> + <indexterm zone="bbv2.reference.modules.path.glob-in-parents"> + <primary>glob-in-parents</primary> + </indexterm> + <code language="jam">rule glob-in-parents ( dir : patterns + : upper-limit ? )</code> + <para> + Search for <code language="jam">patterns</code> in parent directories + of <code language="jam">dir</code>, up to and including + <code language="jam">upper_limit</code>, if it is specified, or + till the filesystem root otherwise. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.path.relative"> + <indexterm zone="bbv2.reference.modules.path.relative"> + <primary>relative</primary> + </indexterm> + <code language="jam">rule relative ( child parent : no-error ? )</code> + <para> + Assuming <code language="jam">child</code> is a subdirectory of + <code language="jam">parent</code>, return the relative path from + <code language="jam">parent</code> to <code language="jam">child</code>. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.path.relative-to"> + <indexterm zone="bbv2.reference.modules.path.relative-to"> + <primary>relative-to</primary> + </indexterm> + <code language="jam">rule relative-to ( path1 path2 )</code> + <para>Returns the minimal path to path2 that is relative path1.</para> + </listitem> + + <listitem id="bbv2.reference.modules.path.programs-path"> + <indexterm zone="bbv2.reference.modules.path.programs-path"> + <primary>programs-path</primary> + </indexterm> + <code language="jam">rule programs-path ( )</code> + <para> + Returns the list of paths which are used by the operating system for + looking up programs. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.path.mkdirs"> + <indexterm zone="bbv2.reference.modules.path.mkdirs"> + <primary>mkdirs</primary> + </indexterm> + <code language="jam">rule makedirs ( path )</code> + <para> + Creates a directory and all parent directories that do not + already exist. + </para> + </listitem> + + </orderedlist> + +</section> diff --git a/boost/tools/build/doc/src/project-target.xml b/boost/tools/build/doc/src/project-target.xml new file mode 100644 index 00000000..1e4e39a5 --- /dev/null +++ b/boost/tools/build/doc/src/project-target.xml @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<section id="bbv2.reference.class.project-target"> + + <title>Class project-target</title> + <indexterm> + <primary>project-target</primary> + </indexterm> + +<programlisting language="jam"> +class project-target : <link linkend="bbv2.reference.class.abstract-target">abstract-target</link> { + rule <link linkend="bbv2.reference.class.project-target.generate">generate</link> ( property-set ) + rule <link linkend="bbv2.reference.class.project-target.build-dir">build-dir</link> ( ) + rule <link linkend="bbv2.reference.class.project-target.main-target">main-target</link> ( name ) + rule <link linkend="bbv2.reference.class.project-target.has-main-target">has-main-target</link> ( name ) + rule <link linkend="bbv2.reference.class.project-target.find">find</link> ( id : no-error ? ) + + # Methods inherited from <link linkend="bbv2.reference.class.abstract-target">abstract-target</link> + rule <link linkend="bbv2.reference.class.abstract-target.name">name</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.project">project</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.location">location</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.full-name">full-name</link> ( ) +} +</programlisting> + + <para> + This class has the following responsibilities: + <itemizedlist> + <listitem> + <para> + Maintaining a list of main targets in this project and building them. + </para> + </listitem> + </itemizedlist> + </para> + + <orderedlist> + + <listitem id="bbv2.reference.class.project-target.generate"> + <indexterm zone="bbv2.reference.class.project-target.generate"> + <primary>generate</primary> + <secondary>Project Target</secondary> + </indexterm> + <code language="jam">rule generate ( property-set )</code> + <para> + Overrides + <link linkend="bbv2.reference.class.abstract-target.generate">abstract-target.generate</link>. + + Generates virtual targets for all the targets contained in this project. + </para> + + <para> + On success, returns: + <itemizedlist> + <listitem>a property-set with the usage requirements to be applied to dependents</listitem> + <listitem>a list of produced virtual targets, which may be empty.</listitem> + </itemizedlist> + </para> + </listitem> + + <listitem id="bbv2.reference.class.project-target.build-dir"> + <indexterm zone="bbv2.reference.class.project-target.build-dir"> + <primary>build-dir</primary> + <secondary>Project Target Method</secondary> + </indexterm> + <code language="jam">rule build-dir ( )</code> + <para> + Returns the root build directory of the project. + </para> + </listitem> + + <listitem id="bbv2.reference.class.project-target.main-target"> + <indexterm zone="bbv2.reference.class.project-target.main-target"> + <primary>main-target</primary> + <secondary>Project Target Method</secondary> + </indexterm> + <code language="jam">rule main-target ( name )</code> + <para> + Returns a <link linkend="bbv2.reference.class.main-target">main-target</link> + class instance corresponding to <literal>name</literal>. + Can only be called after the project has been fully loaded. + </para> + </listitem> + + <listitem id="bbv2.reference.class.project-target.has-main-target"> + <indexterm zone="bbv2.reference.class.project-target.has-main-target"> + <primary>has-main-target</primary> + <secondary>Project Target Method</secondary> + </indexterm> + <code language="jam">rule has-main-target ( name )</code> + <para> + Returns whether a <link linkend="bbv2.reference.class.main-target">main-target</link> + with the specified name exists. + Can only be called after the project has been fully loaded. + </para> + </listitem> + + <listitem id="bbv2.reference.class.project-target.find"> + <indexterm zone="bbv2.reference.class.project-target.find"> + <primary>find</primary> + <secondary>Project Target Method</secondary> + </indexterm> + <code language="jam">rule find ( id : no-error ? )</code> + <para> + 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 <literal>no-error</literal> parameter. + </para> + </listitem> + + <!-- + + I'm not sure whether these should be considered public interfaces. + Leave them out for now (SW): + + rule project-module ( ) + rule get ( attribute ) + + --> + + <!-- + + The following are not documented because I consider them implementation details (SW): + + rule __init__ ( name : project-module parent-project ? + : requirements * : default-build * ) - invoked by the build system. + + rule targets-to-build ( ) - internal to project-target + rule mark-target-as-explicit ( target-name * ) - Implementation of explicit + rule mark-target-as-always ( target-name * ) - Implementation of always + rule add-alternative ( target-instance ) - Implementation of targets.main-target-alternative + rule find-really ( id ) - internal to project-target + rule build-main-targets ( ) - internal to project-target + rule inherit ( parent ) - internal to project-target + rule add-constant ( name : value + : type ? ) - Implementation of constant/path-constant + + --> + + </orderedlist> + +</section> diff --git a/boost/tools/build/doc/src/property-set.xml b/boost/tools/build/doc/src/property-set.xml new file mode 100644 index 00000000..a5b5b8c7 --- /dev/null +++ b/boost/tools/build/doc/src/property-set.xml @@ -0,0 +1,128 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<section id="bbv2.reference.class.property-set"> + + <title>Class property-set</title> + <indexterm> + <primary>property-set</primary> + </indexterm> + + <para>Class for storing a set of properties.</para> + +<programlisting language="jam"> +class property-set { + rule <link linkend="bbv2.reference.class.property-set.raw">raw</link> ( ) + rule <link linkend="bbv2.reference.class.property-set.str">str</link> ( ) + rule <link linkend="bbv2.reference.class.property-set.propagated">propagated</link> ( ) + rule <link linkend="bbv2.reference.class.property-set.add">add</link> ( ps ) + rule <link linkend="bbv2.reference.class.property-set.add-raw">add-raw</link> ( properties * ) + rule <link linkend="bbv2.reference.class.property-set.refine">refine</link> ( ps ) + rule <link linkend="bbv2.reference.class.property-set.get">get</link> ( feature ) +} +</programlisting> + + <para> + 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. + </para> + + <orderedlist> + + <listitem id="bbv2.reference.class.property-set.raw"> + <indexterm zone="bbv2.reference.class.property-set.raw"> + <primary>raw</primary> + <secondary>Property Set Method</secondary> + </indexterm> + <code language="jam">rule raw ( )</code> + <para>Returns a Jam list of the stored properties.</para> + </listitem> + + <listitem id="bbv2.reference.class.property-set.str"> + <indexterm zone="bbv2.reference.class.property-set.str"> + <primary>str</primary> + <secondary>Property Set Method</secondary> + </indexterm> + <code language="jam">rule str ( )</code> + <para>Returns the string repesentation of the stored properties.</para> + </listitem> + + <listitem id="bbv2.reference.class.property-set.propagated"> + <indexterm zone="bbv2.reference.class.property-set.propagated"> + <primary>propagated</primary> + <secondary>Property Set Method</secondary> + </indexterm> + <code language="jam">rule propagated ( )</code> + <para> + Returns a <link linkend="bbv2.reference.class.property-set">property-set</link> + containing all the <link linkend="bbv2.reference.features.attributes.propagated">propagated</link> + properties in this <link linkend="bbv2.reference.class.property-set">property-set</link>. + </para> + </listitem> + + <listitem id="bbv2.reference.class.property-set.add"> + <indexterm zone="bbv2.reference.class.property-set.add"> + <primary>add</primary> + <secondary>Property Set Method</secondary> + </indexterm> + <code language="jam">rule add ( ps )</code> + <para> + Returns a new <link linkend="bbv2.reference.class.property-set"> + property-set</link> containing the union of the properties + in this <link linkend="bbv2.reference.class.property-set"> + property-set</link> and in <literal>ps</literal>. + <note> + <para> + If <literal>ps</literal> contains non-free properties + that should override the values in this object, use + <link linkend="bbv2.reference.class.property-set.refine"> + refine</link> instead. + </para> + </note> + </para> + </listitem> + + <listitem id="bbv2.reference.class.property-set.add-raw"> + <indexterm zone="bbv2.reference.class.property-set.add-raw"> + <primary>add-raw</primary> + <secondary>Property Set Method</secondary> + </indexterm> + <code language="jam">rule add-raw ( properties * )</code> + <para> + Link <link linkend="bbv2.reference.class.property-set.add"> + add</link>, except that it takes a list of properties + instead of a <link linkend="bbv2.reference.class.property-set"> + property-set</link>. + </para> + </listitem> + + <listitem id="bbv2.reference.class.property-set.refine"> + <indexterm zone="bbv2.reference.class.property-set.refine"> + <primary>refine</primary> + <secondary>Property Set Method</secondary> + </indexterm> + <code language="jam">rule refine ( ps )</code> + <para> + Refines properties by overriding any non-free and non-conditional + properties for which a different value is specified in + <literal>ps</literal>. Returns the resulting + <link linkend="bbv2.reference.class.property-set">property-set</link>. + </para> + </listitem> + + <listitem id="bbv2.reference.class.property-set.get"> + <indexterm zone="bbv2.reference.class.property-set.get"> + <primary>get</primary> + <secondary>Property Set Method</secondary> + </indexterm> + <code language="jam">rule get ( feature )</code> + <para> + Returns all the values of <literal>feature</literal>. + </para> + </listitem> + + </orderedlist> + +</section> diff --git a/boost/tools/build/doc/src/recipes.xml b/boost/tools/build/doc/src/recipes.xml new file mode 100644 index 00000000..ec65f28e --- /dev/null +++ b/boost/tools/build/doc/src/recipes.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE appendix PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + + <!-- The file is empty. It's not clear if it will be needed in + future or FAQ completely supercedes it. --> + + <appendix id="bbv2.recipies"> + <title>Boost.Build System V2 recipes</title> + + </appendix> diff --git a/boost/tools/build/doc/src/reference.xml b/boost/tools/build/doc/src/reference.xml new file mode 100644 index 00000000..7e4c4ec8 --- /dev/null +++ b/boost/tools/build/doc/src/reference.xml @@ -0,0 +1,2790 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE chapter PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd" +[ +<!ENTITY toolset_ops "<optional><replaceable>version</replaceable></optional> : <optional><replaceable>c++-compile-command</replaceable></optional> : <optional><replaceable>compiler options</replaceable></optional>"> +<!ENTITY option_list_intro "<para>The following options can be provided, using <literal><<replaceable>option-name</replaceable>><replaceable>option-value</replaceable></literal> syntax:</para>"> +<!ENTITY using_repeation "<para>This statement may be repeated several times, if you want to configure several versions of the compiler.</para>"> +]> + +<chapter id="bbv2.reference" + xmlns:xi="http://www.w3.org/2001/XInclude"> + <title>Reference</title> + + <section id="bbv2.reference.general"> + <title>General information</title> + + <section id="bbv2.reference.init"> + <title>Initialization</title> + + <para> + Immediately upon starting, the Boost.Build engine (<command>b2</command>) + loads the Jam code that implements the build system. To do this, it searches for a file + called <filename>boost-build.jam</filename>, 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:</para> + +<programlisting> +rule boost-build ( location ? ) +</programlisting> + + <para> + If location is a relative path, it is treated as relative to + the directory of <filename>boost-build.jam</filename>. The directory specified by + that location and the directories in BOOST_BUILD_PATH are then searched for + a file called <filename>bootstrap.jam</filename>, 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 + <filename>boost-build.jam</filename> at the project root containing: + +<programlisting> +boost-build build-system ; +</programlisting> + + In this case, running <command>b2</command> anywhere in the project tree will + automatically find the build system.</para> + + <para>The default <filename>bootstrap.jam</filename>, after loading some standard + definitions, loads both <filename>site-config.jam</filename> and <filename>user-config.jam</filename>.</para> + + </section> + + </section> + + <section id="bbv2.reference.rules"> + <title>Builtin rules</title> + + <para>This section contains the list of all rules that + can be used in Jamfile—both rules that define new + targets and auxiliary rules.</para> + + <variablelist> + <varlistentry> + <term><literal>exe</literal></term> + + <listitem><para>Creates an executable file. See + <xref linkend="bbv2.tasks.programs"/>.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>lib</literal></term> + + <listitem><para>Creates an library file. See + <xref linkend="bbv2.tasks.libraries"/>.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>install</literal></term> + + <listitem><para>Installs built targets and other files. See + <xref linkend="bbv2.tasks.installing"/>.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>alias</literal></term> + + <listitem><para>Creates an alias for other targets. See + <xref linkend="bbv2.tasks.alias"/>.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>unit-test</literal></term> + + <listitem><para>Creates an executable that will be automatically run. See + <xref linkend="bbv2.builtins.testing"/>.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>compile</literal></term> + <term><literal>compile-fail</literal></term> + <term><literal>link</literal></term> + <term><literal>link-fail</literal></term> + <term><literal>run</literal></term> + <term><literal>run-fail</literal></term> + + <listitem><para>Specialized rules for testing. See + <xref linkend="bbv2.builtins.testing"/>.</para></listitem> + </varlistentry> + + <varlistentry id="bbv2.reference.check-target-builds"> + <indexterm><primary>check-target-builds</primary></indexterm> + <term><literal>check-target-builds</literal></term> + + <listitem><para>The <literal>check-target-builds</literal> 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: + </para> + <programlisting> +rule check-target-builds ( target message ? : true-properties * : false-properties * ) + </programlisting> + + <para>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 available, one has use the following:</para> + <programlisting> +exe app : app.cpp : [ check-target-builds has_foo "System has foo" : <library>foo : <define>FOO_MISSING=1 ] ; + </programlisting> + + <para>For another example, the alias rule can be used to consolidate configuration + choices and make them available to other metatargets, like so:</para> + <programlisting> +alias foobar : : : : [ check-target-builds has_foo "System has foo" : <library>foo : <library>bar ] ; + </programlisting> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>obj</literal></term> + + <listitem><para>Creates an object file. Useful when a single source + file must be compiled with special properties.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>preprocessed</literal></term> + <indexterm><primary>preprocessed</primary></indexterm> + + <listitem><para>Creates an preprocessed source file. The arguments follow the + <link linkend="bbv2.main-target-rule-syntax">common syntax</link>.</para></listitem> + </varlistentry> + + <varlistentry id="bbv2.reference.rules.glob"> + <term><literal>glob</literal></term> + + <listitem><para>The <code>glob</code> rule takes a list shell pattern + and returns the list of files in the project's source directory that + match the pattern. For example: + <programlisting> +lib tools : [ glob *.cpp ] ; + </programlisting> + It is possible to also pass a second argument—the list of + exclude patterns. The result will then include the list of + files matching any of include patterns, and not matching any + of the exclude patterns. For example: + <programlisting> +lib tools : [ glob *.cpp : file_to_exclude.cpp bad*.cpp ] ; + </programlisting> + </para></listitem> + </varlistentry> + + <varlistentry id="bbv2.reference.glob-tree"> + <indexterm><primary>glob-tree</primary></indexterm> + <term><literal>glob-tree</literal></term> + + <listitem><para>The <code>glob-tree</code> is similar to the + <code>glob</code> except that it operates recursively from + the directory of the containing Jamfile. For example: + <programlisting> +ECHO [ glob-tree *.cpp : .svn ] ; + </programlisting> + will print the names of all C++ files in your project. The + <literal>.svn</literal> exclude pattern prevents the + <code>glob-tree</code> rule from entering administrative + directories of the Subversion version control system. + </para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>project</literal></term> + + <listitem><para>Declares project id and attributes, including + project requirements. See <xref linkend="bbv2.overview.projects"/>. + </para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>use-project</literal></term> + + <listitem><para>Assigns a symbolic project ID to a project at + a given path. This rule must be better documented! + </para></listitem> + </varlistentry> + + <varlistentry id="bbv2.reference.rules.explicit"> + <term><literal>explicit</literal></term> + + <listitem><para>The <literal>explicit</literal> 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.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>always</literal></term> + <indexterm><primary>always building a metatarget</primary></indexterm> + + <listitem><para>The <literal>always</literal> function 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: + </para> +<programlisting> +exe hello : hello.cpp ; +exe bye : bye.cpp ; +always hello ; +</programlisting> + <para>If a build of <filename>hello</filename> is requested, then the binary will + always be relinked. The object files will not be recompiled, though. Note that if + a build of <filename>hello</filename> is not requested, for example you specify just + <filename>bye</filename> on the command line, <filename>hello</filename> will not + be relinked.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>constant</literal></term> + + <listitem><para>Sets 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: + <programlisting> +constant VERSION : 1.34.0 ; + </programlisting> + </para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>path-constant</literal></term> + + <listitem><para>Same as <literal>constant</literal> except that + the value is treated as path relative to Jamfile location. For example, + if <command>b2</command> is invoked in the current directory, + and Jamfile in <filename>helper</filename> subdirectory has: + <programlisting> +path-constant DATA : data/a.txt ; + </programlisting> + then the variable <varname>DATA</varname> will be set to + <literal>helper/data/a.txt</literal>, and if <command>b2</command> + is invoked from the <filename>helper</filename> directory, then + the variable <varname>DATA</varname> will be set to + <literal>data/a.txt</literal>. + </para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>build-project</literal></term> + + <listitem><para>Cause 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. + </para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>test-suite</literal></term> + + <listitem><para>This rule is deprecated and equivalent to + <code>alias</code>.</para></listitem> + </varlistentry> + + </variablelist> + + </section> + + <section id="bbv2.overview.builtins.features"> + <title>Builtin features</title> + + <para>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.</para> + + <indexterm><primary>features</primary><secondary>builtin</secondary></indexterm> + + <variablelist> + <varlistentry><term><literal>variant</literal></term> + <indexterm><primary>variant</primary></indexterm> + + <listitem> + <para> + A feature combining several low-level features, making it easy to + request common build configurations. + </para> + + <para> + <emphasis role="bold">Allowed values:</emphasis> + <literal>debug</literal>, <literal>release</literal>, + <literal>profile</literal>. + </para> + + <para> + The value <literal>debug</literal> expands to + </para> + +<programlisting> +<optimization>off <debug-symbols>on <inlining>off <runtime-debugging>on +</programlisting> + + <para> + The value <literal>release</literal> expands to + </para> + +<programlisting> +<optimization>speed <debug-symbols>off <inlining>full <runtime-debugging>off +</programlisting> + + <para> + The value <literal>profile</literal> expands to the same as + <literal>release</literal>, plus: + </para> + +<programlisting> +<profiling>on <debug-symbols>on +</programlisting> + + <para> + Users can define their own build variants using the + <code>variant</code> rule from the <code>common</code> module. + </para> + + <para> + <emphasis role="bold">Note:</emphasis> Runtime debugging is on in + debug builds to suit the expectations of people used to various + IDEs. + <!-- Define "runtime debugging". Why will those people expect it to + be on in debug builds? --> + </para> + </listitem> + </varlistentry> + + <varlistentry id="bbv2.overview.builtins.features.link"> + <term><literal>link</literal></term> + <indexterm><primary>link</primary></indexterm> + + <listitem> + + <para><emphasis role="bold">Allowed values:</emphasis> <literal>shared</literal>, + <literal>static</literal></para> + + <simpara> + A feature controlling how libraries are built. + </simpara> + + </listitem> + </varlistentry> + + <varlistentry id="bbv2.overview.builtins.features.runtime-link"> + <indexterm><primary>runtime linking</primary></indexterm> + <term><literal>runtime-link</literal></term> + + <listitem> + <para><emphasis role="bold">Allowed values:</emphasis> <literal>shared</literal>, + <literal>static</literal></para> + + <simpara> + 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. + </simpara> + + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>threading</literal></term> + <indexterm><primary>threading</primary></indexterm> + + <listitem> + + <para><emphasis role="bold">Allowed values:</emphasis> <literal>single</literal>, + <literal>multi</literal></para> + + <simpara> + 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, <code>_MT</code> on Windows and <code>_REENTRANT</code> on Linux). + How those symbols affect the compiled code depends on the code itself. + </simpara> + + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>source</literal></term> + <indexterm><primary>source</primary></indexterm> + + <listitem> + <simpara> + The <code><source>X</code> 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 <xref linkend= + "bbv2.tutorial.conditions"/>). See also the <code><library> + </code> feature. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>library</literal></term> + <indexterm><primary>library</primary></indexterm> + + <listitem> + <simpara> + This feature is almost equivalent to the <code><source></code> + feature, except that it takes effect only for linking. When you want + to link all targets in a Jamfile to certain library, the + <code><library></code> feature is preferred over + <code><source>X</code>—the latter will add the library to + all targets, even those that have nothing to do with libraries. + </simpara> + </listitem> + </varlistentry> + + <varlistentry><term><anchor id="bbv2.builtin.features.dependency"/> + <literal>dependency</literal></term> + <indexterm><primary>dependency</primary></indexterm> + + <listitem> + <simpara> + Introduces a dependency on the target named by the value of this + feature (so it will be brought up-to-date whenever the target being + declared is). The dependency is not used in any other way. + + <!-- + ==================================================================== + An example and a motivation is needed here. Below is some commented + out content that used to be here but did not make any sense and + seems to have been left unfinished in some previous revision. Should + be fixed and this whole feature should be retested and fixed as + needed. + ==================================================================== + For example, in application with plugins, the plugins are not used + when linking the application, application might have a dependency on + its plugins, even though + + and + adds its usage requirements to the build properties + of the target being declared. + + The primary use case is when you want + the usage requirements (such as <code>#include</code> paths) of some + library to be applied, but do not want to link to it. + + It is hard to picture why anyone would want to do that. Please flesh + out this motivation. + ==================================================================== + --> + </simpara> + </listitem> + </varlistentry> + + <varlistentry><term><anchor id="bbv2.builtin.features.implicit-dependency"/> + <literal>implicit-dependency</literal></term> + <indexterm><primary>implicit-dependency</primary></indexterm> + + <listitem> + <simpara> + Indicates that the target named by the value of this feature + may produce files that are included by the sources of the + target being declared. See <xref linkend="bbv2.reference.generated_headers"/> + for more information. + </simpara> + </listitem> + </varlistentry> + + + <varlistentry><term><anchor id="bbv2.builtin.features.use"/> + <literal>use</literal></term> + <indexterm><primary>use</primary></indexterm> + + <listitem> + <simpara> + Introduces a dependency on the target named by the value of this + feature (so it will be brought up-to-date whenever the target being + declared is), and adds its usage requirements to the build + properties + <!-- Do you really mean "to the requirements?" --> + of the target being declared. The dependency is not used in any + other way. The primary use case is when you want the usage + requirements (such as <code>#include</code> paths) of some library + to be applied, but do not want to link to it. + <!-- It is hard to picture why anyone would want to do that. Please + flesh out this motivation. --> + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term><anchor id="bbv2.reference.features.dll-path"/> + <literal>dll-path</literal></term> + <indexterm><primary>dll-path</primary></indexterm> + + <listitem> + <simpara> + Specify an additional directory where the system should + look for shared libraries when the executable or shared + library is run. This feature only affects Unix + compilers. Please see <xref linkend="bbv2.faq.dll-path"/> + in <xref linkend="bbv2.faq"/> for details. + </simpara> + </listitem></varlistentry> + + <varlistentry> + <term><literal>hardcode-dll-paths</literal></term> + <indexterm><primary>hardcode-dll-paths</primary></indexterm> + + <listitem> + <simpara> + Controls automatic generation of dll-path properties. + </simpara> + + <para><emphasis role="bold">Allowed values:</emphasis> + <literal>true</literal>, <literal>false</literal>. This property is + specific to Unix systems. If an executable is built with + <code><hardcode-dll-paths>true</code>, 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 <!-- you need an antecedent. This _what_? --> is very + convenient during development. Please see the <link linkend= + "bbv2.faq.dll-path">FAQ entry</link> for details. Note that on Mac + OSX, the paths are unconditionally hardcoded by the linker, and it + is not possible to disable that behaviour.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>cflags</literal></term> + <term><literal>cxxflags</literal></term> + <term><literal>linkflags</literal></term> + + <listitem> + <simpara> + The value of those features is passed without modification to the + corresponding tools. For <code>cflags</code> that is both the C and + C++ compilers, for <code>cxxflags</code> that is the C++ compiler, + and for <code>linkflags</code> 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. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>include</literal></term> + <indexterm><primary>include</primary></indexterm> + + <listitem> + <simpara> + Specifies an additional include path that is to be passed to C and + C++ compilers. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>define</literal></term> + <indexterm><primary>define</primary></indexterm> + + <listitem> + <simpara> + Specifies an preprocessor symbol that should be defined on the command + line. You may either specify just the symbol, which will be defined + without any value, or both the symbol and the value, separated by + equal sign. + </simpara> + </listitem> + </varlistentry> + + + <varlistentry><term><literal>warnings</literal></term> + <listitem> + <simpara> + The <code><warnings></code> feature controls the warning level + of compilers. It has the following values: + <itemizedlist> + <listitem><para><code>off</code> - disables all warnings.</para></listitem> + <listitem><para><code>on</code> - enables default warning level for the tool.</para></listitem> + <listitem><para><code>all</code> - enables all warnings.</para></listitem> + </itemizedlist> + Default value is <code>all</code>. + </simpara> + </listitem> + </varlistentry> + + <varlistentry><term><literal>warnings-as-errors</literal></term> + <listitem> + <simpara> + The <code><warnings-as-errors></code> makes it possible to + treat warnings as errors and abort compilation on a warning. The + value <code>on</code> enables this behaviour. The default value is + <code>off</code>. + </simpara> + </listitem> + </varlistentry> + + <varlistentry><term><literal>build</literal></term> + + <listitem> + <para><emphasis role="bold">Allowed values:</emphasis> <literal>no</literal></para> + + <para> + The <code>build</code> feature is used to conditionally disable + build of a target. If <code><build>no</code> 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. + </para> + </listitem> + </varlistentry> + + <varlistentry><term><anchor id="bbv2.builtin.features.tag"/><literal>tag</literal></term> + + <listitem><para>The <literal>tag</literal> feature is used to customize + the name of the generated files. The value should have the form: +<programlisting>@<replaceable>rulename</replaceable></programlisting> where + <replaceable>rulename</replaceable> should be a name of a rule with the + following signature: +<programlisting>rule tag ( name : type ? : property-set )</programlisting> + 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. + </para> + + <para>Most typical use of the <literal>tag</literal> 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.</para> + </listitem> + </varlistentry> + + <varlistentry><term><literal>debug-symbols</literal></term> + + <listitem> + <para><emphasis role="bold">Allowed values:</emphasis> <literal>on</literal>, <literal>off</literal>.</para> + + <para>The <literal>debug-symbols</literal> feature specifies if + produced object files, executables, and libraries should include + debug information. + Typically, the value of this feature is implicitly set by the + <literal>variant</literal> feature, but it can be explicitly + specified by the user. The most common usage is to build + release variant with debugging information.</para> + </listitem> + </varlistentry> + + <varlistentry><term><literal>runtime-debugging</literal></term> + + <listitem> + <para><emphasis role="bold">Allowed values:</emphasis> <literal>on</literal>, <literal>off</literal>.</para> + + <para>The <literal>runtime-debugging</literal> feature specifies + whether 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 + <literal>variant</literal> feature, but it can be explicitly + specified by the user. The most common usage is to build + release variant with debugging output.</para> + </listitem> + </varlistentry> + + <varlistentry><term><literal>target-os</literal></term> + <listitem> + + <anchor id="bbv2.reference.features.target-os"/> + + <para> + The 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. + </para> + + <para>The complete list of possible values for this feature is: + aix, appletv, bsd, cygwin, darwin, freebsd, hpux, iphone, linux, netbsd, + openbsd, osf, qnx, qnxnto, sgi, solaris, unix, unixware, windows. + </para> + + <para>See <xref linkend="bbv2.tasks.crosscompile"/> for details of + crosscompilation</para> + + </listitem> + </varlistentry> + + + <varlistentry><term><literal>architecture</literal></term> + <listitem> + + <para> + <emphasis role="bold">Allowed values:</emphasis> + <literal>x86</literal>, + <literal>ia64</literal>, + <literal>sparc</literal>, + <literal>power</literal>, + <literal>mips1</literal>, + <literal>mips2</literal>, + <literal>mips3</literal>, + <literal>mips4</literal>, + <literal>mips32</literal>, + <literal>mips32r2</literal>, + <literal>mips64</literal>, + <literal>parisc</literal>, + <literal>arm</literal>, + <literal>combined</literal>, + <literal>combined-x86-power</literal>. + </para> + + <para>The <literal>architecture</literal> features specifies + the general processor family to generate code for.</para> + + </listitem> + </varlistentry> + + <varlistentry><term><literal>instruction-set</literal></term> + <indexterm><primary>instruction-set</primary></indexterm> + <listitem> + <para> + <emphasis role="bold">Allowed values:</emphasis> depend on the used + toolset. + </para> + + <para>The <literal>instruction-set</literal> 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.</para> + + <para>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 + <xref linkend="bbv2.reference.tools.compilers"/> for details. + </para> + + </listitem> + </varlistentry> + + <varlistentry><term><literal>address-model</literal></term> + <indexterm><primary>64-bit compilation</primary></indexterm> + <listitem> + <para><emphasis role="bold">Allowed values:</emphasis> <literal>32</literal>, <literal>64</literal>.</para> + + <para>The <literal>address-model</literal> 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 <literal>architecture</literal> + <literal>instruction-set</literal> + features. Please see <xref linkend="bbv2.reference.tools.compilers"/> + for details.</para> + </listitem> + </varlistentry> + + <varlistentry><term><literal>c++-template-depth</literal></term> + <listitem> + <para> + <emphasis role="bold">Allowed values:</emphasis> Any positive + integer. + </para> + + <para> + 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. + </para> + + <para> + <emphasis role="bold">Note:</emphasis> 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. + </para> + </listitem> + </varlistentry> + + <varlistentry><term><literal>embed-manifest</literal></term> + <listitem> + + <indexterm><primary>manifest file</primary><secondary>embedding</secondary></indexterm> + <indexterm><primary>embed-manifest</primary></indexterm> + + <para> + <emphasis role="bold">Allowed values:</emphasis> on, off. + </para> + + <para>This feature is specific to the msvc toolset (see + <xref linkend="bbv2.reference.tools.compiler.msvc"/>), + 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 <menuchoice><guimenu>Configuration Properties</guimenu> + <guisubmenu>Manifest Tool</guisubmenu> + <guisubmenu>Input and Output</guisubmenu> + <guimenuitem>Embed manifest</guimenuitem> </menuchoice>. + </para> + + </listitem> + </varlistentry> + + <varlistentry><term><literal>embed-manifest-file</literal></term> + <listitem> + + <indexterm><primary>manifest file</primary><secondary>embedding</secondary></indexterm> + <indexterm><primary>embed-manifest-file</primary></indexterm> + + <para>This feature is specific to the msvc toolset (see + <xref linkend="bbv2.reference.tools.compiler.msvc"/>), + 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 <menuchoice><guimenu>Configuration Properties</guimenu> + <guisubmenu>Manifest Tool</guisubmenu> + <guisubmenu>Input and Output</guisubmenu> + <guimenuitem>Additional Manifest Files</guimenuitem> </menuchoice>. + </para> + + </listitem> + </varlistentry> + + + </variablelist> + </section> + + <section id="bbv2.reference.tools"> + <title>Builtin tools</title> + + <para>Boost.Build comes with support for a large number of C++ compilers, + and other tools. This section documents how to use those tools.</para> + + <para>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 <code>using</code> rule, typically in your + <filename>user-config.jam</filename>, for example:</para> +<programlisting> +using gcc ; +</programlisting> + <para>additional parameters can be passed just like for other rules, for example:</para> +<programlisting> +using gcc : 4.0 : g++-4.0 ; +</programlisting> + + + + <para>The options that can be passed to each tool are documented in the + subsequent sections.</para> + + <section id="bbv2.reference.tools.compilers"> + + <title>C++ Compilers</title> + + <para>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 <code>toolset</code> feature that can be used to explicitly + request that compiler. </para> + + <section id="bbv2.reference.tools.compiler.gcc"> + + <title>GNU C++</title> + + <para>The <code>gcc</code> module supports the + <ulink url="http://gcc.gnu.org">GNU C++ compiler</ulink> + on Linux, a number of Unix-like system including SunOS and on Windows + (either <ulink url="http://www.cygwin.com">Cygwin</ulink> or + <ulink url="http://www.mingw.org">MinGW</ulink>). On Mac OSX, it is recommended + to use system gcc, see <xref linkend="bbv2.reference.tools.compiler.darwin"/>. + </para> + + <para>The <code>gcc</code> module is initialized using the following + syntax:</para> + <programlisting> +using gcc : &toolset_ops; ;</programlisting> + + &using_repeation; + + <!-- FIXME: mention everywhere what is the semantic + of version is --> + + <para> + If the version is not explicitly specified, it will be + automatically detected by running the compiler with the <code>-v</code> + option. If the command is not specified, the <command>g++</command> + binary will be searched in <envar>PATH</envar>.</para> + + &option_list_intro; + <variablelist> + + <xi:include href="fragments.xml" xpointer="xpointer(id('common_options')/*)" + parse="xml"/> + + <xi:include href="fragments.xml" xpointer="xpointer(id('root_option')/*)" + parse="xml"/> + + <varlistentry> + <term><literal>archiver</literal></term> + + <listitem> + <para>Specifies the archiver command that is used to produce static + libraries. Normally, it is autodetected using gcc + <command>-print-prog-name</command> option or defaulted to <command>ar</command>, + but in some cases you might want to override it, for example to explicitly + use a system version instead of one included with gcc.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>ranlib</literal></term> + + <listitem> + <para>Specifies the ranlib command that is used to generated symbol table + for static libraries. Normally, it is autodetected using gcc + <command>-print-prog-name</command> option or defaulted to <command>ranlib</command>, + but in some cases you might want to override it, for example to explicitly + use a system version instead of one included with gcc.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>rc</literal></term> + + <listitem> + <para>Specifies 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 <command>windres</command> will be used.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>rc-type</literal></term> + + <listitem> + <para>Specifies the type of resource compiler. The value can + be either <code>windres</code> for msvc resource compiler, + or <code>rc</code> for borland's resource compiler.</para> + </listitem> + </varlistentry> + + </variablelist> + + <indexterm><primary>64-bit compilation</primary> + <secondary>gcc</secondary></indexterm> + + In order to compile 64-bit applications, you have to specify + <code>address-model=64</code>, and the <code>instruction-set</code> + feature should refer to a 64 bit processor. Currently, those + include <literal>nocona</literal>, <literal>opteron</literal>, + <literal>athlon64</literal> and <literal>athlon-fx</literal>. + + </section> + + <section id="bbv2.reference.tools.compiler.darwin"> + + <title>Apple Darwin gcc</title> + + <para>The <code>darwin</code> module supports the version of gcc that is + modified and provided by Apple. The configuration is essentially identical + to that of the gcc module. + </para> + + <para> + <indexterm><primary>fat binaries</primary></indexterm> + 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 + <code>architecture=combined</code>. To build a binary that can run + both in 32-bit and 64-bit modes, specify + <code>address-model=32_64</code>. If you specify both of those + properties, a "4-way" fat binary will be generated. + </para> + + </section> + + <section id="bbv2.reference.tools.compiler.msvc"> + + <title>Microsoft Visual C++</title> + + <para>The <code>msvc</code> module supports the + <ulink url="http://msdn.microsoft.com/visualc/">Microsoft Visual + C++</ulink> command-line tools on Microsoft Windows. The supported + products and versions of command line tools are listed below:</para> + <itemizedlist> + <listitem><para>Visual Studio 2015—14.0</para></listitem> + <listitem><para>Visual Studio 2013—12.0</para></listitem> + <listitem><para>Visual Studio 2012—11.0</para></listitem> + <listitem><para>Visual Studio 2010—10.0</para></listitem> + <listitem><para>Visual Studio 2008—9.0</para></listitem> + <listitem><para>Visual Studio 2005—8.0</para></listitem> + <listitem><para>Visual Studio .NET 2003—7.1</para></listitem> + <listitem><para>Visual Studio .NET—7.0</para></listitem> + <listitem><para>Visual Studio 6.0, Service Pack 5—6.5</para></listitem> + </itemizedlist> + + <para>The <code>msvc</code> module is initialized using the following + syntax:</para> + <programlisting> +using msvc : &toolset_ops; ; + </programlisting> + &using_repeation; + <para>If the version is not explicitly specified, the most recent + version found in the registry will be used instead. If the special + value <code>all</code> 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 <envar>PATH</envar>. + </para> + + <para>The compiler command should be specified using forward slashes, + and quoted.</para> + + &option_list_intro; + <variablelist> + + <xi:include href="fragments.xml" xpointer="xpointer(id('common_options')/*)" + parse="xml"/> + + <varlistentry> + <term><literal>assembler</literal></term> + + <listitem><para>The command that compiles assembler sources. If + not specified, <command>ml</command> will be used. The command + will be invoked after the setup script was executed and adjusted + the <envar>PATH</envar> variable.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>compiler</literal></term> + + <listitem><para>The command that compiles C and C++ sources. If + not specified, <command>cl</command> will be used. The command + will be invoked after the setup script was executed and adjusted + the <envar>PATH</envar> variable.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>compiler-filter</literal></term> + + <listitem><para>Command through which to pipe the output of + running the compiler. For example to pass the output to STLfilt. + </para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>idl-compiler</literal></term> + + <listitem><para>The command that compiles Microsoft COM interface + definition files. If not specified, <command>midl</command> will + be used. The command will be invoked after the setup script was + executed and adjusted the <envar>PATH</envar> variable.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>linker</literal></term> + + <listitem><para>The command that links executables and dynamic + libraries. If not specified, <command>link</command> will be used. + The command will be invoked after the setup script was executed + and adjusted the <envar>PATH</envar> variable.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>mc-compiler</literal></term> + + <listitem><para>The command that compiles Microsoft message + catalog files. If not specified, <command>mc</command> will be + used. The command will be invoked after the setup script was + executed and adjusted the <envar>PATH</envar> variable.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>resource-compiler</literal></term> + + <listitem><para>The command that compiles resource files. If not + specified, <command>rc</command> will be used. The command will be + invoked after the setup script was executed and adjusted the + <envar>PATH</envar> variable.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>setup</literal></term> + + <listitem><para>The 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 + parameter. If not specified a default script is chosen based on the + used compiler binary, e.g. <command>vcvars32.bat</command> or + <command>vsvars32.bat</command>.</para></listitem> + </varlistentry> + + <varlistentry> + <term><literal>setup-amd64</literal></term> + <term><literal>setup-i386</literal></term> + <term><literal>setup-ia64</literal></term> + + <listitem><para>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.</para></listitem> + </varlistentry> + </variablelist> + + <section id="v2.reference.tools.compiler.msvc.64"> + <title>64-bit support</title> + + <indexterm><primary>64-bit compilation</primary> + <secondary>Microsoft Visual Studio</secondary></indexterm> + + <para>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):</para> + + <itemizedlist> + <listitem><para>32-bit x86 host, 32-bit x86 target</para> + </listitem> + <listitem><para>32-bit x86 host, 64-bit AMD64 target</para> + </listitem> + <listitem><para>32-bit x86 host, 64-bit IA64 target</para> + </listitem> + <listitem><para>64-bit AMD64 host, 64-bit AMD64 target</para> + </listitem> + <listitem><para>64-bit IA64 host, 64-bit IA64 target</para> + </listitem> + </itemizedlist> + <para> + 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. + </para> + + <para>To use 64-bit compilation you should:</para> + <orderedlist> + <listitem><para>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.</para></listitem> + + <listitem><para>When compiling, use <code>address-model=64</code>, + to generate AMD64 code.</para></listitem> + + <listitem><para>To generate IA64 code, use + <code>architecture=ia64</code></para></listitem> + </orderedlist> + + <para>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.</para> + + <para>It is believed that AMD64 and EM64T targets are essentially + compatible. The compiler options <code>/favor:AMD64</code> and + <code>/favor:EM64T</code>, 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 the<code>instruction-set</code> + feature.</para> + </section> + + <section id="v2.reference.tools.compiler.msvc.winrt"> + <title>Windows Runtime support</title> + + <indexterm><primary>Windows Runtime support</primary> + <secondary>Microsoft Visual Studio</secondary></indexterm> + + <para> + 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 <literal>windows-api</literal> feature. + Available options are <literal>desktop</literal>, + <literal>store</literal>, or <literal>phone</literal>. If not + specified, <literal>desktop</literal> will be used. + </para> + + <para> + When using <literal>store</literal> or <literal>phone</literal> + the specified toolset determines what Windows version is + targeted. The following options are available: + </para> + + <itemizedlist> + <listitem><para>Windows 8.0: toolset=msvc-11.0 windows-api=store</para> + </listitem> + <listitem><para>Windows 8.1: toolset=msvc-12.0 windows-api=store</para> + </listitem> + <listitem><para>Windows Phone 8.0: toolset=msvc-11.0 windows-api=phone</para> + </listitem> + <listitem><para>Windows Phone 8.1: toolset=msvc-12.0 windows-api=phone</para> + </listitem> + </itemizedlist> + + <para> + For example use the following to build for Windows Store 8.1 + with the ARM architecture: + </para> + <programlisting> +.\b2 toolset=msvc-12.0 windows-api=store architecture=arm</programlisting> + + <para> + 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 + <ulink url="http://blogs.msdn.com/b/vcblog/archive/2014/07/18/using-boost-libraries-in-windows-store-and-phone-applications.aspx">here</ulink>. + </para> + + </section> + </section> + + <section id="bbv2.reference.tools.compiler.intel"> + + <title>Intel C++</title> + + <para>The <code>intel-linux</code> and <code>intel-win</code> modules + support the Intel C++ command-line compiler—the <ulink url= + "http://www.intel.com/software/products/compilers/clin/index.htm">Linux</ulink> + and <ulink url= + "http://www.intel.com/cd/software/products/asmo-na/eng/compilers/284527.htm"> + Windows</ulink> versions respectively.</para> + + <para>The module is initialized using the following syntax:</para> + <programlisting> +using intel-linux : &toolset_ops; ;</programlisting> + <para>or</para> + <programlisting> +using intel-win : &toolset_ops; ;</programlisting> + <para>respectively.</para> + + &using_repeation; + + <para> + If compiler command is not specified, then Boost.Build will + look in <envar>PATH</envar> for an executable <command>icpc</command> + (on Linux), or <command>icc.exe</command> (on Windows). + </para> + + &option_list_intro; + <variablelist> + + <xi:include href="fragments.xml" xpointer="xpointer(id('common_options')/*)" + parse="xml"/> + + </variablelist> + + <para>The Linux version supports the following additional options:</para> + <variablelist> + + <xi:include href="fragments.xml" xpointer="xpointer(id('root_option')/*)" + parse="xml"/> + + </variablelist> + + <!-- the compatibility option appears to be messed up --> + + </section> + + <section id="bbv2.reference.tools.compiler.acc"> + + <title>HP aC++ compiler</title> + + <para>The <code>acc</code> module supports the +<ulink url="http://h21007.www2.hp.com/dspp/tech/tech_TechSoftwareDetailPage_IDX/1,1703,1740,00.html">HP aC++ compiler</ulink> + for the HP-UX operating system.</para> + + <para>The module is initialized using the following + syntax:</para> + <programlisting> +using acc : &toolset_ops; ;</programlisting> + + &using_repeation; + + + <para> + If the command is not specified, the <command>aCC</command> + binary will be searched in <envar>PATH</envar>.</para> + + &option_list_intro; + <variablelist> + <xi:include href="fragments.xml" xpointer="xpointer(id('common_options')/*)" + parse="xml"/> + </variablelist> + + </section> + + <section id="bbv2.reference.tools.compiler.borland"> + + <title>Borland C++ Compiler</title> + + <para>The <code>borland</code> module supports the command line + C++ compiler included in + <ulink url="http://www.borland.com/us/products/cbuilder/index.html">C++ Builder 2006</ulink> + product and earlier version of it, running on Microsoft Windows.</para> + + <para>The supported products are listed below. The version reported + by the command lines tools is also listed for reference.:</para> + <itemizedlist> + <listitem><para>C++ Builder 2006—5.8.2</para></listitem> + <listitem><para>CBuilderX—5.6.5, 5.6.4 (depending on release)</para></listitem> + <listitem><para>CBuilder6—5.6.4</para></listitem> + <listitem><para>Free command line tools—5.5.1</para></listitem> + </itemizedlist> + + <para>The module is initialized using the following syntax:</para> + <programlisting> +using borland : &toolset_ops; ;</programlisting> + + &using_repeation; + + <para>If the command is not specified, Boost.Build will search for + a binary named <command>bcc32</command> in <envar>PATH</envar>.</para> + + &option_list_intro; + <variablelist> + <xi:include href="fragments.xml" xpointer="xpointer(id('common_options')/*)" + parse="xml"/> + </variablelist> + + </section> + + <section id="bbv2.reference.tools.compiler.como"> + + <title>Comeau C/C++ Compiler</title> + + <para>The <code>como-linux</code> and the <code>como-win</code> + modules supports the + <ulink url="http://www.comeaucomputing.com/">Comeau C/C++ Compiler</ulink> + on Linux and Windows respectively.</para> + + <para>The module is initialized using the following syntax:</para> + <programlisting> +using como-linux : &toolset_ops; ;</programlisting> + + &using_repeation; + + <para>If the command is not specified, Boost.Build will search for + a binary named <command>como</command> in + <envar>PATH</envar>.</para> + + &option_list_intro; + <variablelist> + <xi:include href="fragments.xml" xpointer="xpointer(id('common_options')/*)" + parse="xml"/> + </variablelist> + + <para>Before using the Windows version of the compiler, you need to + setup necessary environment variables per compiler's documentation. In + particular, the <envar>COMO_XXX_INCLUDE</envar> variable should be + set, where <envar>XXX</envar> corresponds to the used backend C + compiler.</para> + </section> + + <section id="bbv2.reference.tools.compiler.cw"> + + <title>Code Warrior</title> + + <para>The <code>cw</code> 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 acquisition and are not sold any longer. The last version known + to work is 9.4.</para> + + <para>The module is initialized using the following syntax:</para> + <programlisting> +using cw : &toolset_ops; ;</programlisting> + + &using_repeation; + + <para>If the command is not specified, Boost.Build will search for a + binary named <command>mwcc</command> in default installation paths and + in <envar>PATH</envar>.</para> + + &option_list_intro; + <variablelist> + + <xi:include href="fragments.xml" xpointer="xpointer(id('common_options')/*)" + parse="xml"/> + + <xi:include href="fragments.xml" xpointer="xpointer(id('root_option')/*)" + parse="xml"/> + + <varlistentry> + <term><literal>setup</literal></term> + + <listitem><para>The command that sets up environment variables + prior to invoking the compiler. If not specified, + <command>cwenv.bat</command> alongside the compiler binary + will be used.</para> + </listitem> + </varlistentry> + + + <varlistentry> + <term><literal>compiler</literal></term> + + <listitem><para>The command that compiles C and C++ sources. + If not specified, <command>mwcc</command> will be used. The + command will be invoked after the setup script was + executed and adjusted the <envar>PATH</envar> variable.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>linker</literal></term> + + <listitem><para>The command that links executables and dynamic + libraries. + If not specified, <command>mwld</command> will be used. The + command will be invoked after the setup script was + executed and adjusted the <envar>PATH</envar> variable.</para> + </listitem> + </varlistentry> + + </variablelist> + + </section> + + <section id="bbv2.reference.tools.compiler.dmc"> + + <title>Digital Mars C/C++ Compiler</title> + + <para>The <code>dmc</code> module supports the + <ulink url="http://www.digitalmars.com/">Digital Mars C++ compiler.</ulink> + </para> + + <para>The module is initialized using the following syntax:</para> + <programlisting> +using dmc : &toolset_ops; ;</programlisting> + + &using_repeation; + + <para>If the command is not specified, Boost.Build will search for + a binary named <command>dmc</command> in + <envar>PATH</envar>.</para> + + &option_list_intro; + <variablelist> + <xi:include href="fragments.xml" xpointer="xpointer(id('common_options')/*)" + parse="xml"/> + </variablelist> + + </section> + + <section id="bbv2.reference.tools.compiler.hp_cxx"> + + <title>HP C++ Compiler for Tru64 Unix</title> + + <para>The <code>hp_cxx</code> modules supports the + <ulink url="http://h30097.www3.hp.com/cplus/?jumpid=reg_R1002_USEN"> + HP C++ Compiler</ulink> for Tru64 Unix.</para> + + <para>The module is initialized using the following syntax:</para> + <programlisting> +using hp_cxx : &toolset_ops; ;</programlisting> + + &using_repeation; + + <para>If the command is not specified, Boost.Build will search for + a binary named <command>hp_cxx</command> in <envar>PATH</envar>.</para> + + &option_list_intro; + <variablelist> + <xi:include href="fragments.xml" xpointer="xpointer(id('common_options')/*)" + parse="xml"/> + </variablelist> + + </section> + + <section id="bbv2.reference.tools.compiler.sun"> + + <title>Sun Studio</title> + + <para>The <code>sun</code> module supports the + <ulink url="http://developers.sun.com/sunstudio/index.jsp"> + Sun Studio</ulink> C++ compilers for the Solaris OS.</para> + + <para>The module is initialized using the following syntax:</para> + <programlisting> +using sun : &toolset_ops; ;</programlisting> + + &using_repeation; + + <para>If the command is not specified, Boost.Build will search for + a binary named <command>CC</command> + in <filename>/opt/SUNWspro/bin</filename> and in + <envar>PATH</envar>.</para> + + <para>When using this compiler on complex C++ code, such as the + <ulink url="http://boost.org">Boost C++ library</ulink>, it is + recommended to specify the following options when initializing the + <code>sun</code> module: + <screen> +-library=stlport4 -features=tmplife -features=tmplrefstatic + </screen> See the <ulink url="http://blogs.sun.com/sga/entry/command_line_options"> + Sun C++ Frontend Tales</ulink> for details.</para> + + &option_list_intro; + <variablelist> + <xi:include href="fragments.xml" xpointer="xpointer(id('common_options')/*)" + parse="xml"/> + </variablelist> + + <indexterm><primary>64-bit compilation</primary> + <secondary>Sun Studio</secondary></indexterm> + Starting with Sun Studio 12, you can create 64-bit applications + by using the <code>address-model=64</code> property. + + </section> + + <section id="bbv2.reference.tools.compiler.vacpp"> + + <title>IBM Visual Age</title> + <para>The <code>vacpp</code> module supports the + <ulink url="http://www.ibm.com/software/ad/vacpp">IBM Visual + Age</ulink> C++ Compiler, for the AIX operating system. Versions + 7.1 and 8.0 are known to work.</para> + + <para>The module is initialized using the following + syntax:</para> + <programlisting> +using vacpp ;</programlisting> + + <para>The module does not accept any initialization options. The + compiler should be installed in the <filename>/usr/vacpp/bin</filename> + directory.</para> + + <para>Later versions of Visual Age are known as XL C/C++. They + were not tested with the the <code>vacpp</code> module.</para> + + </section> + + </section> + + <section> + <title>Third-party libraries</title> + + <para>Boost.Build provides special support for some + third-party C++ libraries, documented below.</para> + + <section id="bbv2.reference.tools.libraries.stlport"> + <title>STLport library</title> + <indexterm><primary>STLport</primary></indexterm> + + <para>The <ulink url="http://stlport.org">STLport</ulink> library + is an alternative implementation of C++ runtime library. Boost.Build + supports using that library on Windows platform. Linux is + hampered by different naming of libraries in each STLport + version and is not officially supported.</para> + + <para>Before using STLport, you need to configure it in + <filename>user-config.jam</filename> using the following syntax: + </para> + <programlisting> +using stlport : <optional><replaceable>version</replaceable></optional> : <replaceable>header-path</replaceable> : <optional><replaceable>library-path</replaceable></optional> ; +</programlisting> + <para> + Where <replaceable>version</replaceable> is the version of + STLport, for example <literal>5.1.4</literal>, + <replaceable>headers</replaceable> is the location where + STLport headers can be found, and <replaceable>libraries</replaceable> + 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. + </para> + + <para>When STLport is configured, you can build with STLport by + requesting <literal>stdlib=stlport</literal> on the command line. + </para> + + </section> + + <section id="bbv2.reference.tools.libraries.zlib"> + <title>zlib</title> + <indexterm><primary>zlib</primary></indexterm> + + <para>Provides support for the + <ulink url="http://www.zlib.net">zlib</ulink> library. zlib + can be configured either to use precompiled binaries or to + build the library from source.</para> + + <para>zlib can be initialized using the following syntax</para> + <programlisting> +using zlib : <optional><replaceable>version</replaceable></optional> : <optional><replaceable>options</replaceable></optional> : <optional><replaceable>condition</replaceable></optional> : <optional><replaceable>is-default</replaceable></optional> ; + </programlisting> + <para>Options for using a prebuilt library:</para> + <variablelist> + <varlistentry> + <term><literal>search</literal></term> + <listitem> + <para>The directory containing the zlib binaries.</para> + </listitem> + </varlistentry> + <varlistentry> + <term><literal>name</literal></term> + <listitem> + <para>Overrides the default library name.</para> + </listitem> + </varlistentry> + <varlistentry> + <term><literal>include</literal></term> + <listitem> + <para>The directory containing the zlib headers.</para> + </listitem> + </varlistentry> + </variablelist> + <para>If none of these options is specified, then the environmental + variables ZLIB_LIBRARY_PATH, ZLIB_NAME, and ZLIB_INCLUDE will be + used instead.</para> + <para>Options for building zlib from source:</para> + <variablelist> + <varlistentry> + <term><literal>source</literal></term> + <listitem> + <para>The zlib source directory. Defaults to the + environmental variable ZLIB_SOURCE.</para> + </listitem> + </varlistentry> + <varlistentry> + <term><literal>tag</literal></term> + <listitem> + <para>Sets the <link linkend="bbv2.builtin.features.tag">tag</link> + property to adjust the file name of the library. Ignored + when using precompiled binaries.</para> + </listitem> + </varlistentry> + <varlistentry> + <term><literal>build-name</literal></term> + <listitem> + <para>The base name to use for the compiled library. + Ignored when using precompiled binaries.</para> + </listitem> + </varlistentry> + </variablelist> + <para>Examples:</para> + <programlisting> +# 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 ; +</programlisting> + </section> + + </section> + + <section> + <title>Documentation tools</title> + + <para>Boost.Build support for the Boost documentation tools is + documented below. + </para> + + <section id="bbv2.reference.tools.doc.xsltproc"> + <title>xsltproc</title> + <indexterm><primary>xsltproc</primary></indexterm> + + <para>To use xsltproc, you first need to configure it using the following syntax:</para> + <programlisting> +using xsltproc : <optional><replaceable>xsltproc</replaceable></optional> ; +</programlisting> + <para> + Where <replaceable>xsltproc</replaceable> is the xsltproc executable. + If <replaceable>xsltproc</replaceable> is not specified, and the + variable XSLTPROC is set, the value of XSLTPROC will be used. + Otherwise, xsltproc will be searched for in PATH. + </para> + + + &option_list_intro; + <variablelist> + + <varlistentry> + <indexterm><primary>xsl:param</primary></indexterm> + <term><literal>xsl:param</literal></term> + <listitem> + <para>Values should have the form + <replaceable>name</replaceable>=<replaceable>value</replaceable></para> + </listitem> + </varlistentry> + + <varlistentry> + <indexterm><primary>xsl:path</primary></indexterm> + <term><literal>xsl:path</literal></term> + <listitem> + <para>Sets an additional search path for xi:include elements.</para> + </listitem> + </varlistentry> + + <varlistentry> + <indexterm><primary>catalog</primary></indexterm> + <term><literal>catalog</literal></term> + <listitem> + <para>A catalog file used to rewrite remote URL's to a local copy.</para> + </listitem> + </varlistentry> + + </variablelist> + + <para>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. + </para> + <variablelist> + + <varlistentry> + <indexterm><primary>xslt</primary></indexterm> + <term><literal>xslt</literal></term> + <listitem> + <programlisting> +rule xslt ( target : source stylesheet : properties * ) +</programlisting> + <para>Runs xsltproc to create a single output file.</para> + </listitem> + </varlistentry> + + <varlistentry> + <indexterm><primary>xslt-dir</primary></indexterm> + <term><literal>xslt-dir</literal></term> + <listitem> + <programlisting> +rule xslt-dir ( target : source stylesheet : properties * : dirname ) +</programlisting> + <para>Runs xsltproc to create multiple outputs in a directory. + <literal>dirname</literal> is unused, but exists for + historical reasons. The output directory is determined from the + target. + </para> + </listitem> + </varlistentry> + + </variablelist> + + </section> + + <section id="bbv2.reference.tools.doc.boostbook"> + <title>boostbook</title> + <indexterm><primary>boostbook</primary><secondary>module</secondary></indexterm> + + <para>To use boostbook, you first need to configure it using the following syntax:</para> + <programlisting> +using boostbook : <optional><replaceable>docbook-xsl-dir</replaceable></optional> : <optional><replaceable>docbook-dtd-dir</replaceable></optional> : <optional><replaceable>boostbook-dir</replaceable></optional> ; +</programlisting> + <para> + <replaceable>docbook-xsl-dir</replaceable> 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. + </para> + + <para> + <replaceable>docbook-dtd-dir</replaceable> 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. + </para> + + <para> + <replaceable>boostbook-dir</replaceable> is the BoostBook directory + with the DTD and XSL subdirs. + </para> + + <para>The boostbook module depends on xsltproc. For pdf or ps output, + it also depends on fop. + </para> + + &option_list_intro; + <variablelist> + + <varlistentry> + <indexterm><primary>format</primary></indexterm> + <indexterm><primary>html</primary></indexterm> + <indexterm><primary>xhtml</primary></indexterm> + <indexterm><primary>htmlhelp</primary></indexterm> + <indexterm><primary>onehtml</primary></indexterm> + <indexterm><primary>man</primary></indexterm> + <indexterm><primary>pdf</primary></indexterm> + <indexterm><primary>ps</primary></indexterm> + <indexterm><primary>docbook</primary></indexterm> + <indexterm><primary>fo</primary></indexterm> + <indexterm><primary>tests</primary></indexterm> + <term><literal>format</literal></term> + <listitem> + <para> + <emphasis role="bold">Allowed values:</emphasis> + <literal>html</literal>, <literal>xhtml</literal>, + <literal>htmlhelp</literal>, <literal>onehtml</literal>, + <literal>man</literal>, <literal>pdf</literal>, + <literal>ps</literal>, <literal>docbook</literal>, + <literal>fo</literal>, <literal>tests</literal>. + </para> + + + <para>The <literal>format</literal> feature determines the type + of output produced by the boostbook rule.</para> + </listitem> + </varlistentry> + + </variablelist> + + <para>The boostbook module defines a rule for creating a target + following the common syntax.</para> + + <variablelist> + + <varlistentry> + <indexterm><primary>boostbook</primary><secondary>rule</secondary></indexterm> + <term><literal>boostbook</literal></term> + <listitem> + <programlisting> +rule boostbook ( target-name : sources * : requirements * : default-build * ) +</programlisting> + <para>Creates a boostbook target.</para> + </listitem> + </varlistentry> + + </variablelist> + + </section> + + <section id="bbv2.reference.tools.doc.doxygen"> + <title>doxygen</title> + <indexterm><primary>doxygen</primary></indexterm> + + <para>To use doxygen, you first need to configure it using the following syntax:</para> + <programlisting> +using doxygen : <optional><replaceable>name</replaceable></optional> ; +</programlisting> + <para> + <replaceable>name</replaceable> is the doxygen command. + If it is not specified, it will be found in the PATH. + </para> + + <para>The doxygen module depends on the boostbook module when + generating BoostBook XML. + </para> + + &option_list_intro; + <variablelist> + + <varlistentry> + <indexterm><primary>doxygen:param</primary></indexterm> + <term><literal>doxygen:param</literal></term> + <listitem> + <para>All the values of <literal>doxygen:param</literal> + are added to the doxyfile.</para> + </listitem> + </varlistentry> + + <varlistentry> + <indexterm><primary>prefix</primary></indexterm> + <term><literal>prefix</literal></term> + <listitem> + <para>Specifies the common prefix of all headers + when generating BoostBook XML. Everything before + this will be stripped off. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <indexterm><primary>reftitle</primary></indexterm> + <term><literal>reftitle</literal></term> + <listitem> + <para>Specifies the title of the library-reference section, + when generating BoostBook XML.</para> + </listitem> + </varlistentry> + + <varlistentry> + <indexterm><primary>doxygen:xml-imagedir</primary></indexterm> + <term><literal>doxygen:xml-imagedir</literal></term> + <listitem> + <para>When generating BoostBook XML, specifies the + directory in which to place the images generated + from LaTex formulae.</para> + <warning><para>The path is interpreted relative to the + current working directory, not relative to the Jamfile. + This is necessary to match the behavior of BoostBook. + </para></warning> + </listitem> + </varlistentry> + + </variablelist> + + <para>The doxygen module defines a rule for creating a target + following the common syntax.</para> + + <variablelist> + + <varlistentry> + <indexterm><primary>doxygen</primary><secondary>rule</secondary></indexterm> + <term><literal>doxygen</literal></term> + <listitem> + <programlisting> +rule doxygen ( target : sources * : requirements * : default-build * : usage-requirements * ) +</programlisting> + <para>Creates a doxygen target. If the target name + ends with .html, then this will generate an html + directory. Otherwise it will generate BoostBook XML. + </para> + </listitem> + </varlistentry> + + </variablelist> + + </section> + + <section id="bbv2.reference.tools.doc.quickbook"> + <title>quickbook</title> + <indexterm><primary>quickbook</primary></indexterm> + + <para>The quickbook module provides a generator to convert from + Quickbook to BoostBook XML.</para> + + <para>To use quickbook, you first need to configure it using the following syntax:</para> + <programlisting> +using quickbook : <optional><replaceable>command</replaceable></optional> ; +</programlisting> + <para> + <replaceable>command</replaceable> 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. + </para> + + </section> + + <section id="bbv2.reference.tools.doc.fop"> + <title>fop</title> + <indexterm><primary>fop</primary></indexterm> + + <para>The fop module provides generators to convert from + XSL formatting objects to Postscript and PDF.</para> + + <para>To use fop, you first need to configure it using the following syntax:</para> + <programlisting> +using fop : <optional><replaceable>fop-command</replaceable></optional> : <optional><replaceable>java-home</replaceable></optional> : <optional><replaceable>java</replaceable></optional> ; +</programlisting> + <para> + <replaceable>fop-command</replaceable> is the command to run fop. + If it is not specified, Boost.Build will search for it in PATH and + FOP_HOME. + </para> + <para> + Either <replaceable>java-home</replaceable> or + <replaceable>java</replaceable> + can be used to specify where to find java. + </para> + + </section> + + </section> + + </section> + + <section id="bbv2.reference.modules"> + <title>Builtin modules</title> + + <para> + 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. + </para> + + <section id="bbv2.reference.modules.modules"> + <title>modules</title> + <indexterm><primary>modules</primary></indexterm> + + <para> + The <code>modules</code> module defines basic functionality + for handling modules. + </para> + + <para> + 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> + <para> + 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. + </para> + </note> + </para> + + <para> + 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. + </para> + + <para> + Every module has two special variables. + <code>$(__file__)</code> contains the name of the file that + the module was loaded from and <code>$(__name__)</code> + contains the name of the module. + <note><para><code>$(__file__)</code> does not contain + the full path to the file. If you need this, use + <code>modules.binding</code>.</para></note> + </para> + + <orderedlist> + + <listitem id="bbv2.reference.modules.modules.binding"> + <indexterm zone="bbv2.reference.modules.modules.binding"><primary>binding</primary></indexterm> + <code language="jam">rule binding ( module-name )</code> + <para>Returns the filesystem binding of the given module.</para> + <para>For example, a module can get its own location with: + <programlisting language="jam">me = [ modules.binding $(__name__) ] ;</programlisting> + </para> + </listitem> + + <listitem id="bbv2.reference.modules.modules.poke"> + <indexterm zone="bbv2.reference.modules.modules.poke"><primary>poke</primary></indexterm> + <code language="jam">rule poke ( module-name ? : variables + : value * )</code> + <para>Sets the module-local value of a variable.</para> + <para>For example, to set a variable in the global module: + <programlisting language="jam">modules.poke : ZLIB_INCLUDE : /usr/local/include ;</programlisting> + </para> + </listitem> + + <listitem id="bbv2.reference.modules.modules.peek"> + <indexterm zone="bbv2.reference.modules.modules.peek"><primary>peek</primary></indexterm> + <code language="jam">rule peek ( module-name ? : variables + )</code> + <para>Returns the module-local value of a variable.</para> + <para> + For example, to read a variable from the global module: + <programlisting language="jam">local ZLIB_INCLUDE = [ modules.peek : ZLIB_INCLUDE ] ;</programlisting> + </para> + </listitem> + + <listitem id="bbv2.reference.modules.modules.call-in"> + <indexterm zone="bbv2.reference.modules.modules.call-in"><primary>call-in</primary></indexterm> + <code language="jam">rule call-in ( module-name ? : rule-name args * : * ) </code> + <para>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><para>rules called this way may accept at most + 8 parameters.</para></note></para> + <para>Example: +<programlisting language="jam"> +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 ; +} +</programlisting> + </para> + </listitem> + + <listitem id="bbv2.reference.modules.modules.load"> + <indexterm zone="bbv2.reference.modules.modules.load"><primary>load</primary></indexterm> + <code language="jam">rule load ( module-name : filename ? : search * )</code> + <para>Load the indicated module if it is not already loaded.</para> + <variablelist> + <varlistentry> + <term><literal>module-name</literal></term> + <listitem><para>Name of module to load.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <varlistentry> + <term><literal>filename</literal></term> + <listitem><para>(partial) path to file; Defaults to <code>$(module-name).jam</code></para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <varlistentry> + <term><literal>search</literal></term> + <listitem><para>Directories in which to search for filename. + Defaults to <code>$(BOOST_BUILD_PATH)</code>.</para></listitem> + </varlistentry> + </variablelist> + </listitem> + + <listitem id="bbv2.reference.modules.modules.import"> + <indexterm zone="bbv2.reference.modules.modules.import"><primary>import</primary></indexterm> + <code language="jam">rule import ( module-names + : rules-opt * : rename-opt * )</code> + <para>Load the indicated module and import rule names into the + current module. Any members of <code>rules-opt</code> will be + available without qualification in the caller's module. Any + members of <code>rename-opt</code> 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 <code>rules-opt = '*'</code>, + all rules from the indicated module are imported into the + caller's module. If <code>rename-opt</code> is supplied, it must have the + same number of elements as <code>rules-opt</code>.</para> + <note><para>The <literal>import</literal> rule is available + without qualification in all modules.</para></note> + <para>Examples: +<programlisting language="jam"> +import path ; +import path : * ; +import path : join ; +import path : native make : native-path make-path ; +</programlisting> + </para> + </listitem> + + <listitem id="bbv2.reference.modules.modules.clone-rules"> + <indexterm zone="bbv2.reference.modules.modules.clone-rules"><primary>clone-rules</primary></indexterm> + <code language="jam">rule clone-rules ( source-module target-module )</code> + <para>Define exported copies in <code>$(target-module)</code> + of all rules exported from <code>$(source-module)</code>. Also + make them available in the global module with qualification, + so that it is just as though the rules were defined originally + in <code>$(target-module)</code>.</para> + </listitem> + + </orderedlist> + + </section> + + <xi:include href="path.xml"/> + <xi:include href="regex.xml"/> + <xi:include href="sequence.xml"/> + <xi:include href="type.xml"/> + + </section> + + <section id="bbv2.reference.class"> + <title>Builtin classes</title> + <xi:include href="abstract-target.xml"/> + <xi:include href="project-target.xml"/> + <xi:include href="main-target.xml"/> + <xi:include href="basic-target.xml"/> + <xi:include href="typed-target.xml"/> + <xi:include href="property-set.xml"/> + </section> + + <section id="bbv2.reference.buildprocess"> + <title>Build process</title> + + <para>The general overview of the build process was given in the + <link linkend="bbv2.overview.build_process">user documentation</link>. + This section provides additional details, and some specific rules. + </para> + + <para>To recap, building a target with specific properties includes the + following steps: + <orderedlist> + + <listitem><para>applying default build,</para></listitem> + + <listitem><para>selecting the main target alternative to use, + </para></listitem> + + <listitem><para>determining "common" properties,</para></listitem> + + <listitem><para>building targets referred by the sources list and + dependency properties,</para></listitem> + + <listitem><para>adding the usage requirements produces when building + dependencies to the "common" properties,</para></listitem> + + <listitem><para>building the target using generators,</para></listitem> + + <listitem><para>computing the usage requirements to be returned.</para></listitem> + + </orderedlist> + </para> + + <section id="bbv2.reference.buildprocess.alternatives"> + <title>Alternative selection</title> + + <para>When there are several alternatives, one of them must be + selected. The process is as follows:</para> + + <orderedlist> + <listitem> + <simpara> + For each alternative <emphasis>condition</emphasis> is defined as + the set of base properties in requirements. [Note: it might be + better to specify the condition explicitly, as in conditional + requirements]. + </simpara> + </listitem> + + <listitem> + <simpara> + An alternative is viable only if all properties in condition + are present in build request. + </simpara> + </listitem> + + <listitem> + <simpara> + If there's one viable alternative, it's choosen. Otherwise, + an attempt is made to find one best alternative. An alternative + a is better than another alternative b, if the set of properties + in b's condition is a strict subset of the set of properties of + 'a's condition. If there's one viable alternative, which is + better than all others, it's selected. Otherwise, an error is + reported. + </simpara> + </listitem> + </orderedlist> + + </section> + + <section id="bbv2.reference.buildprocess.common"> + <title>Determining common properties</title> + + <para>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. + </para> + + <para>Since default build and alternatives are already handled, we have + only two inputs: build requests and requirements. Here are the rules + about common properties. + </para> + + <orderedlist> + <listitem><para>Non-free feature can have only one + value</para></listitem> + + <listitem><para>A non-conditional property in requirement in always + present in common properties.</para></listitem> + + <listitem><para>A property in build request is present in + common properties, unless (2) tells otherwise.</para></listitem> + + <listitem><para>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.</para></listitem> + + <listitem><para>If requirements include a conditional property, and + condition of this property is true in context of common + properties, then the conditional property should be in common + properties as well.</para></listitem> + + <listitem><para>If no value for a feature is given by other rules + here, it has default value in common properties.</para></listitem> + </orderedlist> + + <para>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: +<programlisting> +exe a : a.cpp + : <toolset>gcc:<variant>release + <variant>release:<define>FOO ; +</programlisting> + </para> + + </section> + + <section id="bbv2.reference.buildprocess.targetpath"> + <title>Target Paths</title> + <indexterm><primary>path</primary><secondary>for targets</secondary></indexterm> + + <para>Several factors determine the location of a concrete + file target. All files in a project are built under + the directory bin unless this is overridden 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: + <code><toolset>gcc <toolset-gcc:version>4.6.1 <variant>debug + <warnings>all <define>_DEBUG <include>/usr/local/include + <link>static</code>, + 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.</para> + + <para>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.</para> + + <para>There are two features that affect the build + directory. The <location> feature completely + overrides the default build directory. For example, + <programlisting>exe a : a.cpp : <location>. ;</programlisting> + builds all the files produced by <code>a</code> + in the directory of the Jamfile. This is generally + discouraged, as it precludes variant builds.</para> + + <para>The <location-prefix> feature adds a + prefix to the path, under the project's build + directory. For example, + <programlisting>exe a : a.cpp : <location-prefix>subdir ;</programlisting> + will create the files for <code>a</code> in bin/subdir/gcc-4.6.1/debug</para> + + </section> + + </section> + + + + <section id="bbv2.reference.definitions"> + + <title>Definitions</title> + + <section id="bbv2.reference.features"> + <title>Features and properties</title> + + <para>A <emphasis>feature</emphasis> is a normalized (toolset-independent) + aspect of a build configuration, such as whether inlining is + enabled. Feature names may not contain the '<literal>></literal>' + character.</para> + + <!-- + And what about dash? + --> + + <para>Each feature in a build configuration has one or more + associated <emphasis>value</emphasis>s. Feature values for non-free features + may not contain the '<literal><</literal>', '<literal>:</literal>', or + '<literal>=</literal>' characters. Feature values for free features may not + contain the '<literal><</literal>' character.</para> + + <para>A <emphasis>property</emphasis> is a (feature,value) pair, expressed as + <feature>value.</para> + + <para>A <emphasis>subfeature</emphasis> 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.</para> + + <para>A <emphasis>value-string</emphasis> for a feature <emphasis role="bold">F</emphasis> is a string of + the form + <literal>value-subvalue1-subvalue2</literal>...<literal>-subvalueN</literal>, where + <literal>value</literal> is a legal value for <emphasis role="bold">F</emphasis> and + <literal>subvalue1</literal>...<literal>subvalueN</literal> are legal values of some + of <emphasis role="bold">F</emphasis>'s subfeatures. For example, the properties + <literal><toolset>gcc <toolset-version>3.0.1</literal> can be + expressed more concisely using a value-string, as + <literal><toolset>gcc-3.0.1</literal>.</para> + + <para>A <emphasis>property set</emphasis> is a set of properties (i.e. a + collection without duplicates), for instance: + <literal><toolset>gcc <runtime-link>static</literal>.</para> + + <para>A <emphasis>property path</emphasis> 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 + <literal><toolset>gcc/<runtime-link>static</literal>.</para> + + <para>A <emphasis>build specification</emphasis> is a property set that fully + describes the set of features used to build a target.</para> + + <section id="bbv2.reference.features.validity"> + <title>Property Validity</title> + + <para> + For <link linkend= + "bbv2.reference.features.attributes.free">free</link> + 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 <code><gcc-target>mingw</code> + property is only valid in the presence of + <code><gcc-version>2.95.2</code>. + </para> + + </section> + <section id="bbv2.reference.features.attributes"> + <title>Feature Attributes</title> + + <para>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 <emphasis>incidental</emphasis> property, for example, is + one whose feature has the <emphasis>incidental</emphasis> + attribute.</para> + + <itemizedlist> + <listitem> + <para><emphasis>incidental</emphasis></para> + + <para>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.</para> + + <para>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 <xref linkend="bbv2.reference.buildprocess.targetpath"/>. + </para> + </listitem> + + <listitem> + <para> + <anchor id="bbv2.reference.features.attributes.propagated"/> + <emphasis>propagated</emphasis> + </para> + + <para>Features of this kind are + propagated to dependencies. That is, if a <link linkend= + "bbv2.overview.targets.main">main target</link> 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 executable is + requested, one usually wants it to be linked with optimized + libraries. Thus, the <literal><optimization></literal> feature is + propagated.</para> + </listitem> + + <listitem> + <para> + <anchor id="bbv2.reference.features.attributes.free"/> + <emphasis>free</emphasis> + </para> + + <para>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:</para> + +<programlisting> +<define>NDEBUG=1 <define>HAS_CONFIG_H=1 +</programlisting> + + </listitem> + + <listitem> + <para><emphasis>optional</emphasis></para> + + <para>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]</para> + </listitem> + + <listitem> + <para><emphasis>symmetric</emphasis></para> + + <para>Normally a feature only generates a subvariant directory + when its value differs from its default value, + leading to an asymmetric subvariant directory structure for + certain values of the feature. A symmetric feature + always generates a corresponding + subvariant directory.</para> + </listitem> + + <listitem> + <para><emphasis>path</emphasis></para> + + <para>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</para> + </listitem> + + <listitem> + <para><emphasis>implicit</emphasis></para> + + <para>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.</para> + </listitem> + + <listitem> + <para><emphasis>composite</emphasis></para> + + <para>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 + <emphasis>added</emphasis> 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.</para> + </listitem> + + <listitem> + <para><emphasis>dependency</emphasis></para> + + <para>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.</para> + + <para>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. <!-- Need to clarify this. --></para> + </listitem> + </itemizedlist> + + <para>Features that are neither free nor incidental are called + <emphasis>base</emphasis> features.</para> + + + </section> + <section id="bbv2.reference.features.declaration"> + <title>Feature Declaration</title> + + <para>The low-level feature declaration interface is the + <literal>feature</literal> rule from the + <literal>feature</literal> module: + +<programlisting> +rule feature ( name : allowed-values * : attributes * ) +</programlisting> + + A feature's allowed-values may be extended with the + <code>feature.extend</code> rule. + </para> + + </section> + </section> + + <section id="bbv2.reference.variants.proprefine"> + <title>Property refinement</title> + + <para>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 + <emphasis>property refinement</emphasis> and is performed by these rules</para> + + <orderedlist> + + <listitem> + <simpara> + Each property in the required set is added to the original + property set + </simpara> + </listitem> + + <listitem> + <simpara> + If the original property set includes property with a different + value of non free feature, that property is removed. + </simpara> + </listitem> + </orderedlist> + </section> + + <section id="bbv2.reference.variants.propcond"> + <title>Conditional properties</title> + + <para>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:</para> + + <programlisting> + property ( "," property ) * ":" property + </programlisting> + + <para> + For example, the problem above would be solved by: + +<programlisting> +exe hello : hello.cpp : <toolset>yfc:<cxxflags>-disable-pointless-warning ; +</programlisting> + </para> + + <para>The syntax also allows several properties in the condition, for + example: +<programlisting> +exe hello : hello.cpp : <os>NT,<toolset>gcc:<link>static ; +</programlisting> + </para> + + </section> + + <section id="bbv2.reference.ids"> + <title>Target identifiers and references</title> + + <para><emphasis>Target identifier</emphasis> is used to denote a + target. The syntax is:</para> + +<programlisting> +target-id -> (target-name | file-name | project-id | directory-name) + | (project-id | directory-name) "//" target-name +project-id -> path +target-name -> path +file-name -> path +directory-name -> path +</programlisting> + + <para> + This grammar allows some elements to be recognized as either + + <itemizedlist> + <listitem> + <simpara> + name of target declared in current Jamfile (note that target + names may include slash). + </simpara> + </listitem> + + <listitem> + <simpara> + a regular file, denoted by absolute name or name relative to + project's sources location. + </simpara> + </listitem> + + <listitem> + <simpara> + project id (at this point, all project ids start with slash). + </simpara> + </listitem> + + <listitem> + <simpara> + the directory of another project, denoted by absolute name + or name relative to the current project's location. + </simpara> + </listitem> + </itemizedlist> + + To determine the real meaning the possible interpretations + are checked in this order. For example, valid target ids might be: + +<screen> +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 +../boost_1_61_0 -- project in specific directory +</screen> + + </para> + + <para><emphasis role="bold">Rationale:</emphasis>Target is separated from project by special + separator (not just slash), because:</para> + + <itemizedlist> + <listitem> + <simpara> + It emphasis that projects and targets are different things. + </simpara> + </listitem> + + <listitem> + <simpara> + It allows to have main target names with slashes. + + <!-- The motivation for which is: + + So, to summarize: + + 1. The project that extract tarfile may extract all possible kinds + of targets, and it's reasonable to use them directly from other + project. + + 2. The rule for unpacking tar is implemented in terms of + "patch-file", for maintainability, and therefore, must use main + target name that contains slashes? + + 3. Using sub-Jamfile in "foo" to declare extracted file "foo/b" is + not an option, because you should not change existing tree + + That makes good rationale for why main target must contain names. + --> + </simpara> + </listitem> + </itemizedlist> + + <para id="bbv2.reference.targets.references"> + <emphasis>Target reference</emphasis> is used to + specify a source target, and may additionally specify desired + properties for that target. It has this syntax:</para> + +<programlisting> +target-reference -> target-id [ "/" requested-properties ] +requested-properties -> property-path +</programlisting> + + <para> + For example, + + <programlisting> + exe compiler : compiler.cpp libs/cmdline/<optimization>space ; + </programlisting> + + would cause the version of <literal>cmdline</literal> library, + optimized for space, to be linked in even if the + <literal>compiler</literal> executable is build with optimization for + speed. + </para> + </section> + + </section> + +</chapter> + +<!-- + Local Variables: + mode: nxml + sgml-indent-data: t + sgml-parent-document: ("userman.xml" "chapter") + sgml-set-face: t + End: +--> diff --git a/boost/tools/build/doc/src/regex.xml b/boost/tools/build/doc/src/regex.xml new file mode 100644 index 00000000..234c6eae --- /dev/null +++ b/boost/tools/build/doc/src/regex.xml @@ -0,0 +1,170 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<section id="bbv2.reference.modules.regex"> + + <title>regex</title> + <indexterm> + <primary>regex</primary> + <secondary>module</secondary> + </indexterm> + + <para> + Contains rules for string processing using regular expressions. + </para> + + <itemizedlist> + + <listitem><para> + <code language="jam">"x*"</code> matches the pattern + <code language="jam">"x"</code> zero or more times. + </para></listitem> + + <listitem><para> + <code language="jam">"x+"</code> matches <code language="jam">"x"</code> + one or more times. + </para></listitem> + + <listitem><para> + <code language="jam">"x?"</code> matches <code language="jam">"x"</code> + zero or one time. + </para></listitem> + + <listitem><para> + <code language="jam">"[abcd]"</code> matches any of the characters, + <code language="jam">"a"</code>, <code language="jam">"b"</code>, + <code language="jam">"c"</code>, and <code language="jam">"d"</code>. + A character range such as <code language="jam">"[a-z]"</code> matches + any character between <code language="jam">"a"</code> and + <code language="jam">"z"</code>. <code language="jam">"[^abc]"</code> + matches any character which is not <code language="jam">"a"</code>, + <code language="jam">"b"</code>, or <code language="jam">"c"</code>. + </para></listitem> + + <listitem><para> + <code language="jam">"x|y"</code> matches either pattern + <code language="jam">"x"</code> or pattern <code language="jam">"y"</code> + </para></listitem> + + <listitem><para> + <code language="jam">(x)</code> matches <code language="jam">"x"</code> + and captures it. + </para></listitem> + + <listitem><para> + <code language="jam">"^"</code> matches the beginning of the string. + </para></listitem> + + <listitem><para> + <code language="jam">"$"</code> matches the end of the string. + </para></listitem> + + <listitem><para> + "\<" matches the beginning of a word. + </para></listitem> + + <listitem><para> + "\>" matches the end of a word. + </para></listitem> + + </itemizedlist> + + <orderedlist> + + <listitem id="bbv2.reference.modules.regex.split"> + <indexterm zone="bbv2.reference.modules.regex.split"> + <primary>split</primary> + <secondary>regex</secondary> + </indexterm> + <code language="jam">rule split ( string separator )</code> + <para>Returns a list of the following substrings: + <orderedlist> + <listitem><para>from beginning till the first occurrence of + <code language="jam">separator</code> or till the end, + </para></listitem> + <listitem><para>between each occurrence of + <code language="jam">separator</code> and the next occurrence, + </para></listitem> + <listitem><para>from the last occurrence of + <code language="jam">separator</code> till the end. + </para></listitem> + </orderedlist> + If no separator is present, the result will contain only one element. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.regex.split-list"> + <indexterm zone="bbv2.reference.modules.regex.split-list"> + <primary>split-list</primary> + <secondary>regex</secondary> + </indexterm> + <code language="jam">rule split-list ( list * : separator )</code> + <para>Returns the concatenated results of applying + <link linkend="bbv2.reference.modules.regex.split">regex.split</link> + to every element of the list using the separator pattern.</para> + </listitem> + + <listitem id="bbv2.reference.modules.regex.match"> + <indexterm zone="bbv2.reference.modules.regex.match"> + <primary>match</primary> + <secondary>regex</secondary> + </indexterm> + <code language="jam">rule match ( pattern : string : indices * )</code> + <para>Match <code language="jam">string</code> against + <code language="jam">pattern</code>, and return the elements + indicated by <code language="jam">indices</code>. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.regex.transform"> + <indexterm zone="bbv2.reference.modules.regex.transform"> + <primary>transform</primary> + <secondary>regex</secondary> + </indexterm> + <code language="jam">rule transform ( list * : pattern : indices * )</code> + <para>Matches all elements of <code language="jam">list</code> against + the <code language="jam">pattern</code> and returns a list of elements + indicated by <code language="jam">indices</code> of all successful + matches. If <code language="jam">indices</code> is omitted returns a list + of first parenthesized groups of all successful matches.</para> + </listitem> + + <listitem id="bbv2.reference.modules.regex.escape"> + <indexterm zone="bbv2.reference.modules.regex.escape"> + <primary>escape</primary> + <secondary>regex</secondary> + </indexterm> + <code language="jam">rule escape ( string : symbols : escape-symbol )</code> + <para>Escapes all of the characters in <code language="jam">symbols</code> + using the escape symbol <code language="jam">escape-symbol</code> for + the given string, and returns the escaped string.</para> + </listitem> + + <listitem id="bbv2.reference.modules.regex.replace"> + <indexterm zone="bbv2.reference.modules.regex.replace"> + <primary>replace</primary> + <secondary>regex</secondary> + </indexterm> + <code language="jam">rule replace ( string match replacement )</code> + <para>Replaces occurrences of a match string in a given string and + returns the new string. The match string can be a regex expression.</para> + </listitem> + + <listitem id="bbv2.reference.modules.regex.replace-list"> + <indexterm zone="bbv2.reference.modules.regex.replace-list"> + <primary>replace-list</primary> + <secondary>regex</secondary> + </indexterm> + <code language="jam">rule replace-list ( list * : match : replacement )</code> + <para>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. + </para> + </listitem> + + </orderedlist> + + <para>See also: <link linkend="jam.language.rules.builtins.utility._match__">MATCH</link></para> + +</section> diff --git a/boost/tools/build/doc/src/sequence.xml b/boost/tools/build/doc/src/sequence.xml new file mode 100644 index 00000000..54b2fbdb --- /dev/null +++ b/boost/tools/build/doc/src/sequence.xml @@ -0,0 +1,135 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<section id="bbv2.reference.modules.sequence"> + + <title>sequence</title> + <indexterm> + <primary>sequence</primary> + <secondary>module</secondary> + </indexterm> + + <para> + 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. + </para> + + <orderedlist> + + <listitem id="bbv2.reference.modules.sequence.filter"> + <indexterm zone="bbv2.reference.modules.sequence.filter"> + <primary>filter</primary> + <secondary>sequence</secondary> + </indexterm> + <code language="jam">rule filter ( predicate + : sequence * )</code> + <para>Return the elements <code language="jam">e</code> of + <code language="jam">$(sequence)</code> for which + <code language="jam">[ $(predicate) e ]</code> has a non-null value. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.sequence.transform"> + <indexterm zone="bbv2.reference.modules.sequence.transform"> + <primary>transform</primary> + <secondary>sequence</secondary> + </indexterm> + <code language="jam">rule transform ( function + : sequence * )</code> + <para>Return a new sequence consisting of + <code language="jam">[ $(function) $(e) ]</code> for each element + <code language="jam">e</code> of <code language="jam">$(sequence)</code>. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.sequence.reverse"> + <indexterm zone="bbv2.reference.modules.sequence.reverse"> + <primary>reverse</primary> + <secondary>sequence</secondary> + </indexterm> + <code language="jam">rule reverse ( s * )</code> + <para>Returns the elements of <code language="jam">s</code> in + reverse order.</para> + </listitem> + + <listitem id="bbv2.reference.modules.sequence.insertion-sort"> + <indexterm zone="bbv2.reference.modules.sequence.insertion-sort"> + <primary>insertion-sort</primary> + <secondary>sequence</secondary> + </indexterm> + <code language="jam">rule insertion-sort ( s * : ordered * )</code> + <para>Insertion-sort <code language="jam">s</code> using the + BinaryPredicate <code language="jam">ordered</code>.</para> + </listitem> + + <listitem id="bbv2.reference.modules.sequence.merge"> + <indexterm zone="bbv2.reference.modules.sequence.merge"> + <primary>merge</primary> + <secondary>sequence</secondary> + </indexterm> + <code language="jam">rule merge ( s1 * : s2 * : ordered * )</code> + <para>Merge two ordered sequences using the BinaryPredicate + <code language="jam">ordered</code>.</para> + </listitem> + + <listitem id="bbv2.reference.modules.sequence.join"> + <indexterm zone="bbv2.reference.modules.sequence.join"> + <primary>join</primary> + <secondary>sequence</secondary> + </indexterm> + <code language="jam">rule join ( s * : joint ? )</code> + <para>Join the elements of <code language="jam">s</code> into one + long string. If <code language="jam">joint</code> is supplied, it + is used as a separator.</para> + </listitem> + + <listitem id="bbv2.reference.modules.sequence.length"> + <indexterm zone="bbv2.reference.modules.sequence.length"> + <primary>length</primary> + <secondary>sequence</secondary> + </indexterm> + <code language="jam">rule length ( s * )</code> + <para>Find the length of any sequence.</para> + </listitem> + + <listitem id="bbv2.reference.modules.sequence.unique"> + <indexterm zone="bbv2.reference.modules.sequence.unique"> + <primary>unique</primary> + <secondary>sequence</secondary> + </indexterm> + <code language="jam">rule unique ( list * : stable ? )</code> + <para>Removes duplicates from <code language="jam">list</code>. + If <code language="jam">stable</code> is passed, then the order + of the elements will be unchanged.</para> + </listitem> + + <listitem id="bbv2.reference.modules.sequence.max-element"> + <indexterm zone="bbv2.reference.modules.sequence.max-element"> + <primary>max-element</primary> + <secondary>sequence</secondary> + </indexterm> + <code language="jam">rule max-element ( elements + : ordered ? )</code> + <para>Returns the maximum number in <code language="jam">elements</code>. + Uses <code language="jam">ordered</code> for comparisons or + <link linkend="bbv2.reference.modules.numbers.less">numbers.less</link> + if none is provided.</para> + </listitem> + + <listitem id="bbv2.reference.modules.sequence.select-highest-ranked"> + <indexterm zone="bbv2.reference.modules.sequence.select-highest-ranked"> + <primary>select-highest-ranked</primary> + <secondary>sequence</secondary> + </indexterm> + <code language="jam">rule select-highest-ranked ( elements * : ranks * )</code> + <para>Returns all of <code language="jam">elements</code> for which + the corresponding element in the parallel list + <code language="jam">rank</code> is equal to the maximum value in + <code language="jam">rank</code>.</para> + </listitem> + + </orderedlist> + +</section> diff --git a/boost/tools/build/doc/src/standalone.xml b/boost/tools/build/doc/src/standalone.xml new file mode 100644 index 00000000..d6f85617 --- /dev/null +++ b/boost/tools/build/doc/src/standalone.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE book PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<book xmlns:xi="http://www.w3.org/2001/XInclude" + id="bbv2" last-revision="$Date$"> + + <title>Boost.Build User Manual</title> + + <!-- Chapters --> + <xi:include href="howto.xml"/> + <xi:include href="install.xml"/> + <xi:include href="tutorial.xml"/> + <xi:include href="overview.xml"/> + <xi:include href="tasks.xml"/> + <xi:include href="reference.xml"/> + <xi:include href="extending.xml"/> + <xi:include href="faq.xml"/> + + <!-- Appendicies --> +<!-- <xi:include href="architecture.xml"/> --> + <appendix id="bbv2.jam"> + <title>Boost.Jam Documentation</title> + <xi:include href="jam_docs.xml" parse="xml" + xpointer="xpointer(id('jam.building')|id('jam.building')/following-sibling::*)"/> + </appendix> + + <index/> + +</book> diff --git a/boost/tools/build/doc/src/tasks.xml b/boost/tools/build/doc/src/tasks.xml new file mode 100644 index 00000000..48f611a2 --- /dev/null +++ b/boost/tools/build/doc/src/tasks.xml @@ -0,0 +1,842 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE chapter PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<!-- Copyright 2006 Vladimir Prus --> +<!-- Distributed under the Boost Software License, Version 1.0. --> +<!-- (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) --> + +<chapter id="bbv2.tasks"> + <title>Common tasks</title> + + <para> + This section describes main targets types that Boost.Build supports + out-of-the-box. Unless otherwise noted, all mentioned main target rules have + the common signature, described in <xref linkend="bbv2.overview.targets"/>. + </para> + + <section id="bbv2.tasks.programs"> + <title>Programs</title> + + <indexterm><primary>exe</primary></indexterm> + <para> + Programs are created using the <code>exe</code> rule, which follows the + <link linkend="bbv2.main-target-rule-syntax">common syntax</link>. For + example: +<programlisting> +exe hello : hello.cpp some_library.lib /some_project//library + : <threading>multi + ; +</programlisting> + This will create an executable file from the sources—in this case, one + C++ file, one library file present in the same directory, and another + library that is created by Boost.Build. Generally, sources can include C + and C++ files, object files and libraries. Boost.Build will automatically + try to convert targets of other types. + </para> + + <tip> + <para> + On Windows, if an application uses shared libraries, and both the + application and the libraries are built using Boost.Build, it is not + possible to immediately run the application, because the <literal>PATH + </literal> environment variable should include the path to the + libraries. It means you have to either add the paths manually, or have + the build place the application and the libraries into the same + directory. See <xref linkend="bbv2.tasks.installing"/>. + </para> + <!-- We should be emphasizing the use of the built-in testing rules + rather than continually discussing these quirks of running programs + with shared libraries. --> + </tip> + </section> + + <section id="bbv2.tasks.libraries"> + <title>Libraries</title> + + <indexterm> + <primary>library</primary> + <secondary>target</secondary> + </indexterm> + + <para> + Library targets are created using the <code>lib</code> rule, which + follows the <link linkend="bbv2.main-target-rule-syntax">common syntax + </link>. For example: +<programlisting> +lib helpers : helpers.cpp ; +</programlisting> + This will define a library target named <code>helpers</code> built from + the <code>helpers.cpp</code> source file. + It can be either a static library or a shared library, + depending on the value of the <link linkend="bbv2.overview.builtins.features.link"><link></link> feature. + </para> + <para> + Library targets can represent: + <itemizedlist> + <listitem> + <para> + Libraries that should be built from source, + as in the example above. + </para> + </listitem> + <listitem> + <para> + Prebuilt libraries which already exist on the system. + Such libraries can be searched for by the tools using them (typically + with the linker's <option>-l</option> option) or their paths can be + known in advance by the build system. + </para> + </listitem> + </itemizedlist> + </para> + + <para> + The syntax for prebuilt libraries is given below: +<programlisting> +lib z : : <name>z <search>/home/ghost ; +lib compress : : <file>/opt/libs/compress.a ; +</programlisting> + The <code>name</code> property specifies the name of the library + without the standard prefixes and suffixes. For example, depending + on the system, <code>z</code> could refer to a file called + z.so, libz.a, or z.lib, etc. The <code>search</code> feature + specifies paths in which to search for the library in addition + to the default compiler paths. <code>search</code> can be specified + several times or it can be omitted, in which case only the default + compiler paths will be searched. The <code>file</code> property + specifies the file location. + </para> + + <para> + The difference between using the <code>file</code> feature and + using a combination of the <code>name</code> and <code>search</code> + features is that <code>file</code> is more precise. + + <warning> + <para> + The value of the <code>search</code> feature is just added to the + linker search path. When linking to multiple libraries, + the paths specified by <code>search</code> are combined without + regard to which <code>lib</code> target each path came from. + Thus, given +<programlisting> +lib a : : <name>a <search>/pool/release ; +lib b : : <name>b <search>/pool/debug ; +</programlisting> + If /pool/release/a.so, /pool/release/b.so, /pool/debug/a.so, + and /pool/release/b.so all exist, the linker will probably + take both <code>a</code> and <code>b</code> from the same + directory, instead of finding <code>a</code> in /pool/release + and <code>b</code> in /pool/debug. If you need to distinguish + between multiple libraries with the same name, it's safer + to use <code>file</code>. + </para> + </warning> + </para> + + <para> + For convenience, the following syntax is allowed: +<programlisting> +lib z ; +lib gui db aux ; +</programlisting> + which has exactly the same effect as: +<programlisting> +lib z : : <name>z ; +lib gui : : <name>gui ; +lib db : : <name>db ; +lib aux : : <name>aux ; +</programlisting> + </para> + + <para> + When a library references another library you should put that other + library in its list of sources. This will do the right thing in all cases. + <!--Add a link to the notes below. --> For portability, you should specify + library dependencies even for searched and prebuilt libraries, othewise, + static linking on Unix will not work. For example: +<programlisting> +lib z ; +lib png : z : <name>png ; +</programlisting> + </para> + + <note> + <para> + When a library has a shared library as a source, or a static + library has another static library as a source then any target + linking to the first library with automatically link to its source + library as well. + </para> + <para> + On the other hand, when a shared library has a static library as + a source then the first library will be built so that it completely + includes the second one. + </para> + <para> + If you do not want a shared library to include all the libraries specified + in its sources (especially statically linked ones), you would need to + use the following: +<programlisting> +lib b : a.cpp ; +lib a : a.cpp : <use>b : : <library>b ; +</programlisting> + This specifies that library <code>a</code> uses library <code>b</code>, + and causes all executables that link to <code>a</code> to link to + <code>b</code> also. In this case, even for shared linking, the + <code>a</code> library will not refer to <code>b</code>. + </para> + </note> + + <para> + <!-- FIXME: After adding a full subsection on usage requirements, link to it --> + <link linkend="bbv2.overview.targets">Usage requirements</link> are often + very useful for defining library targets. For example, imagine that + you want you build a <code>helpers</code> library and its interface is + described in its <code>helpers.hpp</code> header file located in the same + directory as the <code>helpers.cpp</code> source file. Then you could add + the following to the Jamfile located in that same directory: +<programlisting> +lib helpers : helpers.cpp : : : <include>. ; +</programlisting> + which would automatically add the directory where the target has been + defined (and where the library's header file is located) to the compiler's + include path for all targets using the <code>helpers</code> library. This + feature greatly simplifies Jamfiles. + </para> + </section> + + <section id="bbv2.tasks.alias"> + <title>Alias</title> + + <para> + The <code language="jam">alias</code> rule gives an alternative name to a + group of targets. For example, to give the name <filename>core</filename> + to a group of three other targets with the following code: +<programlisting> +alias core : im reader writer ; +</programlisting> + Using <filename>core</filename> on the command line, or in the source list + of any other target is the same as explicitly using <filename>im + </filename>, <filename>reader</filename>, and <filename>writer</filename>. + </para> + + <para> + Another use of the <code>alias</code> rule is to change build properties. + For example, if you want to use link statically to the Boost Threads + library, you can write the following: +<programlisting> +alias threads : /boost/thread//boost_thread : <link>static ; +</programlisting> + and use only the <code>threads</code> alias in your Jamfiles. + </para> + + <para> + You can also specify usage requirements for the <code>alias</code> target. + If you write the following: +<programlisting> +alias header_only_library : : : : <include>/usr/include/header_only_library ; +</programlisting> + then using <code>header_only_library</code> in sources will only add an + include path. Also note that when an alias has sources, their usage + requirements are propagated as well. For example: +<programlisting> +lib library1 : library1.cpp : : : <include>/library/include1 ; +lib library2 : library2.cpp : : : <include>/library/include2 ; +alias static_libraries : library1 library2 : <link>static ; +exe main : main.cpp static_libraries ; +</programlisting> + will compile <filename>main.cpp</filename> with additional includes + required for using the specified static libraries. + </para> + </section> + + <section id="bbv2.tasks.installing"> + <title>Installing</title> + + <para> + This section describes various ways to install built target and arbitrary + files. + </para> + + <bridgehead>Basic install</bridgehead> + + <para> + For installing a built target you should use the <code>install</code> + rule, which follows the <link linkend="bbv2.main-target-rule-syntax"> + common syntax</link>. For example: +<programlisting> +install dist : hello helpers ; +</programlisting> + will cause the targets <code>hello</code> and <code>helpers</code> to be + moved to the <filename>dist</filename> directory, relative to the + Jamfile's directory. The directory can be changed using the + <code>location</code> property: +<programlisting> +install dist : hello helpers : <location>/usr/bin ; +</programlisting> + While you can achieve the same effect by changing the target name to + <filename>/usr/bin</filename>, using the <code>location</code> property is + better as it allows you to use a mnemonic target name. + </para> + + <para> + The <code>location</code> property is especially handy when the location + is not fixed, but depends on the build variant or environment variables: +<programlisting> +install dist : hello helpers : + <variant>release:<location>dist/release + <variant>debug:<location>dist/debug ; +install dist2 : hello helpers : <location>$(DIST) ; +</programlisting> + See also <link linkend="bbv2.reference.variants.propcond">conditional + properties</link> and <link linkend="bbv2.faq.envar">environment + variables</link> + </para> + + <bridgehead>Installing with all dependencies</bridgehead> + + <para> + Specifying the names of all libraries to install can be boring. The + <code>install</code> allows you to specify only the top-level executable + targets to install, and automatically install all dependencies: +<programlisting> +install dist : hello + : <install-dependencies>on <install-type>EXE + <install-type>LIB + ; +</programlisting> + will find all targets that <code>hello</code> depends on, and install all + of those which are either executables or libraries. More specifically, for + each target, other targets that were specified as sources or as dependency + properties, will be recursively found. One exception is that targets + referred with the <link linkend="bbv2.builtin.features.use"> + <code>use</code></link> feature are not considered, as that feature is + typically used to refer to header-only libraries. If the set of target + types is specified, only targets of that type will be installed, + otherwise, all found target will be installed. + </para> + + <bridgehead>Preserving Directory Hierarchy</bridgehead> + + <indexterm><primary>install-source-root</primary></indexterm> + + <para> + By default, the <code>install</code> rule will strip paths from its + sources. So, if sources include <filename>a/b/c.hpp</filename>, the + <filename>a/b</filename> part will be ignored. To make the + <code>install</code> rule preserve the directory hierarchy you need to + use the <literal><install-source-root></literal> feature to specify + the root of the hierarchy you are installing. Relative paths from that + root will be preserved. For example, if you write: +<programlisting> +install headers + : a/b/c.h + : <location>/tmp <install-source-root>a + ; +</programlisting> + the a file named <filename>/tmp/b/c.h</filename> will be created. + </para> + + <para> + The <link linkend="bbv2.reference.glob-tree">glob-tree</link> rule can be + used to find all files below a given directory, making it easy to install + an entire directory tree. + </para> + + <bridgehead>Installing into Several Directories</bridgehead> + + <para> + The <link linkend="bbv2.tasks.alias"><code>alias</code></link> rule can be + used when targets need to be installed into several directories: +<programlisting> +alias install : install-bin install-lib ; +install install-bin : applications : /usr/bin ; +install install-lib : helper : /usr/lib ; +</programlisting> + </para> + + <para> + Because the <code>install</code> rule just copies targets, most free + features <footnote><para>see the definition of "free" in <xref + linkend="bbv2.reference.features.attributes"/>.</para></footnote> have no + effect when used in requirements of the <code>install</code> rule. The + only two that matter are <link linkend="bbv2.builtin.features.dependency"> + <varname>dependency</varname></link> and, on Unix, <link + linkend="bbv2.reference.features.dll-path"><varname>dll-path</varname> + </link>. + </para> + + <note> + <para> + (Unix specific) On Unix, executables built using Boost.Build typically + contain the list of paths to all used shared libraries. For installing, + this is not desired, so Boost.Build relinks the executable with an empty + list of paths. You can also specify additional paths for installed + executables using the <varname>dll-path</varname> feature. + </para> + </note> + </section> + + <section id="bbv2.builtins.testing"> + <title>Testing</title> + + <para> + Boost.Build has convenient support for running unit tests. The simplest + way is the <code>unit-test</code> rule, which follows the <link + linkend="bbv2.main-target-rule-syntax">common syntax</link>. For example: +<programlisting> +unit-test helpers_test : helpers_test.cpp helpers ; +</programlisting> + </para> + + <para> + The <code language="jam">unit-test</code> rule behaves like the + <link linkend="bbv2.tasks.programs">exe</link> rule, but after the executable is created + it is also run. If the executable returns an error code, the build system + will also return an error and will try running the executable on the next + invocation until it runs successfully. This behaviour ensures that you can + not miss a unit test failure. + </para> + + + <para> + There are few specialized testing rules, listed below: +<programlisting> +rule compile ( sources : requirements * : target-name ? ) +rule compile-fail ( sources : requirements * : target-name ? ) +rule link ( sources + : requirements * : target-name ? ) +rule link-fail ( sources + : requirements * : target-name ? ) +</programlisting> + They are given a list of sources and requirements. If the target name is + not provided, the name of the first source file is used instead. The + <literal>compile*</literal> tests try to compile the passed source. The + <literal>link*</literal> rules try to compile and link an application from + all the passed sources. The <literal>compile</literal> and <literal>link + </literal> rules expect that compilation/linking succeeds. The <literal> + compile-fail</literal> and <literal>link-fail</literal> rules expect that + the compilation/linking fails. + </para> + + <para> + There are two specialized rules for running applications, which are more + powerful than the <code>unit-test</code> rule. The <code>run</code> rule + has the following signature: +<programlisting> +rule run ( sources + : args * : input-files * : requirements * : target-name ? + : default-build * ) +</programlisting> + The rule builds application from the provided sources and runs it, passing + <varname>args</varname> and <varname>input-files</varname> as command-line + arguments. The <varname>args</varname> parameter is passed verbatim and + the values of the <varname>input-files</varname> parameter are treated as + paths relative to containing Jamfile, and are adjusted if <command>b2</command> + is invoked from a different directory. The + <code>run-fail</code> rule is identical to the <code>run</code> rule, + except that it expects that the run fails. + </para> + + <para> + All rules described in this section, if executed successfully, create a + special manifest file to indicate that the test passed. For the + <code>unit-test</code> rule the files is named <filename><replaceable> + target-name</replaceable>.passed</filename> and for the other rules it is + called <filename><replaceable>target-name</replaceable>.test</filename>. + The <code>run*</code> rules also capture all output from the program, and + store it in a file named <filename><replaceable> + target-name</replaceable>.output</filename>. + </para> + + <para> + <indexterm><primary>preserve-test-targets</primary></indexterm> + If the <literal>preserve-test-targets</literal> feature has the value + <literal>off</literal>, then <code>run</code> and the <code>run-fail</code> + rules will remove the executable after running it. This somewhat decreases + disk space requirements for continuous testing environments. The default + value of <literal>preserve-test-targets</literal> feature is <literal>on</literal>. + </para> + + <para> + It is possible to print the list of all test targets (except for + <code>unit-test</code>) declared in your project, by passing the <literal> + --dump-tests</literal> command-line option. The output will consist of + lines of the form: +<screen> +boost-test(<replaceable>test-type</replaceable>) <replaceable>path</replaceable> : <replaceable>sources</replaceable> +</screen> + </para> + + <para> + It is possible to process the list of tests, Boost.Build output + and the presense/absense of the <filename>*.test</filename> + files created when test passes into human-readable status table of tests. + Such processing utilities are not included in Boost.Build. + </para> + + <para>The following features adjust behaviour of the testing metatargets.</para> + + <variablelist> + <varlistentry> + <term><literal>testing.arg</literal></term> + <indexterm><primary>testing.arg</primary></indexterm> + + <listitem> + <para> + Defines an argument to be passed to the target when it is executed + before the list of input files. + </para> + + <para> +<programlisting> +unit-test helpers_test + : helpers_test.cpp helpers + : <emphasis role="bold"><testing.arg>"--foo bar"</emphasis> + ; +</programlisting> + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>testing.input-file</literal></term> + <indexterm><primary>testing.input-file</primary></indexterm> + + <listitem> + <para> + Specifies a file to be passed to the executable on the command line + after the arguments. All files must be specified in alphabetical + order due to constrainsts in the current implementation. + </para> + + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>testing.launcher</literal></term> + <indexterm><primary>testing.launcher</primary></indexterm> + + <listitem> + <para> + By default, the executable is run directly. Sometimes, it is + desirable to run the executable using some helper command. You + should use this property to specify the name of the helper + command. For example, if you write: +<programlisting> +unit-test helpers_test + : helpers_test.cpp helpers + : <emphasis role="bold"><testing.launcher>valgrind</emphasis> + ; +</programlisting> + The command used to run the executable will be: +<screen> +<emphasis role="bold">valgrind</emphasis> bin/$toolset/debug/helpers_test +</screen> + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>test-info</literal></term> + <indexterm><primary>test-info</primary></indexterm> + + <listitem> + <para> + A description of the test. This is displayed as part of the + <literal>--dump-tests</literal> command-line option. + </para> + </listitem> + </varlistentry> + + </variablelist> + </section> + + <section id="bbv2.builtins.raw"> + <title>Custom commands</title> + + <para> + For most main target rules, Boost.Build automatically figures out + the commands to run. When you want to use new + file types or support new tools, one approach is to extend Boost.Build to + support them smoothly, as documented in <xref linkend="bbv2.extender"/>. + However, if the new tool is only used in a single place, it + might be easier just to specify the commands to run explicitly. + </para> + + <para> + <!-- This paragraph requires links to where the terms 'virtual target' & + 'target' are defined. --> + Three main target rules can be used for that. The <code language="jam">make + </code> rule allows you to construct a single file from any number + of source file, by running a command you specify. The <code language="jam"> + notfile</code> rule allows you to run an arbitrary command, + without creating any files. And finaly, the <code language="jam">generate + </code> rule allows you to describe a transformation using + Boost.Build's virtual targets. This is higher-level than the file names that + the <code language="jam">make</code> rule operates with and allows you to + create more than one target, create differently named targets depending on + properties, or use more than one tool. + </para> + + <para> + The <code language="jam">make</code> rule is used when you want to create + one file from a number of sources using some specific command. The + <code language="jam">notfile</code> is used to unconditionally run a + command. + </para> + + <!-- We need to specify somewhere that the user can get rules like make, + notfile & generate defined in his Jamfiles by importing an appropriate + Boost.Build module. Also, each of those rules should get a separate + documentation page explicitly listing which module needs to be imported for + them to become accessible. --> + + <para> + Suppose you want to create the file <filename>file.out</filename> from + the file <filename>file.in</filename> by running the command <command> + in2out</command>. Here is how you would do this in Boost.Build: +<programlisting> +make file.out : file.in : @in2out ; +actions in2out +{ + in2out $(<) $(>) +} +</programlisting> + If you run <command>b2</command> and <filename>file.out</filename> does + not exist, Boost.Build will run the <command>in2out</command> command to + create that file. For more details on specifying actions, see <xref + linkend="bbv2.overview.jam_language.actions"/>. + </para> + + <para> + It could be that you just want to run some command unconditionally, and + that command does not create any specific files. For that you can use the + <code language="jam">notfile</code> rule. For example: +<programlisting> +notfile echo_something : @echo ; +actions echo +{ + echo "something" +} +</programlisting> + The only difference from the <code language="jam">make</code> rule is + that the name of the target is not considered a name of a file, so + Boost.Build will unconditionally run the action. + </para> + + <para> + <!-- This paragraph requires links to where terms like 'virtual target', + 'target', 'project-target' & 'property-set' are defined. --> + The <code language="jam">generate</code> rule is used when you want to + express transformations using Boost.Build's virtual targets, as opposed to + just filenames. The <code language="jam">generate</code> rule has the + standard main target rule signature, but you are required to specify the + <literal>generating-rule</literal> property. The value of the property + should be in the form <literal> + @<replaceable>rule-name</replaceable></literal>, the named rule should + have the following signature: +<programlisting> +rule generating-rule ( project name : property-set : sources * ) +</programlisting> + and will be called with an instance of the <code>project-target</code> + class, the name of the main target, an instance of the + <code>property-set</code> class containing build properties, and the list + of instances of the <code>virtual-target</code> class corresponding to + sources. The rule must return a list of <code>virtual-target</code> + instances. The interface of the <code>virtual-target</code> class can be + learned by looking at the <filename>build/virtual-target.jam</filename> + file. The <filename>generate</filename> example contained in the + Boost.Build distribution illustrates how the <literal>generate</literal> + rule can be used. + </para> + </section> + + <section id="bbv2.reference.precompiled_headers"> + <title>Precompiled Headers</title> + + <para> + Precompiled headers is a mechanism to speed up compilation by creating a + partially processed version of some header files, and then using that + version during compilations rather then repeatedly parsing the original + headers. Boost.Build supports precompiled headers with gcc and msvc + toolsets. + </para> + + <para> + To use precompiled headers, follow the following steps: + </para> + + <orderedlist> + <listitem> + <para> + Create a header that includes headers used by your project that you + want precompiled. It is better to include only headers that are + sufficiently stable — like headers from the compiler and + external libraries. Please wrap the header in <code>#ifdef + BOOST_BUILD_PCH_ENABLED</code>, so that the potentially expensive + inclusion of headers is not done when PCH is not enabled. Include the + new header at the top of your source files. + </para> + </listitem> + + <listitem> + <para> + Declare a new Boost.Build target for the precompiled header and add + that precompiled header to the sources of the target whose compilation + you want to speed up: +<programlisting> +cpp-pch pch : pch.hpp ; +exe main : main.cpp pch ; +</programlisting> + You can use the <code language="jam">c-pch</code> rule if you want to + use the precompiled header in C programs. + </para></listitem> + </orderedlist> + + <para> + The <filename>pch</filename> example in Boost.Build distribution can be + used as reference. + </para> + + <para> + Please note the following: + </para> + + <itemizedlist> + <listitem> + <para> + The inclusion of the precompiled header must be the first thing in a + source file, before any code or preprocessor directives. + </para> + </listitem> + + <listitem> + <para> + The build properties used to compile the source files and the + precompiled header must be the same. Consider using project + requirements to assure this. + </para> + </listitem> + + <listitem> + <para> + Precompiled headers must be used purely as a way to improve + compilation time, not to save the number of <code>#include</code> + statements. If a source file needs to include some header, explicitly + include it in the source file, even if the same header is included + from the precompiled header. This makes sure that your project will + build even if precompiled headers are not supported. + </para> + </listitem> + + <listitem> + <para> + On the gcc compiler, the name of the header being precompiled must be + equal to the name of the <code>cpp-pch</code> target. This is a gcc + requirement. + </para> + </listitem> + + <listitem> + <para> + Prior to version 4.2, the gcc compiler did not allow anonymous + namespaces in precompiled headers, which limits their utility. See the + <ulink url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29085"> bug + report</ulink> for details. + </para> + </listitem> + </itemizedlist> + </section> + + <section id="bbv2.reference.generated_headers"> + <title>Generated headers</title> + + <para> + Usually, Boost.Build handles implicit dependendies completely + automatically. For example, for C++ files, all <literal>#include</literal> + statements are found and handled. The only aspect where user help might be + needed is implicit dependency on generated files. + </para> + + <para> + By default, Boost.Build handles such dependencies within one main target. + For example, assume that main target "app" has two sources, "app.cpp" and + "parser.y". The latter source is converted into "parser.c" and "parser.h". + Then, if "app.cpp" includes "parser.h", Boost.Build will detect this + dependency. Moreover, since "parser.h" will be generated into a build + directory, the path to that directory will automatically be added to the include + path. + </para> + + <para> + Making this mechanism work across main target boundaries is possible, but + imposes certain overhead. For that reason, if there is implicit dependency + on files from other main targets, the <literal><implicit-dependency> + </literal> feature must be used, for example: +<programlisting> +lib parser : parser.y ; +exe app : app.cpp : <implicit-dependency>parser ; +</programlisting> + The above example tells the build system that when scanning all sources of + "app" for implicit-dependencies, it should consider targets from "parser" + as potential dependencies. + </para> + </section> + + <section id="bbv2.tasks.crosscompile"> + <title>Cross-compilation</title> + + <indexterm><primary>cross compilation</primary></indexterm> + + <para>Boost.Build supports cross compilation with the gcc and msvc + toolsets.</para> + + <para> + When using gcc, you first need to specify your cross compiler + in <filename>user-config.jam</filename> (see <xref linkend="bbv2.overview.configuration"/>), + for example:</para> +<programlisting> +using gcc : arm : arm-none-linux-gnueabi-g++ ; +</programlisting> + <para> + After that, if the host and target os are the same, for example Linux, you can + just request that this compiler version be used: + </para> +<screen> +b2 toolset=gcc-arm +</screen> + + <para> + If you want to target a different operating system from the host, you need + to additionally specify the value for the <code>target-os</code> feature, for + example: + </para> +<screen> +# On windows box +b2 toolset=gcc-arm <emphasis role="bold">target-os=linux</emphasis> +# On Linux box +b2 toolset=gcc-mingw <emphasis role="bold">target-os=windows</emphasis> +</screen> + <para> + For the complete list of allowed opeating system names, please see the documentation for + <link linkend="bbv2.reference.features.target-os">target-os feature</link>. + </para> + + <para> + When using the msvc compiler, it's only possible to cross-compile to a 64-bit system + on a 32-bit host. Please see <xref linkend="v2.reference.tools.compiler.msvc.64"/> for + details. + </para> + + </section> + +</chapter> + +<!-- + Local Variables: + mode: nxml + sgml-indent-data: t + sgml-parent-document: ("userman.xml" "chapter") + sgml-set-face: t + End: +--> diff --git a/boost/tools/build/doc/src/tutorial.xml b/boost/tools/build/doc/src/tutorial.xml new file mode 100644 index 00000000..e36ac140 --- /dev/null +++ b/boost/tools/build/doc/src/tutorial.xml @@ -0,0 +1,682 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE chapter PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<?psgml nofill screen programlisting literallayout?> + +<chapter id="bbv2.tutorial"> + <title>Tutorial</title> + +<!-- You can't launch into this stuff without describing how to configure --> +<!-- Boost.Build... unless of course you think it's likely to work with --> +<!-- no configuration. But even if you do you have to tell people how to --> +<!-- configure their installation in case it doesn't work. --> +<!-- + VP: need also mention the examples which correspond to specific + sections. +--> + + <para> + This section will guide you though the most basic features of Boost.Build. + We will start with the “Hello, world” example, learn how + to use libraries, and finish with testing and installing features. + </para> + + <section id="bbv2.tutorial.hello"> + <title>Hello, world</title> + + <para> + The simplest project that Boost.Build can construct is stored in + <filename>example/hello/</filename> directory. The project is described by + a file called <filename>Jamroot</filename> that contains: + +<programlisting language="jam"> +exe hello : hello.cpp ; +</programlisting> + + Even with this simple setup, you can do some interesting things. First of + all, just invoking <command>b2</command> will build the <filename>hello + </filename> executable by compiling and linking <filename>hello.cpp + </filename>. By default, the debug variant is built. Now, to build the release + variant of <filename>hello</filename>, invoke + +<screen> +b2 release +</screen> + + Note that the debug and release variants are created in different directories, + so you can switch between variants or even build multiple variants at + once, without any unnecessary recompilation. Let us extend the example by + adding another line to our project's <filename>Jamroot</filename>: + +<programlisting language="jam"> +exe hello2 : hello.cpp ; +</programlisting> + + Now let us build both the debug and release variants of our project again: + +<screen> +b2 debug release +</screen> + + Note that two variants of <filename>hello2</filename> are linked. Since we + have already built both variants of <filename>hello</filename>, hello.cpp + will not be recompiled; instead the existing object files will just be + linked into the corresponding variants of <filename>hello2</filename>. Now + let us remove all the built products: + +<screen> +b2 --clean debug release +</screen> + + It is also possible to build or clean specific targets. The following two + commands, respectively, build or clean only the debug version of + <filename>hello2</filename>. + +<screen> +b2 hello2 +b2 --clean hello2 +</screen> + </para> + </section> + + <section id="bbv2.tutorial.properties"> + <title>Properties</title> + + <para> + To represent aspects of target configuration such as + debug and release variants, or single- and multi-threaded + builds portably, Boost.Build uses <firstterm>features</firstterm> with + associated <firstterm>values</firstterm>. For + example, the <code>debug-symbols</code> feature can have a value of <code>on</code> or + <code>off</code>. A <firstterm>property</firstterm> is just a (feature, + value) pair. When a user initiates a build, Boost.Build + automatically translates the requested properties into appropriate + command-line flags for invoking toolset components like compilers + and linkers. + </para> + + <para> + There are many built-in features that can be combined to + produce arbitrary build configurations. The following command + builds the project's <code>release</code> variant with inlining + disabled and debug symbols enabled: +<screen> +b2 release inlining=off debug-symbols=on +</screen> + </para> + + <para> + Properties on the command-line are specified with the syntax: + +<screen> +<replaceable>feature-name</replaceable>=<replaceable>feature-value</replaceable> +</screen> + </para> + + <para> + The <option>release</option> and <option>debug</option> that we have seen + in <command>b2</command> invocations are just a shorthand way to specify + values of the <varname>variant</varname> feature. For example, the + command above could also have been written this way: + + <screen> +b2 variant=release inlining=off debug-symbols=on + </screen> + </para> + + <para> + <varname>variant</varname> is so commonly-used that it has been given + special status as an <firstterm>implicit</firstterm> feature— + Boost.Build will deduce its identity just from the name of one of its + values. + </para> + + <para> + A complete description of features can be found in <xref linkend="bbv2.reference.features"/>. + </para> + + <section id="bbv2.tutorial.properties.requirements"> + <title>Build Requests and Target Requirements</title> + + <para> + The set of properties specified on the command line constitutes + a <firstterm>build request</firstterm>—a description of + the desired properties for building the requested targets (or, + if no targets were explicitly requested, the project in the + current directory). The <emphasis>actual</emphasis> + properties used for building targets are typically a + combination of the build request and properties derived from + the project's <filename>Jamroot</filename> (and its other + Jamfiles, as described in <xref + linkend="bbv2.tutorial.hierarchy"/>). For example, the + locations of <code>#include</code>d header files are normally + not specified on the command-line, but described in + Jamfiles as <firstterm>target + requirements</firstterm> and automatically combined with the + build request for those targets. Multithread-enabled + compilation is another example of a typical target + requirement. The Jamfile fragment below + illustrates how these requirements might be specified. + </para> + +<programlisting language="jam"> +exe hello + : hello.cpp + : <include>boost <threading>multi + ; +</programlisting> + + <para> + When <filename>hello</filename> is built, the two requirements specified + above will always be present. If the build request given on the + <command>b2</command> command-line explictly contradicts a target's + requirements, the target requirements usually override (or, in the case + of “free”” features like + <varname><include></varname>, + <footnote> + <para> + See <xref linkend="bbv2.reference.features.attributes"/> + </para> + </footnote> + augment) the build request. + </para> + + <tip> + <para> + The value of the <varname><include></varname> feature is + relative to the location of <filename>Jamroot</filename> where it is + used. + </para> + </tip> + </section> + + <section id="bbv2.tutorial.properties.project_attributes"> + <title>Project Attributes</title> + + <para> + If we want the same requirements for our other target, + <filename>hello2</filename>, we could simply duplicate them. However, + as projects grow, that approach leads to a great deal of repeated + boilerplate in Jamfiles. + + Fortunately, there's a better way. Each project can specify a set of + <firstterm>attributes</firstterm>, including requirements: + +<programlisting language="jam"> +project + : requirements <include>/home/ghost/Work/boost <threading>multi + ; + +exe hello : hello.cpp ; +exe hello2 : hello.cpp ;</programlisting> + + The effect would be as if we specified the same requirement for both + <filename>hello</filename> and <filename>hello2</filename>. + </para> + </section> + </section> + + <section id="bbv2.tutorial.hierarchy"> + <title>Project Hierarchies</title> + + <para> + So far we have only considered examples with one project, with + one user-written Boost.Jam file, <filename>Jamroot</filename>. A typical + large codebase would be composed of many projects organized into a tree. + The top of the tree is called the <firstterm>project root</firstterm>. + Every subproject is defined by a file called <filename>Jamfile</filename> + in a descendant directory of the project root. The parent project of a + subproject is defined by the nearest <filename>Jamfile</filename> or + <filename>Jamroot</filename> file in an ancestor directory. For example, + in the following directory layout: + +<screen> +top/ + | + +-- Jamroot + | + +-- app/ + | | + | +-- Jamfile + | `-- app.cpp + | + `-- util/ + | + +-- foo/ + . | + . +-- Jamfile + . `-- bar.cpp +</screen> + + the project root is <filename>top/</filename>. The projects in + <filename>top/app/</filename> and <filename>top/util/foo/</filename> are + immediate children of the root project. + + <note> + <para> + When we refer to a “Jamfile,” set in normal + type, we mean a file called either + <filename>Jamfile</filename> or + <filename>Jamroot</filename>. When we need to be more + specific, the filename will be set as + “<filename>Jamfile</filename>” or + “<filename>Jamroot</filename>.” + </para> + </note> + </para> + + <para> + Projects inherit all attributes (such as requirements) + from their parents. Inherited requirements are combined with + any requirements specified by the subproject. + For example, if <filename>top/Jamroot</filename> has + +<programlisting language="jam"> +<include>/home/ghost/local +</programlisting> + + in its requirements, then all of its subprojects will have it + in their requirements, too. Of course, any project can add + include paths to those specified by its parents. <footnote> + <para>Many + features will be overridden, + rather than added-to, in subprojects. See <xref + linkend="bbv2.reference.features.attributes"/> for more + information</para> + </footnote> + More details can be found in + <xref linkend= "bbv2.overview.projects"/>. + </para> + + <para> + Invoking <command>b2</command> without explicitly specifying + any targets on the command line builds the project rooted in the + current directory. Building a project does not automatically + cause its subprojects to be built unless the parent project's + Jamfile explicitly requests it. In our example, + <filename>top/Jamroot</filename> might contain: + +<programlisting language="jam"> +build-project app ; +</programlisting> + + which would cause the project in <filename>top/app/</filename> + to be built whenever the project in <filename>top/</filename> is + built. However, targets in <filename>top/util/foo/</filename> + will be built only if they are needed by targets in + <filename>top/</filename> or <filename>top/app/</filename>. + </para> + </section> + + <section id="bbv2.tutorial.libs"> + <title>Dependent Targets</title> + + <para> + When building a target <filename>X</filename> that depends on first + building another target <filename>Y</filename> (such as a + library that must be linked with <firstterm>X</firstterm>), + <filename>Y</filename> is called a + <firstterm>dependency</firstterm> of <filename>X</filename> and + <filename>X</filename> is termed a + <firstterm>dependent</firstterm> of <filename>Y</filename>. + </para> + + <para>To get a feeling of target dependencies, let's continue the + above example and see how <filename>top/app/Jamfile</filename> can + use libraries from <filename>top/util/foo</filename>. If + <filename>top/util/foo/Jamfile</filename> contains + +<programlisting language="jam"> +lib bar : bar.cpp ; +</programlisting> + + then to use this library in <filename>top/app/Jamfile</filename>, we can + write: + +<programlisting language="jam"> +exe app : app.cpp ../util/foo//bar ; +</programlisting> + + While <code>app.cpp</code> refers to a regular source file, + <code>../util/foo//bar</code> is a reference to another target: + a library <filename>bar</filename> declared in the Jamfile at + <filename>../util/foo</filename>. + </para> + + <tip> + <para>Some other build system have special syntax for listing dependent + libraries, for example <varname>LIBS</varname> variable. In Boost.Build, + you just add the library to the list of sources. + </para> + </tip> + + <para>Suppose we build <filename>app</filename> with: + <screen> +b2 app optimization=full define=USE_ASM + </screen> + Which properties will be used to build <code>foo</code>? The answer is + that some features are + <firstterm>propagated</firstterm>—Boost.Build attempts to use + dependencies with the same value of propagated features. The + <varname><optimization></varname> feature is propagated, so both + <filename>app</filename> and <filename>foo</filename> will be compiled + with full optimization. But <varname><define></varname> is not + propagated: its value will be added as-is to the compiler flags for + <filename>a.cpp</filename>, but won't affect <filename>foo</filename>. + </para> + + + <para> + Let's improve this project further. The library probably has some headers + that must be used when compiling <filename>app.cpp</filename>. We could + manually add the necessary <code>#include</code> paths to + <filename>app</filename>'s requirements as values of the + <varname><include> </varname> feature, but then this work will be + repeated for all programs that use <filename>foo</filename>. A better + solution is to modify <filename>util/foo/Jamfile</filename> in this way: + + <programlisting language="jam"> +project + : usage-requirements <include>. + ; + +lib foo : foo.cpp ;</programlisting> + + Usage requirements are applied not to the target being declared but to its + dependents. In this case, <literal><include>.</literal> will be + applied to all targets that directly depend on <filename>foo</filename>. + </para> + + <para> + Another improvement is using symbolic identifiers to refer to the library, + as opposed to <filename>Jamfile</filename> location. In a large project, a + library can be used by many targets, and if they all use <filename>Jamfile + </filename> location, a change in directory organization entails much + work. The solution is to use project ids—symbolic names not tied to + directory layout. First, we need to assign a project id by adding this + code to <filename>Jamroot</filename>: + </para> + + <programlisting language="jam"> +use-project /library-example/foo : util/foo ;</programlisting> + + <para> + Second, we modify <filename>app/Jamfile</filename> to use the project id: + <programlisting> +exe app : app.cpp /library-example/foo//bar ;</programlisting> + + The <filename>/library-example/foo//bar</filename> syntax is used to refer + to the target <filename>bar</filename> in the project with id <filename> + /library-example/foo</filename>. We've achieved our goal—if the + library is moved to a different directory, only <filename>Jamroot + </filename> must be modified. Note that project ids are global—two + Jamfiles are not allowed to assign the same project id to different + directories. + </para> + + <tip> + <para>If you want all applications in some project to link to a certain + library, you can avoid having to specify directly the sources of + every target by using the <varname><library></varname> property. + For example, if <filename>/boost/filesystem//fs</filename> should be + linked to all applications in your project, you can add + <code><library>/boost/filesystem//fs</code> to the project's + requirements, like this: + </para> + + <programlisting language="jam"> +project + : requirements <library>/boost/filesystem//fs + ;</programlisting> + </tip> + </section> + + <section id="bbv2.tutorial.linkage"> + <title>Static and shared libraries</title> + + <para> + Libraries can be either <emphasis>static</emphasis>, which means they are + included in executable files that use them, or <emphasis>shared</emphasis> + (a.k.a. <emphasis>dynamic</emphasis>), which are only referred to from + executables, and must be available at run time. Boost.Build can create and + use both kinds. + </para> + + <para> + The kind of library produced from a <code>lib</code> target is determined + by the value of the <varname>link</varname> feature. Default value is + <literal>shared</literal>, and to build a static library, the value should + be <literal>static</literal>. You can request a static build either on the + command line: + <programlisting>b2 link=static</programlisting> + or in the library's requirements: + <programlisting language="jam">lib l : l.cpp : <link>static ;</programlisting> + </para> + + <para> + We can also use the <varname><link></varname> property to express + linking requirements on a per-target basis. For example, if a particular + executable can be correctly built only with the static version of a + library, we can qualify the executable's <link + linkend="bbv2.reference.targets.references">target reference</link> to the + library as follows: + +<!-- There has been no earlier indication that target references can contain + properties. You can't assume that the reader will recognize that strange + incantation as a target reference, or that she'll know what it means. You + also can't assume that hyperlinks will help the reader, because she may be + working from a printout, as I was. + VP: to be addressed when this section is moved. See comment below. +--> + + <programlisting language="jam"> +exe important : main.cpp helpers/<link>static ;</programlisting> + + No matter what arguments are specified on the <command>b2</command> + command line, <filename>important</filename> will only be linked with the + static version of <filename>helpers</filename>. + </para> + + <para> + Specifying properties in target references is especially useful if you use + a library defined in some other project (one you can't change) but you + still want static (or dynamic) linking to that library in all cases. If + that library is used by many targets, you <emphasis>could</emphasis> use + target references everywhere: + + <programlisting language="jam"> +exe e1 : e1.cpp /other_project//bar/<link>static ; +exe e10 : e10.cpp /other_project//bar/<link>static ;</programlisting> + + but that's far from being convenient. A better approach is to introduce a + level of indirection. Create a local <type>alias</type> target that refers + to the static (or dynamic) version of <filename>foo</filename>: + + <programlisting> +alias foo : /other_project//bar/<link>static ; +exe e1 : e1.cpp foo ; +exe e10 : e10.cpp foo ;</programlisting> + + The <link linkend="bbv2.tasks.alias">alias</link> rule is specifically + used to rename a reference to a target and possibly change the + properties. + + <!-- You should introduce the alias rule in an earlier section, before + describing how it applies to this specific use-case, and the + foregoing sentence should go there. + VP: we've agreed that this section should be moved further in the + docs, since it's more like advanced reading. When I move it, I'll + make sure 'alias' is already mentioned. + --> + </para> + + <tip> + <para> + When one library uses another, you put the second library in the source + list of the first. For example: + <programlisting language="jam"> +lib utils : utils.cpp /boost/filesystem//fs ; +lib core : core.cpp utils ; +exe app : app.cpp core ;</programlisting> + This works no matter what kind of linking is used. When <filename>core + </filename> is built as a shared library, links <filename>utils + </filename> directly into it. Static libraries can't link to other + libraries, so when <filename>core</filename> is built as a static + library, its dependency on <filename>utils</filename> is passed along to + <filename>core</filename>'s dependents, causing <filename>app</filename> + to be linked with both <filename>core</filename> and <filename>utils + </filename>. + </para> + </tip> + + <note> + <para> + (Note for non-UNIX system). Typically, shared libraries must be + installed to a directory in the dynamic linker's search path. Otherwise, + applications that use shared libraries can't be started. On Windows, the + dynamic linker's search path is given by the <envar>PATH</envar> + environment variable. This restriction is lifted when you use + Boost.Build testing facilities—the <envar>PATH</envar> variable + will be automatically adjusted before running the executable. + <!-- Need ref here to 'testing facilities' --> + </para> + </note> + </section> + + <section id="bbv2.tutorial.conditions"> + <title>Conditions and alternatives</title> + + <para> + Sometimes, particular relationships need to be maintained among a target's + build properties. For example, you might want to set specific <code> + #define</code> when a library is built as shared, or when a target's + <code>release</code> variant is built. This can be achieved using + <firstterm>conditional requirements</firstterm>. + + <programlisting language="jam"> +lib network : network.cpp + : <emphasis role="bold"><link>shared:<define>NETWORK_LIB_SHARED</emphasis> + <variant>release:<define>EXTRA_FAST + ;</programlisting> + + In the example above, whenever <filename>network</filename> is built with + <code language="jam"><link>shared</code>, <code language="jam"><define>NETWORK_LIB_SHARED + </code> will be in its properties, too. Also, whenever its release variant + is built, <code><define>EXTRA_FAST</code> will appear in its + properties. + </para> + + <para> + Sometimes the ways a target is built are so different that describing them + using conditional requirements would be hard. For example, imagine that a + library actually uses different source files depending on the toolset used + to build it. We can express this situation using <firstterm>target + alternatives</firstterm>: + <programlisting language="jam"> +lib demangler : dummy_demangler.cpp ; # alternative 1 +lib demangler : demangler_gcc.cpp : <toolset>gcc ; # alternative 2 +lib demangler : demangler_msvc.cpp : <toolset>msvc ; # alternative 3</programlisting> + When building <filename>demangler</filename>, Boost.Build will compare + requirements for each alternative with build properties to find the best + match. For example, when building with <code language="jam"><toolset>gcc</code> + alternative 2, will be selected, and when building with + <code language="jam"><toolset>msvc</code> alternative 3 will be selected. In all + other cases, the most generic alternative 1 will be built. + </para> + </section> + + <section id="bbv2.tutorial.prebuilt"> + <title>Prebuilt targets</title> + + <para> + To link to libraries whose build instructions aren't given in a Jamfile, + you need to create <code>lib</code> targets with an appropriate + <varname>file</varname> property. Target alternatives can be used to + associate multiple library files with a single conceptual target. For + example: + <programlisting language="jam"> +# util/lib2/Jamfile +lib lib2 + : + : <file>lib2_release.a <variant>release + ; + +lib lib2 + : + : <file>lib2_debug.a <variant>debug + ;</programlisting> + + This example defines two alternatives for <filename>lib2</filename>, and + for each one names a prebuilt file. Naturally, there are no sources. + Instead, the <varname><file></varname> feature is used to specify + the file name. + </para> + + <para> + Once a prebuilt target has been declared, it can be used just like any + other target: + + <programlisting language="jam"> +exe app : app.cpp ../util/lib2//lib2 ;</programlisting> + + As with any target, the alternative selected depends on the properties + propagated from <filename>lib2</filename>'s dependents. If we build the + release and debug versions of <filename>app</filename> it will be linked + with <filename>lib2_release.a</filename> and <filename>lib2_debug.a + </filename>, respectively. + </para> + + <para> + System libraries—those that are automatically found by the toolset + by searching through some set of predetermined paths—should be + declared almost like regular ones: + + <programlisting language="jam"> +lib pythonlib : : <name>python22 ;</programlisting> + + We again don't specify any sources, but give a <varname>name</varname> + that should be passed to the compiler. If the gcc toolset were used to + link an executable target to <filename>pythonlib</filename>, + <option>-lpython22</option> would appear in the command line (other + compilers may use different options). + </para> + + <para> + We can also specify where the toolset should look for the library: + + <programlisting language="jam"> +lib pythonlib : : <name>python22 <search>/opt/lib ;</programlisting> + + And, of course, target alternatives can be used in the usual way: + + <programlisting language="jam"> +lib pythonlib : : <name>python22 <variant>release ; +lib pythonlib : : <name>python22_d <variant>debug ;</programlisting> + </para> + + <para> + A more advanced use of prebuilt targets is described in <xref linkend= + "bbv2.recipies.site-config"/>. + </para> + </section> +</chapter> + +<!-- + Local Variables: + mode: nxml + sgml-indent-data:t + sgml-parent-document:("userman.xml" "chapter") + sgml-set-face: t + sgml-omittag:nil + sgml-shorttag:nil + sgml-namecase-general:t + sgml-general-insert-case:lower + sgml-minimize-attributes:nil + sgml-always-quote-attributes:t + sgml-indent-step:2 + sgml-exposed-tags:nil + sgml-local-catalogs:nil + sgml-local-ecat-files:nil + End: +--> diff --git a/boost/tools/build/doc/src/type.xml b/boost/tools/build/doc/src/type.xml new file mode 100644 index 00000000..6ca7cc7a --- /dev/null +++ b/boost/tools/build/doc/src/type.xml @@ -0,0 +1,236 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<section id="bbv2.reference.modules.type"> + + <title>type</title> + <indexterm> + <primary>type</primary> + <secondary>module</secondary> + </indexterm> + + <para> + Deals with target type declaration and defines target class which supports + typed targets. + </para> + + <orderedlist> + + <listitem id="bbv2.reference.modules.type.register"> + <indexterm zone="bbv2.reference.modules.type.register"> + <primary>register</primary> + <secondary>type</secondary> + </indexterm> + <code language="jam">rule register ( type : suffixes * : base-type ? )</code> + <para> + Registers a target type, possible derived from a + <code language="jam">base-type</code>. Providing a list + of suffixes here is a shortcut for separately calling the + <link linkend="bbv2.reference.modules.type.register-suffixes">register-suffixes</link> + rule with the given suffixes and the + <link linkend="bbv2.reference.modules.type.set-generated-target-suffix">set-generated-target-suffix</link> + rule with the first given suffix. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.register-suffixes"> + <indexterm zone="bbv2.reference.modules.type.register-suffixes"> + <primary>register-suffixes</primary> + </indexterm> + <code language="jam">rule register-suffixes ( suffixes + : type )</code> + <para> + Specifies that files with suffix from <code language="jam">suffixes</code> + be recognized as targets of type <code language="jam">type</code>. + Issues an error if a different type is already specified for any + of the suffixes. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.registered"> + <indexterm zone="bbv2.reference.modules.type.registered"> + <primary>registered</primary> + </indexterm> + <code language="jam">rule registered ( type )</code> + <para>Returns true iff type has been registered.</para> + </listitem> + + <listitem id="bbv2.reference.modules.type.validate"> + <indexterm zone="bbv2.reference.modules.type.validate"> + <primary>validate</primary> + </indexterm> + <code language="jam">rule validate ( type )</code> + <para>Issues an error if <code lang="jam">type</code> is unknown.</para> + </listitem> + + <listitem id="bbv2.reference.modules.type.set-scanner"> + <indexterm zone="bbv2.reference.modules.type.set-scanner"> + <primary>set-scanner</primary> + </indexterm> + <code language="jam">rule set-scanner ( type : scanner )</code> + <para>Sets a scanner class that will be used for this type.</para> + </listitem> + + <listitem id="bbv2.reference.modules.type.get-scanner"> + <indexterm zone="bbv2.reference.modules.type.get-scanner"> + <primary>get-scanner</primary> + </indexterm> + <code language="jam">rule get-scanner ( type : property-set )</code> + <para> + Returns a scanner instance appropriate to <code language="jam">type</code> + and <code language="jam">property-set</code>. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.base"> + <indexterm zone="bbv2.reference.modules.type.base"> + <primary>base</primary> + </indexterm> + <code language="jam">rule base ( type )</code> + <para> + Returns a base type for the given type or nothing in case the given + type is not derived. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.all-bases"> + <indexterm zone="bbv2.reference.modules.type.all-bases"> + <primary>all-bases</primary> + </indexterm> + <code language="jam">rule all-bases ( type )</code> + <para> + Returns the given type and all of its base types in order of + their distance from type. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.all-derived"> + <indexterm zone="bbv2.reference.modules.type.all-derived"> + <primary>all-derived</primary> + </indexterm> + <code language="jam">rule all-derived ( type )</code> + <para> + Returns the given type and all of its derived types in order + of their distance from type. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.is-derived"> + <indexterm zone="bbv2.reference.modules.type.is-derived"> + <primary>is-derived</primary> + </indexterm> + <code language="jam">rule is-derived ( type base )</code> + <para> + Returns true if <code language="jam">type</code> is equal to + <code language="jam">base</code> or has <code language="jam">base</code> + as its direct or indirect base. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.set-generated-target-suffix"> + <indexterm zone="bbv2.reference.modules.type.set-generated-target-suffix"> + <primary>set-generated-target-suffix</primary> + </indexterm> + <code language="jam">rule set-generated-target-suffix ( type : properties * : suffix )</code> + <para> + Sets a file suffix to be used when generating a target of <code language="jam">type</code> with the + specified properties. Can be called with no properties if no suffix has + already been specified for the <code language="jam">type</code>. The <code language="jam">suffix</code> parameter can be an empty + string (<code language="jam">""</code>) to indicate that no suffix should be used. + </para> + + <para> + Note that this does not cause files with <code language="jam">suffix</code> + to be automatically recognized as being of <code language="jam">type</code>. + 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 + <link linkend="bbv2.reference.modules.type.register-suffixes">register-suffixes</link> + rule. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.change-generated-target-suffix"> + <indexterm zone="bbv2.reference.modules.type.change-generated-target-suffix"> + <primary>change-generated-target-suffix</primary> + </indexterm> + <code language="jam">rule change-generated-target-suffix ( type : properties * : suffix )</code> + <para> + Change the suffix previously registered for this type/properties + combination. If suffix is not yet specified, sets it. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.generated-target-suffix"> + <indexterm zone="bbv2.reference.modules.type.generated-target-suffix"> + <primary>generated-target-suffix</primary> + </indexterm> + <code language="jam">rule generated-target-suffix ( type : property-set )</code> + <para> + Returns the suffix used when generating a file of + <code language="jam">type</code> with the given properties. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.set-generated-target-prefix"> + <indexterm zone="bbv2.reference.modules.type.set-generated-target-prefix"> + <primary>set-generated-target-prefix</primary> + </indexterm> + <code language="jam">rule set-generated-target-prefix ( type : properties * : prefix )</code> + <para> + Sets a target prefix that should be used when generating targets of + <code language="jam">type</code> with the specified properties. Can + be called with empty properties if no prefix for + <code language="jam">type</code> has been specified yet. + </para> + + <para> + The <code language="jam">prefix</code> parameter can be empty string + (<code language="jam">""</code>) to indicate that no prefix + should be used. + </para> + + <para> + Usage example: library names use the <code language="jam">"lib"</code> + prefix on unix. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.change-generated-target-prefix"> + <indexterm zone="bbv2.reference.modules.type.change-generated-target-prefix"> + <primary>change-generated-target-prefix</primary> + </indexterm> + <code language="jam">rule change-generated-target-prefix ( type : properties * : prefix )</code> + <para> + Change the prefix previously registered for this type/properties + combination. If prefix is not yet specified, sets it. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.generated-target-prefix"> + <indexterm zone="bbv2.reference.modules.type.generated-target-prefix"> + <primary>generated-target-prefix</primary> + </indexterm> + <code language="jam">rule generated-target-prefix ( type : property-set )</code> + <para> + Returns the prefix used when generating a file of + <code language="jam">type</code> with the given properties. + </para> + </listitem> + + <listitem id="bbv2.reference.modules.type.type"> + <indexterm zone="bbv2.reference.modules.type.type"> + <primary>type</primary> + <secondary>rule</secondary> + </indexterm> + <code language="jam">rule type ( filename )</code> + <para> + 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. + </para> + </listitem> + + </orderedlist> + +</section> diff --git a/boost/tools/build/doc/src/typed-target.xml b/boost/tools/build/doc/src/typed-target.xml new file mode 100644 index 00000000..2a7d7c98 --- /dev/null +++ b/boost/tools/build/doc/src/typed-target.xml @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<section id="bbv2.reference.class.typed-target"> + + <title>Class typed-target</title> + <indexterm> + <primary>typed-target</primary> + </indexterm> + +<programlisting language="jam"> +class typed-target : <link linkend="bbv2.reference.class.basic-target">basic-target</link> { + rule <link linkend="bbv2.reference.class.typed-target.__init__">__init__</link> ( name : project : type : sources * : requirements * : default-build * : usage-requirements * ) + rule <link linkend="bbv2.reference.class.typed-target.type">type</link> ( ) + rule <link linkend="bbv2.reference.class.typed-target.construct">construct</link> ( name : source-targets * : property-set ) + + # Methods inherited from <link linkend="bbv2.reference.class.abstract-target">abstract-target</link> + rule <link linkend="bbv2.reference.class.abstract-target.name">name</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.project">project</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.location">location</link> ( ) + rule <link linkend="bbv2.reference.class.abstract-target.full-name">full-name</link> ( ) + + # Methods inherited from <link linkend="bbv2.reference.class.basic-target">basic-target</link> + rule <link linkend="bbv2.reference.class.basic-target.generate">generate</link> ( property-set ) + } +</programlisting> + + <para> + <link linkend="bbv2.reference.class.typed-target">typed-target</link> + is the most common kind of target alternative. Rules for creating + typed targets are defined automatically for each type. + </para> + + <orderedlist> + + <listitem id="bbv2.reference.class.typed-target.__init__"> + <code language="jam">rule __init__ ( name : project : type : sources * : requirements * : default-build * : usage-requirements * )</code> + <para> + <variablelist> + <varlistentry> + <term><literal>name</literal></term> + <listitem><para>The name of the target</para></listitem> + </varlistentry> + <varlistentry> + <term><literal>project</literal></term> + <listitem> + <para> + The <link linkend="bbv2.reference.class.project-target">project</link> + in which the target is declared. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><literal>type</literal></term> + <listitem> + <para> + The <link linkend="bbv2.reference.modules.type">type</link> + of the target. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + + <listitem id="bbv2.reference.class.typed-target.type"> + <indexterm zone="bbv2.reference.class.typed-target.type"> + <primary>type</primary> + <secondary>Typed Target Method</secondary> + </indexterm> + <code language="jam">rule type ( )</code> + <para> + Returns the <link linkend="bbv2.reference.modules.type">type</link> + of the target. + </para> + </listitem> + + <listitem id="bbv2.reference.class.typed-target.construct"> + <indexterm zone="bbv2.reference.class.typed-target.construct"> + <primary>construct</primary> + <secondary>Typed Target Method</secondary> + </indexterm> + <code language="jam">rule construct ( name : source-targets * : property-set )</code> + <para> + Implements <link linkend="bbv2.reference.class.basic-target.construct"> + basic-target.construct</link>. Attempts to create a target of + the correct type using generators appropriate for the given + <link linkend="bbv2.reference.class.property-set">property-set</link>. + Returns a <link linkend="bbv2.reference.class.property-set"> + property-set</link> containing the usage requirements + and a list of virtual targets. + + <note> + <para> + This function is invoked automatically by + <link linkend="bbv2.reference.class.basic-target.generate">basic-target.generate</link> + and should not be called directly by users. + </para> + </note> + </para> + </listitem> + + </orderedlist> + +</section> diff --git a/boost/tools/build/doc/src/userman.xml b/boost/tools/build/doc/src/userman.xml new file mode 100644 index 00000000..396d8514 --- /dev/null +++ b/boost/tools/build/doc/src/userman.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE part PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" + "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> + +<part xmlns:xi="http://www.w3.org/2001/XInclude" + id="bbv2" last-revision="$Date$"> + + <title>Boost.Build User Manual</title> + + <!-- Chapters --> + <xi:include href="howto.xml"/> + <xi:include href="install.xml"/> + <xi:include href="tutorial.xml"/> + <xi:include href="overview.xml"/> + <xi:include href="tasks.xml"/> + <xi:include href="reference.xml"/> + <xi:include href="extending.xml"/> + <xi:include href="faq.xml"/> + + <!-- Appendicies --> +<!-- <xi:include href="architecture.xml"/> --> + +</part> |
