1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <!DOCTYPE chapter PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" |
---|
3 | "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> |
---|
4 | |
---|
5 | <chapter id="bbv2.reference"> |
---|
6 | <title>Detailed reference</title> |
---|
7 | |
---|
8 | <section id="bbv2.reference.general"> |
---|
9 | <title>General information</title> |
---|
10 | |
---|
11 | <section id="bbv2.reference.init"> |
---|
12 | <title>Initialization</title> |
---|
13 | |
---|
14 | <para>bjam's first job upon startup is to load the Jam code that |
---|
15 | implements the build system. To do this, it searches for a file |
---|
16 | called <filename>boost-build.jam</filename>, first in the invocation directory, then |
---|
17 | in its parent and so forth up to the filesystem root, and finally |
---|
18 | in the directories specified by the environment variable |
---|
19 | BOOST_BUILD_PATH. When found, the file is interpreted, and should |
---|
20 | specify the build system location by calling the boost-build |
---|
21 | rule:</para> |
---|
22 | |
---|
23 | <programlisting> |
---|
24 | rule boost-build ( location ? ) |
---|
25 | </programlisting> |
---|
26 | |
---|
27 | <para> |
---|
28 | If location is a relative path, it is treated as relative to |
---|
29 | the directory of <filename>boost-build.jam</filename>. The directory specified by |
---|
30 | that location and the directories in BOOST_BUILD_PATH are then searched for |
---|
31 | a file called <filename>bootstrap.jam</filename>, which is expected to |
---|
32 | bootstrap the build system. This arrangement allows the build |
---|
33 | system to work without any command-line or environment variable |
---|
34 | settings. For example, if the build system files were located in a |
---|
35 | directory "build-system/" at your project root, you might place a |
---|
36 | <filename>boost-build.jam</filename> at the project root containing: |
---|
37 | |
---|
38 | <programlisting> |
---|
39 | boost-build build-system ; |
---|
40 | </programlisting> |
---|
41 | |
---|
42 | In this case, running bjam anywhere in the project tree will |
---|
43 | automatically find the build system.</para> |
---|
44 | |
---|
45 | <para>The default <filename>bootstrap.jam</filename>, after loading some standard |
---|
46 | definitions, loads two files, which can be provided/customised by |
---|
47 | user: <filename>site-config.jam</filename> and <filename>user-config.jam</filename>.</para> |
---|
48 | |
---|
49 | <para>Locations where those files a search are summarized below:</para> |
---|
50 | |
---|
51 | <table id="bbv2.reference.init.config"> |
---|
52 | <title>Search paths for configuration files</title> |
---|
53 | |
---|
54 | <tgroup cols="3"> |
---|
55 | <thead> |
---|
56 | |
---|
57 | <row> |
---|
58 | <entry></entry> |
---|
59 | |
---|
60 | <entry>site-config.jam</entry> |
---|
61 | |
---|
62 | <entry>user-config.jam</entry> |
---|
63 | </row> |
---|
64 | |
---|
65 | </thead> |
---|
66 | <tbody> |
---|
67 | |
---|
68 | <row> |
---|
69 | <entry>Linux</entry> |
---|
70 | |
---|
71 | <entry> |
---|
72 | <simpara><code>/etc</code></simpara> |
---|
73 | <simpara><code>$HOME</code></simpara> |
---|
74 | <simpara><code>$BOOST_BUILD_PATH</code></simpara> |
---|
75 | </entry> |
---|
76 | |
---|
77 | <entry> |
---|
78 | <simpara><code>$HOME</code></simpara> |
---|
79 | <simpara><code>$BOOST_BUILD_PATH</code></simpara> |
---|
80 | </entry> |
---|
81 | </row> |
---|
82 | |
---|
83 | <row> |
---|
84 | <entry>Windows</entry> |
---|
85 | |
---|
86 | <entry> |
---|
87 | <simpara><code>%SystemRoot%</code></simpara> |
---|
88 | <simpara><code>%HOMEDRIVE%%HOMEPATH%</code></simpara> |
---|
89 | <simpara><code>%HOME%</code></simpara> |
---|
90 | <simpara><code>%BOOST_BUILD_PATH%</code></simpara> |
---|
91 | </entry> |
---|
92 | |
---|
93 | <entry> |
---|
94 | <simpara><code>%HOMEDRIVE%%HOMEPATH%</code></simpara> |
---|
95 | <simpara><code>%HOME%</code></simpara> |
---|
96 | <simpara><code>%BOOST_BUILD_PATH%</code></simpara> |
---|
97 | </entry> |
---|
98 | </row> |
---|
99 | </tbody> |
---|
100 | </tgroup> |
---|
101 | </table> |
---|
102 | |
---|
103 | <para> |
---|
104 | Boost.Build comes with default versions of those files, |
---|
105 | <!-- Where are those files installed? The user can't use them as templates unless she can find them --> |
---|
106 | which can serve as templates for customized versions. |
---|
107 | </para> |
---|
108 | |
---|
109 | </section> |
---|
110 | <section id="bbv2.reference.commandline"> |
---|
111 | <title>Command line</title> |
---|
112 | |
---|
113 | <para>The command line may contain:</para> |
---|
114 | |
---|
115 | <itemizedlist> |
---|
116 | <listitem><simpara>Jam options,</simpara></listitem> |
---|
117 | |
---|
118 | <listitem><simpara>Boost.Build <link linkend= |
---|
119 | "bbv2.reference.init.options">options</link>,</simpara></listitem> |
---|
120 | |
---|
121 | <listitem><simpara>Command line arguments</simpara></listitem> |
---|
122 | </itemizedlist> |
---|
123 | |
---|
124 | <section id="bbv2.reference.init.args"> |
---|
125 | <title>Command line arguments</title> |
---|
126 | |
---|
127 | <para> |
---|
128 | Command line arguments specify targets and build |
---|
129 | request using the following rules. |
---|
130 | </para> |
---|
131 | |
---|
132 | <itemizedlist> |
---|
133 | <listitem> |
---|
134 | <simpara> |
---|
135 | An argument that does not contain slashes or the <code>=</code> |
---|
136 | symbol is either a value of an implicit feature or of a target to |
---|
137 | be built. It is taken to be value of a feature if an appropriate |
---|
138 | feature exists. Otherwise, it is considered a <link linkend= |
---|
139 | "bbv2.reference.ids">target id</link>. Building the |
---|
140 | special target name “clean” has the same effect as |
---|
141 | using the <code>--clean</code> option. |
---|
142 | </simpara> |
---|
143 | </listitem> |
---|
144 | |
---|
145 | <listitem> |
---|
146 | <para> |
---|
147 | An argument containing either slashes or |
---|
148 | the <code>=</code> symbol specifies a number of build |
---|
149 | request elements (see <xref |
---|
150 | linkend="bbv2.reference.buildreq"/>). In its simplest |
---|
151 | form, it's just a set of properties, separated by |
---|
152 | slashes, which become a single build request element, |
---|
153 | for example: |
---|
154 | |
---|
155 | <programlisting> |
---|
156 | borland/<runtime-link>static |
---|
157 | </programlisting> |
---|
158 | |
---|
159 | A more complex form can be used to save typing. For example, |
---|
160 | instead of |
---|
161 | |
---|
162 | <programlisting> |
---|
163 | borland/runtime-link=static borland/runtime-link=dynamic |
---|
164 | </programlisting> |
---|
165 | |
---|
166 | one can use |
---|
167 | |
---|
168 | <programlisting> |
---|
169 | borland/runtime-link=static,dynamic |
---|
170 | </programlisting> |
---|
171 | |
---|
172 | Exactly, the conversion from argument to build request |
---|
173 | elements is performed by (1) splitting the argument at each slash, |
---|
174 | (2) converting each split part into a set of properties and (3) |
---|
175 | taking all possible combinations |
---|
176 | <!-- Be specific. Do you mean the cross-product? --> |
---|
177 | of the property sets. Each split |
---|
178 | part should have the either the form |
---|
179 | |
---|
180 | <programlisting> |
---|
181 | <emphasis>feature-name</emphasis>=<emphasis>feature-value1</emphasis>[","<emphasis>feature-valueN</emphasis>]* |
---|
182 | </programlisting> |
---|
183 | |
---|
184 | or, in case of implicit features |
---|
185 | |
---|
186 | <programlisting> |
---|
187 | <emphasis>feature-value1</emphasis>[","<emphasis>feature-valueN</emphasis>;]* |
---|
188 | </programlisting> |
---|
189 | |
---|
190 | will be converted into the property set |
---|
191 | |
---|
192 | <programlisting> |
---|
193 | <feature-name>feature-value1 .... <feature-name>feature-valueN |
---|
194 | </programlisting> |
---|
195 | |
---|
196 | <!-- There's absolutely no explanation of how arguments are combined. Fix that. --> |
---|
197 | |
---|
198 | </para> |
---|
199 | </listitem> |
---|
200 | </itemizedlist> |
---|
201 | |
---|
202 | <para> |
---|
203 | For example, the command line |
---|
204 | |
---|
205 | <programlisting> |
---|
206 | target1 debug gcc/runtime-link=dynamic,static |
---|
207 | </programlisting> |
---|
208 | |
---|
209 | would cause target called <literal>target1</literal> to be rebuilt in |
---|
210 | debug mode, except that for gcc, both dynamically and statically |
---|
211 | linked binaries would be created. |
---|
212 | </para> |
---|
213 | |
---|
214 | </section> |
---|
215 | <section id="bbv2.reference.init.options"> |
---|
216 | <title>Command line options</title> |
---|
217 | |
---|
218 | <para>All of the Boost.Build options start with the "--" prefix. |
---|
219 | They are described in the following table.</para> |
---|
220 | |
---|
221 | <table> |
---|
222 | <title>Command line options</title> |
---|
223 | <tgroup cols="2"> |
---|
224 | |
---|
225 | <thead> |
---|
226 | <row> |
---|
227 | <entry>Option</entry> |
---|
228 | |
---|
229 | <entry>Description</entry> |
---|
230 | </row> |
---|
231 | </thead> |
---|
232 | |
---|
233 | <tbody> |
---|
234 | <row> |
---|
235 | <entry><literal>--version</literal></entry> |
---|
236 | |
---|
237 | <entry>Prints information on Boost.Build and Boost.Jam |
---|
238 | versions.</entry> |
---|
239 | </row> |
---|
240 | |
---|
241 | <row id="bbv2.reference.init.options.help"> |
---|
242 | <entry><literal>--help</literal></entry> |
---|
243 | |
---|
244 | <entry>Access to the online help system. This prints general |
---|
245 | information on how to use the help system with additional |
---|
246 | --help* options.</entry> |
---|
247 | </row> |
---|
248 | |
---|
249 | <row> |
---|
250 | <entry><literal>--clean</literal></entry> |
---|
251 | |
---|
252 | <entry>Removes everything instead of building. Unlike |
---|
253 | <literal>clean</literal> target in make, it is possible to clean only |
---|
254 | some targets.</entry> |
---|
255 | </row> |
---|
256 | |
---|
257 | <row> |
---|
258 | <entry><literal>--debug</literal></entry> |
---|
259 | |
---|
260 | <entry>Enables internal checks.</entry> |
---|
261 | </row> |
---|
262 | |
---|
263 | <row> |
---|
264 | <entry><literal>--dump-projects</literal></entry> |
---|
265 | |
---|
266 | <entry>Cause the project structure to be output.</entry> |
---|
267 | </row> |
---|
268 | |
---|
269 | <row> |
---|
270 | <entry><literal>--no-error-backtrace</literal></entry> |
---|
271 | |
---|
272 | <entry>Don't print backtrace on errors. Primary useful for |
---|
273 | testing.</entry> |
---|
274 | </row> |
---|
275 | |
---|
276 | <row> |
---|
277 | <entry><literal>--ignore-config</literal></entry> |
---|
278 | |
---|
279 | <entry>Do not load <literal>site-config.jam</literal> and |
---|
280 | <literal>user-config.jam</literal></entry> |
---|
281 | </row> |
---|
282 | </tbody> |
---|
283 | </tgroup> |
---|
284 | </table> |
---|
285 | |
---|
286 | </section> |
---|
287 | </section> |
---|
288 | |
---|
289 | |
---|
290 | </section> |
---|
291 | |
---|
292 | <section id="bbv2.reference.jamfiles"> |
---|
293 | <title>Writing Jamfiles</title> |
---|
294 | |
---|
295 | <para>This section describes specific information about writing Jamfiles.</para> |
---|
296 | |
---|
297 | <section id="bbv2.reference.headers"> |
---|
298 | <title>Generated headers</title> |
---|
299 | |
---|
300 | <para>Usually, Boost.Build handles implicit dependendies completely |
---|
301 | automatically. For example, for C++ files, all <literal>#include</literal> |
---|
302 | statements are found and handled. The only aspect where user help |
---|
303 | might be needed is implicit dependency on generated files.</para> |
---|
304 | |
---|
305 | <para>By default, Boost.Build handles such dependencies within one |
---|
306 | main target. For example, assume that main target "app" has two |
---|
307 | sources, "app.cpp" and "parser.y". The latter source is converted |
---|
308 | into "parser.c" and "parser.h". Then, if "app.cpp" includes |
---|
309 | "parser.h", Boost.Build will detect this dependency. Moreover, |
---|
310 | since "parser.h" will be generated into a build directory, the |
---|
311 | path to that directory will automatically added to include |
---|
312 | path.</para> |
---|
313 | |
---|
314 | <para>Making this mechanism work across main target boundaries is |
---|
315 | possible, but imposes certain overhead. For that reason, if |
---|
316 | there's implicit dependency on files from other main targets, the |
---|
317 | <literal><implicit-dependency></literal> [ link ] feature must |
---|
318 | be used, for example:</para> |
---|
319 | |
---|
320 | <programlisting> |
---|
321 | lib parser : parser.y ; |
---|
322 | exe app : app.cpp : <implicit-dependency>parser ; |
---|
323 | </programlisting> |
---|
324 | |
---|
325 | <para> |
---|
326 | The above example tells the build system that when scanning |
---|
327 | all sources of "app" for implicit-dependencies, it should consider |
---|
328 | targets from "parser" as potential dependencies. |
---|
329 | </para> |
---|
330 | </section> |
---|
331 | |
---|
332 | |
---|
333 | </section> |
---|
334 | |
---|
335 | <section id="bbv2.reference.buildprocess"> |
---|
336 | <title>Build process</title> |
---|
337 | |
---|
338 | <para>The general overview of the build process was given in the |
---|
339 | <link linkend="bbv2.advanced.build_process">user documentation</link>. |
---|
340 | This section provides additional details, and some specific rules. |
---|
341 | </para> |
---|
342 | |
---|
343 | <para>To recap, building a target with specific properties includes the |
---|
344 | following steps: |
---|
345 | <orderedlist> |
---|
346 | |
---|
347 | <listitem><para>applying default build,</para></listitem> |
---|
348 | |
---|
349 | <listitem><para>selecting the main target alternative to use, |
---|
350 | </para></listitem> |
---|
351 | |
---|
352 | <listitem><para>determining "common" properties</para></listitem> |
---|
353 | |
---|
354 | <listitem><para>building targets referred by the sources list and |
---|
355 | dependency properties</para></listitem> |
---|
356 | |
---|
357 | <listitem><para>adding the usage requirements produces when building |
---|
358 | dependencies to the "common" properties</para></listitem> |
---|
359 | |
---|
360 | <listitem><para>building the target using generators</para></listitem> |
---|
361 | |
---|
362 | <listitem><para>computing the usage requirements to be returned</para></listitem> |
---|
363 | |
---|
364 | </orderedlist> |
---|
365 | </para> |
---|
366 | |
---|
367 | <section id="bbv2.reference.buildprocess.alternatives"> |
---|
368 | <title>Alternative selection</title> |
---|
369 | |
---|
370 | <para>When there are several alternatives, one of them must be |
---|
371 | selected. The process is as follows:</para> |
---|
372 | |
---|
373 | <orderedlist> |
---|
374 | <listitem> |
---|
375 | <simpara> |
---|
376 | For each alternative <emphasis>condition</emphasis> is defined |
---|
377 | as the set of base properies in requirements. [Note: it might be |
---|
378 | better to specify the condition explicitly, as in |
---|
379 | conditional requirements]. |
---|
380 | </simpara> |
---|
381 | </listitem> |
---|
382 | |
---|
383 | <listitem> |
---|
384 | <simpara> |
---|
385 | An alternative is viable only if all properties in condition |
---|
386 | are present in build request. |
---|
387 | </simpara> |
---|
388 | </listitem> |
---|
389 | |
---|
390 | <listitem> |
---|
391 | <simpara> |
---|
392 | If there's one viable alternative, it's choosen. Otherwise, |
---|
393 | an attempt is made to find one best alternative. An alternative |
---|
394 | a is better than another alternative b, iff set of properties |
---|
395 | in b's condition is strict subset of the set of properities of |
---|
396 | 'a's condition. If there's one viable alternative, which is |
---|
397 | better than all other, it's selected. Otherwise, an error is |
---|
398 | reported. |
---|
399 | </simpara> |
---|
400 | </listitem> |
---|
401 | </orderedlist> |
---|
402 | |
---|
403 | </section> |
---|
404 | |
---|
405 | <section id="bbv2.reference.buildprocess.common"> |
---|
406 | <title>Determining common properties</title> |
---|
407 | |
---|
408 | <para>The "common" properties is a somewhat artificial term. Those are |
---|
409 | the intermediate property set from which both the build request for |
---|
410 | dependencies and properties for building the target are derived. |
---|
411 | </para> |
---|
412 | |
---|
413 | <para>Since default build and alternatives are already handled, we have |
---|
414 | only two inputs: build requests and requirements. Here are the rules |
---|
415 | about common properties. |
---|
416 | </para> |
---|
417 | |
---|
418 | <orderedlist> |
---|
419 | <listitem><para>Non-free feature can have only one |
---|
420 | value</para></listitem> |
---|
421 | |
---|
422 | <listitem><para>A non-conditional property in requirement in always |
---|
423 | present in common properties.</para></listitem> |
---|
424 | |
---|
425 | <listitem><para>A property in build request is present in |
---|
426 | common properties, unless (2) tells otherwise.</para></listitem> |
---|
427 | |
---|
428 | <listitem><para>If either build request, or requirements (non-conditional |
---|
429 | or conditional) include an expandable property (either composite, |
---|
430 | or property with specified subfeature value), the behaviour is |
---|
431 | equivalent to explicitly adding all expanded properties to build |
---|
432 | request or requirements.</para></listitem> |
---|
433 | |
---|
434 | <listitem><para>If requirements include a conditional property, and |
---|
435 | condiiton of this property is true in context of common |
---|
436 | properties, then the conditional property should be in common |
---|
437 | properties as well.</para></listitem> |
---|
438 | |
---|
439 | <listitem><para>If no value for a feature is given by other rules |
---|
440 | here, it has default value in common properties.</para></listitem> |
---|
441 | </orderedlist> |
---|
442 | |
---|
443 | <para>Those rules are declarative, they don't specify how to compute the |
---|
444 | common properties. However, they provide enough information for the |
---|
445 | user. The important point is the handling of conditional |
---|
446 | requirements. The condition can be satisfied either by property in |
---|
447 | build request, by non-conditional requirements, or even by another |
---|
448 | conditional property. For example, the following example works as |
---|
449 | expected: |
---|
450 | <programlisting> |
---|
451 | exe a : a.cpp |
---|
452 | : <toolset>gcc:<variant>release |
---|
453 | <variant>release:<define>FOO ; |
---|
454 | </programlisting> |
---|
455 | </para> |
---|
456 | |
---|
457 | </section> |
---|
458 | |
---|
459 | </section> |
---|
460 | |
---|
461 | |
---|
462 | |
---|
463 | <section id="bbv2.reference.definitions"> |
---|
464 | |
---|
465 | <title>Definitions</title> |
---|
466 | |
---|
467 | <section id="bbv2.reference.features"> |
---|
468 | <title>Features and properties</title> |
---|
469 | |
---|
470 | <para>A <emphasis>feature</emphasis> is a normalized (toolset-independent) |
---|
471 | aspect of a build configuration, such as whether inlining is |
---|
472 | enabled. Feature names may not contain the '<literal>></literal>' |
---|
473 | character.</para> |
---|
474 | |
---|
475 | <!-- |
---|
476 | And what about dash? |
---|
477 | --> |
---|
478 | |
---|
479 | <para>Each feature in a build configuration has one or more |
---|
480 | associated <emphasis>value</emphasis>s. Feature values for non-free features |
---|
481 | may not contain the '<literal><</literal>', '<literal>:</literal>', or |
---|
482 | '<literal>=</literal>' characters. Feature values for free features may not |
---|
483 | contain the '<literal><</literal>' character.</para> |
---|
484 | |
---|
485 | <para>A <emphasis>property</emphasis> is a (feature,value) pair, expressed as |
---|
486 | <feature>value.</para> |
---|
487 | |
---|
488 | <para>A <emphasis>subfeature</emphasis> is a feature that only exists in the |
---|
489 | presence of its parent feature, and whose identity can be derived |
---|
490 | (in the context of its parent) from its value. A subfeature's |
---|
491 | parent can never be another subfeature. Thus, features and their |
---|
492 | subfeatures form a two-level hierarchy.</para> |
---|
493 | |
---|
494 | <para>A <emphasis>value-string</emphasis> for a feature <emphasis role="bold">F</emphasis> is a string of |
---|
495 | the form |
---|
496 | <literal>value-subvalue1-subvalue2</literal>...<literal>-subvalueN</literal>, where |
---|
497 | <literal>value</literal> is a legal value for <emphasis role="bold">F</emphasis> and |
---|
498 | <literal>subvalue1</literal>...<literal>subvalueN</literal> are legal values of some |
---|
499 | of <emphasis role="bold">F</emphasis>'s subfeatures. For example, the properties |
---|
500 | <literal><toolset>gcc <toolset-version>3.0.1</literal> can be |
---|
501 | expressed more conscisely using a value-string, as |
---|
502 | <literal><toolset>gcc-3.0.1</literal>.</para> |
---|
503 | |
---|
504 | <para>A <emphasis>property set</emphasis> is a set of properties (i.e. a |
---|
505 | collection without duplicates), for instance: |
---|
506 | <literal><toolset>gcc <runtime-link>static</literal>.</para> |
---|
507 | |
---|
508 | <para>A <emphasis>property path</emphasis> is a property set whose elements have |
---|
509 | been joined into a single string separated by slashes. A property |
---|
510 | path representation of the previous example would be |
---|
511 | <literal><toolset>gcc/<runtime-link>static</literal>.</para> |
---|
512 | |
---|
513 | <para>A <emphasis>build specification</emphasis> is a property set that fully |
---|
514 | describes the set of features used to build a target.</para> |
---|
515 | |
---|
516 | <section id="bbv2.reference.features.validity"> |
---|
517 | <title>Property Validity</title> |
---|
518 | |
---|
519 | <para> |
---|
520 | For <link linkend= |
---|
521 | "bbv2.reference.features.attributes.free">free</link> |
---|
522 | features, all values are valid. For all other features, |
---|
523 | the valid values are explicitly specified, and the build |
---|
524 | system will report an error for the use of an invalid |
---|
525 | feature-value. Subproperty validity may be restricted so |
---|
526 | that certain values are valid only in the presence of |
---|
527 | certain other subproperties. For example, it is possible |
---|
528 | to specify that the <code><gcc-target>mingw</code> |
---|
529 | property is only valid in the presence of |
---|
530 | <code><gcc-version>2.95.2</code>. |
---|
531 | </para> |
---|
532 | |
---|
533 | </section> |
---|
534 | <section id="bbv2.reference.features.attributes"> |
---|
535 | <title>Feature Attributes</title> |
---|
536 | |
---|
537 | <para>Each feature has a collection of zero or more of the following |
---|
538 | attributes. Feature attributes are low-level descriptions of how the |
---|
539 | build system should interpret a feature's values when they appear in |
---|
540 | a build request. We also refer to the attributes of properties, so |
---|
541 | that an <emphasis>incidental</emphasis> property, for example, is |
---|
542 | one whose feature has the <emphasis>incidental</emphasis> |
---|
543 | attribute.</para> |
---|
544 | |
---|
545 | <itemizedlist> |
---|
546 | <listitem> |
---|
547 | <para><emphasis>incidental</emphasis></para> |
---|
548 | |
---|
549 | <para>Incidental features are assumed not to affect build |
---|
550 | products at all. As a consequence, the build system may use |
---|
551 | the same file for targets whose build specification differs |
---|
552 | only in incidental features. A feature that controls a |
---|
553 | compiler's warning level is one example of a likely |
---|
554 | incidental feature.</para> |
---|
555 | |
---|
556 | <para>Non-incidental features are assumed to affect build |
---|
557 | products, so the files for targets whose build specification |
---|
558 | differs in non-incidental features are placed in different |
---|
559 | directories as described in "target paths" below. [ where? ] |
---|
560 | </para> |
---|
561 | </listitem> |
---|
562 | |
---|
563 | <listitem> |
---|
564 | <para> |
---|
565 | <anchor id="bbv2.reference.features.attributes.propagated"/> |
---|
566 | <emphasis>propagated</emphasis> |
---|
567 | </para> |
---|
568 | |
---|
569 | <para>Features of this kind are |
---|
570 | propagated to dependencies. That is, if a <link linkend= |
---|
571 | "bbv2.advanced.targets.main">main target</link> is built using a |
---|
572 | propagated |
---|
573 | property, the build systems attempts to use the same property |
---|
574 | when building any of its dependencies as part of that main |
---|
575 | target. For instance, when an optimized exectuable is |
---|
576 | requested, one usually wants it to be linked with optimized |
---|
577 | libraries. Thus, the <literal><optimization></literal> feature is |
---|
578 | propagated.</para> |
---|
579 | </listitem> |
---|
580 | |
---|
581 | <listitem> |
---|
582 | <para> |
---|
583 | <anchor id="bbv2.reference.features.attributes.free"/> |
---|
584 | <emphasis>free</emphasis> |
---|
585 | </para> |
---|
586 | |
---|
587 | <para>Most features have a finite set of allowed values, and can |
---|
588 | only take on a single value from that set in a given build |
---|
589 | specification. Free features, on the other hand, can have |
---|
590 | several values at a time and each value can be an arbitrary |
---|
591 | string. For example, it is possible to have several |
---|
592 | preprocessor symbols defined simultaneously:</para> |
---|
593 | |
---|
594 | <programlisting> |
---|
595 | <define>NDEBUG=1 <define>HAS_CONFIG_H=1 |
---|
596 | </programlisting> |
---|
597 | |
---|
598 | </listitem> |
---|
599 | |
---|
600 | <listitem> |
---|
601 | <para><emphasis>optional</emphasis></para> |
---|
602 | |
---|
603 | <para>An optional feature is a feature that is not required to |
---|
604 | appear in a build specification. Every non-optional non-free |
---|
605 | feature has a default value that is used when a value for |
---|
606 | the feature is not otherwise specified, either in a target's |
---|
607 | requirements or in the user's build request. [A feature's |
---|
608 | default value is given by the first value listed in the |
---|
609 | feature's declaration. -- move this elsewhere - dwa]</para> |
---|
610 | </listitem> |
---|
611 | |
---|
612 | <listitem> |
---|
613 | <para><emphasis>symmetric</emphasis></para> |
---|
614 | |
---|
615 | <para>A symmetric feature's default value is not automatically |
---|
616 | included in <link linkend= |
---|
617 | "bbv2.reference.variants">build variants</link>. Normally |
---|
618 | a feature only generates a subvariant directory when its |
---|
619 | value differs from the value specified by the build variant, |
---|
620 | leading to an assymmetric subvariant directory structure for |
---|
621 | certain values of the feature. A symmetric feature, when |
---|
622 | relevant to the toolset, always generates a corresponding |
---|
623 | subvariant directory.</para> |
---|
624 | </listitem> |
---|
625 | |
---|
626 | <listitem> |
---|
627 | <para><emphasis>path</emphasis></para> |
---|
628 | |
---|
629 | <para>The value of a path feature specifies a path. The path is |
---|
630 | treated as relative to the directory of Jamfile where path |
---|
631 | feature is used and is translated appropriately by the build |
---|
632 | system when the build is invoked from a different |
---|
633 | directory</para> |
---|
634 | </listitem> |
---|
635 | |
---|
636 | <listitem> |
---|
637 | <para><emphasis>implicit</emphasis></para> |
---|
638 | |
---|
639 | <para>Values of implicit features alone identify the feature. |
---|
640 | For example, a user is not required to write |
---|
641 | "<toolset>gcc", but can simply write "gcc". Implicit |
---|
642 | feature names also don't appear in variant paths, although |
---|
643 | the values do. Thus: bin/gcc/... as opposed to |
---|
644 | bin/toolset-gcc/.... There should typically be only a few |
---|
645 | such features, to avoid possible name clashes.</para> |
---|
646 | </listitem> |
---|
647 | |
---|
648 | <listitem> |
---|
649 | <para><emphasis>composite</emphasis></para> |
---|
650 | |
---|
651 | <para>Composite features actually correspond to groups of |
---|
652 | properties. For example, a build variant is a composite |
---|
653 | feature. When generating targets from a set of build |
---|
654 | properties, composite features are recursively expanded and |
---|
655 | <emphasis>added</emphasis> to the build property set, so rules can find |
---|
656 | them if necessary. Non-composite non-free features override |
---|
657 | components of composite features in a build property set.</para> |
---|
658 | </listitem> |
---|
659 | |
---|
660 | <listitem> |
---|
661 | <para><emphasis>dependency</emphasis></para> |
---|
662 | |
---|
663 | <para>The value of dependency feature if a target reference. |
---|
664 | When used for building of a main target, the value of |
---|
665 | dependency feature is treated as additional dependency.</para> |
---|
666 | |
---|
667 | <para>For example, dependency features allow to state that |
---|
668 | library A depends on library B. As the result, whenever an |
---|
669 | application will link to A, it will also link to B. |
---|
670 | Specifying B as dependency of A is different from adding B to |
---|
671 | the sources of A. <!-- Need to clarify this. --></para> |
---|
672 | </listitem> |
---|
673 | </itemizedlist> |
---|
674 | |
---|
675 | <para>Features that are neither free nor incidental are called |
---|
676 | <emphasis>base</emphasis> features.</para> |
---|
677 | |
---|
678 | |
---|
679 | </section> |
---|
680 | <section id="bbv2.reference.features.declaration"> |
---|
681 | <title>Feature Declaration</title> |
---|
682 | |
---|
683 | <para>The low-level feature declaration interface is the |
---|
684 | <literal>feature</literal> rule from the |
---|
685 | <literal>feature</literal> module: |
---|
686 | |
---|
687 | <programlisting> |
---|
688 | rule feature ( name : allowed-values * : attributes * ) |
---|
689 | </programlisting> |
---|
690 | |
---|
691 | A feature's allowed-values may be extended with the |
---|
692 | <code>feature.extend</code> rule. |
---|
693 | </para> |
---|
694 | |
---|
695 | </section> |
---|
696 | </section> |
---|
697 | |
---|
698 | <section id="bbv2.reference.variants"> |
---|
699 | <title>Build Variants</title> |
---|
700 | |
---|
701 | <para> |
---|
702 | A build variant, or (simply variant) is a special kind of composite |
---|
703 | feature that automatically incorporates the default values of |
---|
704 | features that . Typically you'll want at least two separate |
---|
705 | variants: one for debugging, and one for your release code. [ |
---|
706 | Volodya says: "Yea, we'd need to mention that it's a composite |
---|
707 | feature and describe how they are declared, in pacticular that |
---|
708 | default values of non-optional features are incorporated into |
---|
709 | build variant automagically. Also, do we wan't some variant |
---|
710 | inheritance/extension/templates. I don't remember how it works in |
---|
711 | V1, so can't document this for V2.". Will clean up soon -DWA ] |
---|
712 | </para> |
---|
713 | |
---|
714 | </section> |
---|
715 | |
---|
716 | <section id="bbv2.reference.variants.proprefine"> |
---|
717 | <title>Property refinement</title> |
---|
718 | |
---|
719 | <para>When a target with certain properties is requested, and that |
---|
720 | target requires some set of properties, it is needed to find the |
---|
721 | set of properties to use for building. This process is called |
---|
722 | <emphasis>property refinement</emphasis> and is performed by these rules</para> |
---|
723 | |
---|
724 | <orderedlist> |
---|
725 | |
---|
726 | <listitem> |
---|
727 | <simpara> |
---|
728 | Each property in the required set is added to the original |
---|
729 | property set |
---|
730 | </simpara> |
---|
731 | </listitem> |
---|
732 | |
---|
733 | <listitem> |
---|
734 | <simpara> |
---|
735 | If the original property set includes property with a different |
---|
736 | value of non free feature, that property is removed. |
---|
737 | </simpara> |
---|
738 | </listitem> |
---|
739 | </orderedlist> |
---|
740 | </section> |
---|
741 | |
---|
742 | <section id="bbv2.reference.variants.propcond"> |
---|
743 | <title>Conditional properties</title> |
---|
744 | |
---|
745 | <para>Sometime it's desirable to apply certain requirements only for |
---|
746 | a specific combination of other properties. For example, one of |
---|
747 | compilers that you use issues a pointless warning that you want to |
---|
748 | suppress by passing a command line option to it. You would not |
---|
749 | want to pass that option to other compilers. Conditional |
---|
750 | properties allow you to do just that. Their syntax is:</para> |
---|
751 | |
---|
752 | <programlisting> |
---|
753 | property ( "," property ) * ":" property |
---|
754 | </programlisting> |
---|
755 | |
---|
756 | <para> |
---|
757 | For example, the problem above would be solved by: |
---|
758 | |
---|
759 | <programlisting> |
---|
760 | exe hello : hello.cpp : <toolset>yfc:<cxxflags>-disable-pointless-warning ; |
---|
761 | </programlisting> |
---|
762 | </para> |
---|
763 | |
---|
764 | <para>The syntax also allows several properties in the condition, for |
---|
765 | example: |
---|
766 | <programlisting> |
---|
767 | exe hello : hello.cpp : <os>NT,<toolset>gcc:<link>static ; |
---|
768 | </programlisting> |
---|
769 | </para> |
---|
770 | |
---|
771 | </section> |
---|
772 | |
---|
773 | <section id="bbv2.reference.ids"> |
---|
774 | <title>Target identifiers and references</title> |
---|
775 | |
---|
776 | <para><emphasis>Target identifier</emphasis> is used to denote a |
---|
777 | target. The syntax is:</para> |
---|
778 | |
---|
779 | <programlisting> |
---|
780 | target-id -> (project-id | target-name | file-name ) |
---|
781 | | (project-id | directory-name) "//" target-name |
---|
782 | project-id -> path |
---|
783 | target-name -> path |
---|
784 | file-name -> path |
---|
785 | directory-name -> path |
---|
786 | </programlisting> |
---|
787 | |
---|
788 | <para> |
---|
789 | This grammar allows some elements to be recognized as either |
---|
790 | |
---|
791 | <itemizedlist> |
---|
792 | <listitem> |
---|
793 | <simpara> |
---|
794 | project id (at this point, all project ids start with slash). |
---|
795 | </simpara> |
---|
796 | </listitem> |
---|
797 | |
---|
798 | <listitem> |
---|
799 | <simpara> |
---|
800 | name of target declared in current Jamfile (note that target |
---|
801 | names may include slash). |
---|
802 | </simpara> |
---|
803 | </listitem> |
---|
804 | |
---|
805 | <listitem> |
---|
806 | <simpara> |
---|
807 | a regular file, denoted by absolute name or name relative to |
---|
808 | project's sources location. |
---|
809 | </simpara> |
---|
810 | </listitem> |
---|
811 | </itemizedlist> |
---|
812 | |
---|
813 | To determine the real meaning a check is made if project-id |
---|
814 | by the specified name exists, and then if main target of that |
---|
815 | name exists. For example, valid target ids might be: |
---|
816 | |
---|
817 | <screen> |
---|
818 | a -- target in current project |
---|
819 | lib/b.cpp -- regular file |
---|
820 | /boost/thread -- project "/boost/thread" |
---|
821 | /home/ghost/build/lr_library//parser -- target in specific project |
---|
822 | </screen> |
---|
823 | |
---|
824 | </para> |
---|
825 | |
---|
826 | <para><emphasis role="bold">Rationale:</emphasis>Target is separated from project by special |
---|
827 | separator (not just slash), because:</para> |
---|
828 | |
---|
829 | <itemizedlist> |
---|
830 | <listitem> |
---|
831 | <simpara> |
---|
832 | It emphasises that projects and targets are different things. |
---|
833 | </simpara> |
---|
834 | </listitem> |
---|
835 | |
---|
836 | <listitem> |
---|
837 | <simpara> |
---|
838 | It allows to have main target names with slashes. |
---|
839 | |
---|
840 | <!-- The motivation for which is: |
---|
841 | |
---|
842 | So, to summarize: |
---|
843 | |
---|
844 | 1. The project that extract tarfile may extract all possible kinds |
---|
845 | of targets, and it's reasonable to use them directly from other |
---|
846 | project. |
---|
847 | |
---|
848 | 2. The rule for unpacking tar is inplemented in terms of |
---|
849 | "patch-file", for maintainability, and therefore, must use main |
---|
850 | target name that contains slashes? |
---|
851 | |
---|
852 | 3. Using sub-Jamfile in "foo" to declare extracted file "foo/b" is |
---|
853 | not an option, because you should not change existing tree |
---|
854 | |
---|
855 | That makes good rationale for why main target must contain names. |
---|
856 | --> |
---|
857 | </simpara> |
---|
858 | </listitem> |
---|
859 | </itemizedlist> |
---|
860 | |
---|
861 | <para id="bbv2.reference.targets.references"> |
---|
862 | <emphasis>Target reference</emphasis> is used to |
---|
863 | specify a source target, and may additionally specify desired |
---|
864 | properties for that target. It has this syntax:</para> |
---|
865 | |
---|
866 | <programlisting> |
---|
867 | target-reference -> target-id [ "/" requested-properties ] |
---|
868 | requested-properties -> property-path |
---|
869 | </programlisting> |
---|
870 | |
---|
871 | <para> |
---|
872 | For example, |
---|
873 | |
---|
874 | <programlisting> |
---|
875 | exe compiler : compiler.cpp libs/cmdline/<optimization>space ; |
---|
876 | </programlisting> |
---|
877 | |
---|
878 | would cause the version of <literal>cmdline</literal> library, |
---|
879 | optimized for space, to be linked in even if the |
---|
880 | <literal>compiler</literal> executable is build with optimization for |
---|
881 | speed. |
---|
882 | </para> |
---|
883 | </section> |
---|
884 | |
---|
885 | </section> |
---|
886 | |
---|
887 | <section id="bbv2.reference.generators"> |
---|
888 | <title>Generators</title> |
---|
889 | |
---|
890 | <warning><para>The information is this section is likely to be outdated |
---|
891 | and misleading. |
---|
892 | </para></warning> |
---|
893 | |
---|
894 | <para>To construct a main target with given properties from sources, |
---|
895 | it is required to create a dependency graph for that main target, |
---|
896 | which will also include actions to be run. The algorithm for |
---|
897 | creating the dependency graph is described here.</para> |
---|
898 | |
---|
899 | <para>The fundamental concept is <emphasis>generator</emphasis>. If encapsulates |
---|
900 | the notion of build tool and is capable to converting a set of |
---|
901 | input targets into a set of output targets, with some properties. |
---|
902 | Generator matches a build tool as closely as possible: it works |
---|
903 | only when the tool can work with requested properties (for |
---|
904 | example, msvc compiler can't work when requested toolset is gcc), |
---|
905 | and should produce exactly the same targets as the tool (for |
---|
906 | example, if Borland's linker produces additional files with debug |
---|
907 | information, generator should also).</para> |
---|
908 | |
---|
909 | <para>Given a set of generators, the fundamental operation is to |
---|
910 | construct a target of a given type, with given properties, from a |
---|
911 | set of targets. That operation is performed by rule |
---|
912 | <literal>generators.construct</literal> and the used algorithm is described |
---|
913 | below.</para> |
---|
914 | |
---|
915 | <section> |
---|
916 | <title>Selecting and ranking viable generators</title> |
---|
917 | |
---|
918 | <para>Each generator, in addition to target types that it can |
---|
919 | produce, have attribute that affects its applicability in |
---|
920 | particular sitiation. Those attributes are:</para> |
---|
921 | |
---|
922 | <orderedlist> |
---|
923 | <listitem> |
---|
924 | <simpara> |
---|
925 | Required properties, which are properties absolutely |
---|
926 | necessary for the generator to work. For example, generator |
---|
927 | encapsulating the gcc compiler would have <toolset>gcc as |
---|
928 | required property. |
---|
929 | </simpara> |
---|
930 | </listitem> |
---|
931 | |
---|
932 | <listitem> |
---|
933 | <simpara> |
---|
934 | Optional properties, which increase the generators |
---|
935 | suitability for a particual build. |
---|
936 | </simpara> |
---|
937 | </listitem> |
---|
938 | </orderedlist> |
---|
939 | |
---|
940 | <para> |
---|
941 | Generator's required and optional properties may not include |
---|
942 | either free or incidental properties. (Allowing this would |
---|
943 | greatly complicate caching targets). |
---|
944 | </para> |
---|
945 | |
---|
946 | <para>When trying to construct a target, the first step is to select |
---|
947 | all possible generators for the requested target type, which |
---|
948 | required properties are a subset of requested properties. |
---|
949 | Generators that were already selected up the call stack are |
---|
950 | excluded. In addition, if any composing generators were selected |
---|
951 | up the call stack, all other composing generators are ignored |
---|
952 | (TODO: define composing generators). The found generators |
---|
953 | are assigned a rank, which is the number of optional properties |
---|
954 | present in requested properties. Finally, generators with highest |
---|
955 | rank are selected for futher processing.</para> |
---|
956 | |
---|
957 | </section> |
---|
958 | <section> |
---|
959 | <title>Running generators</title> |
---|
960 | |
---|
961 | <para>When generators are selected, each is run to produce a list of |
---|
962 | created targets. This list might include targets that are not of |
---|
963 | requested types, because generators create the same targets as |
---|
964 | some tool, and tool's behaviour is fixed. (Note: should specify |
---|
965 | that in some cases we actually want extra targets). If generator |
---|
966 | fails, it returns an empty list. Generator is free to call |
---|
967 | 'construct' again, to convert sources to the types it can handle. |
---|
968 | It also can pass modified properties to 'construct'. However, a |
---|
969 | generator is not allowed to modify any propagated properties, |
---|
970 | otherwise when actually consuming properties we might discover |
---|
971 | that the set of propagated properties is different from what was |
---|
972 | used for building sources.</para> |
---|
973 | |
---|
974 | <para>For all targets that are not of requested types, we try to |
---|
975 | convert them to requested type, using a second call to |
---|
976 | <literal>construct</literal>. This is done in order to support |
---|
977 | transformation sequences where single source file expands to |
---|
978 | several later. See <ulink url= |
---|
979 | "http://groups.yahoo.com/group/jamboost/message/1667">this |
---|
980 | message</ulink> for details.</para> |
---|
981 | |
---|
982 | </section> |
---|
983 | |
---|
984 | <section> |
---|
985 | <title>Selecting dependency graph</title> |
---|
986 | |
---|
987 | <para> |
---|
988 | After all generators are run, |
---|
989 | it is necessary to decide which of successfull invocation will be |
---|
990 | taken as final result. At the moment, this is not done. Instead, |
---|
991 | it is checked whether all successfull generator invocation |
---|
992 | returned the same target list. Error is issued otherwise. |
---|
993 | </para> |
---|
994 | |
---|
995 | </section> |
---|
996 | |
---|
997 | <section> |
---|
998 | <title>Property adjustment</title> |
---|
999 | |
---|
1000 | <para>Because target location is determined by the build system, it |
---|
1001 | is sometimes necessary to adjust properties, in order to not |
---|
1002 | break actions. For example, if there's an action that generates |
---|
1003 | a header, say "a_parser.h", and a source file "a.cpp" which |
---|
1004 | includes that file, we must make everything work as if a_parser.h |
---|
1005 | is generated in the same directory where it would be generated |
---|
1006 | without any subvariants.</para> |
---|
1007 | |
---|
1008 | <para>Correct property adjustment can be done only after all targets |
---|
1009 | are created, so the approach taken is:</para> |
---|
1010 | |
---|
1011 | <orderedlist> |
---|
1012 | <listitem> |
---|
1013 | <para> |
---|
1014 | When dependency graph is constructed, each action can be |
---|
1015 | assigned a rule for property adjustment. |
---|
1016 | </para> |
---|
1017 | </listitem> |
---|
1018 | |
---|
1019 | <listitem> |
---|
1020 | <para> |
---|
1021 | When virtual target is actualized, that rule is run and |
---|
1022 | return the final set of properties. At this stage it can use |
---|
1023 | information of all created virtual targets. |
---|
1024 | </para> |
---|
1025 | </listitem> |
---|
1026 | </orderedlist> |
---|
1027 | |
---|
1028 | <para>In case of quoted includes, no adjustment can give 100% correct |
---|
1029 | results. If target dirs are not changed by build system, quoted |
---|
1030 | includes are searched in "." and then in include path, while angle |
---|
1031 | includes are searched only in include path. When target dirs are |
---|
1032 | changed, we'd want to make quoted includes to be search in "." then in |
---|
1033 | additional dirs and then in the include path and make angle includes |
---|
1034 | be searched in include path, probably with additional paths added at |
---|
1035 | some position. Unless, include path already has "." as the first |
---|
1036 | element, this is not possible. So, either generated headers should not |
---|
1037 | be included with quotes, or first element of include path should be |
---|
1038 | ".", which essentially erases the difference between quoted and angle |
---|
1039 | includes. <emphasis role="bold">Note:</emphasis> the only way to get |
---|
1040 | "." as include path into compiler command line is via verbatim |
---|
1041 | compiler option. In all other case, Boost.Build will convert "." into |
---|
1042 | directory where it occurs.</para> |
---|
1043 | |
---|
1044 | </section> |
---|
1045 | |
---|
1046 | <section> |
---|
1047 | <title>Transformations cache</title> |
---|
1048 | |
---|
1049 | <para> |
---|
1050 | Under certain conditions, an |
---|
1051 | attempt is made to cache results of transformation search. First, |
---|
1052 | the sources are replaced with targets with special name and the |
---|
1053 | found target list is stored. Later, when properties, requested |
---|
1054 | type, and source type are the same, the store target list is |
---|
1055 | retrieved and cloned, with appropriate change in names. |
---|
1056 | </para> |
---|
1057 | |
---|
1058 | </section> |
---|
1059 | </section> |
---|
1060 | |
---|
1061 | </chapter> |
---|
1062 | |
---|
1063 | <!-- |
---|
1064 | Local Variables: |
---|
1065 | mode: xml |
---|
1066 | sgml-indent-data: t |
---|
1067 | sgml-parent-document: ("userman.xml" "chapter") |
---|
1068 | sgml-set-face: t |
---|
1069 | End: |
---|
1070 | --> |
---|