]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/boostdep/doc/src/boostdep.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / boostdep / doc / src / boostdep.qbk
1 [/
2 Copyright 2015 Peter Dimov
3
4 Distributed under the Boost Software License, Version 1.0.
5
6 See accompanying file LICENSE_1_0.txt or copy at
7 http://boost.org/LICENSE_1_0.txt
8 ]
9
10 [article Boostdep
11 [quickbook 1.6]
12 [id boostdep]
13 [copyright 2014, 2015, 2016 Peter Dimov]
14 [license Distributed under the
15 [@http://boost.org/LICENSE_1_0.txt Boost Software License, Version 1.0].
16 ]
17 ]
18
19 [template simplesect[title]
20 [block '''<simplesect><title>'''[title]'''</title>''']]
21
22 [template endsimplesect[]
23 [block '''</simplesect>''']]
24
25 [section Introduction]
26
27 /Boostdep/ is a tool for generating Boost dependency reports. It scans
28 the header or source files of the Boost libraries for `#include`
29 directives, builds a dependency graph from this information and outputs
30 its findings in plain text or HTML.
31
32 [section Modular Boost]
33
34 /Boostdep/ requires the so-called "modular Boost" directory structure.
35
36 If you already have a [@https://svn.boost.org/trac/boost/wiki/ModularBoost
37 modular Boost installation], you can skip this section. Otherwise, read on.
38
39 Boost libraries reside in subdirectories under the =libs= directory. For
40 example, the contents of the Boost.Filesystem library are in =libs/filesystem=.
41 This includes the build scripts (in =libs/filesystem/build=), the source files
42 (in =libs/filesystem/src=), the tests (in =libs/filesystem/test=), the documentation
43 (in =libs/filesystem/doc=), and so on.
44
45 In the past, when Boost used SVN as its version control system, the header files
46 were an exception. The header files of all libraries resided in the =boost= subdirectory,
47 and it wasn't possible to accurately determine which header belonged to which library.
48
49 When Boost moved to Git for version control, header files were moved to their corresponding
50 libraries, into an =include= subdirectory. The header files of Boost.Filesystem are now in
51 =libs/filesystem/include=.
52
53 For compatibility, =boost= is now a "virtual" directory, containing links to the headers.
54 It's maintained automatically by Boost.Build. (The command =b2 headers= creates or recreates
55 the contents of the =boost= directory.)
56
57 This new structure allows /Boostdep/ to determine that, when faced with an
58 `#include <boost/filesystem.hpp>` directive, that this header is part of Boost.Filesystem, and
59 that therefore, the current library being scanned depends on Boost.Filesystem.
60
61 Unfortunately, Boost releases do not have this structure. For backward compatibility, they
62 have an old-style =boost= directory containing all header files, whereas the per-library =include=
63 subdirectories are missing. Therefore, /Boostdep/ will not work with a downloaded Boost release.
64
65 To use /Boostdep/, you will have to clone the Boost Git repository instead. To do that, execute the
66 following command:
67
68 [pre
69 git clone https://github.com/boostorg/boost.git boost
70 ]
71
72 This will download the Boost "superproject" (the master project, without any libraries) and place it
73 into the subdirectory =boost= of the current directory. To override the directory name, pass it as a
74 second argument instead of =boost=:
75
76 [pre
77 git clone https://github.com/boostorg/boost.git /mydir/
78 ]
79
80 You can now =cd= into the newly created directory with
81
82 [pre
83 cd /mydir/
84 ]
85
86 This directory is called the "Boost root". All of the commands below assume that it is the current directory.
87
88 The above =git clone= commands download the default branch of the Boost Git repository, which is =master=.
89 This is the current more-or-less stable version of Boost.
90
91 To verify this, issue the command
92
93 [pre
94 git status
95 ]
96
97 from the Boost root. This will output
98
99 [pre
100 # On branch master
101 nothing to commit, working directory clean
102 ]
103
104 To download a specific release instead, such as 1.58.0, issue the following command after =git clone=, from
105 the Boost root:
106
107 [pre
108 git checkout boost-1.58.0
109 ]
110
111 =git status= will now say
112
113 [pre
114 # HEAD detached at boost-1.58.0
115 nothing to commit, working directory clean
116 ]
117
118 Then, download all the libraries:
119
120 [pre
121 git submodule update --init
122 ]
123
124 This step will take a while.
125
126 If all goes well, you will now have the complete contents of Boost's latest =master= branch (if you didn't =checkout=
127 a specific release by name) or the corresponding Boost release (if you did).
128
129 You can switch between the =master= branch, the =develop= (unstable) branch, and a release, by issuing the following
130 commands:
131
132 [:For the =master= branch:]
133
134 [pre
135 git checkout master
136 git pull
137 git submodule update --init
138 ]
139
140 [:(=git pull= updates your local copy of the =master= branch from the server, in case it has changed since your initial
141 checkout.)]
142
143 [:For the =develop= branch:]
144
145 [pre
146 git checkout develop
147 git pull
148 git submodule update --init
149 ]
150
151 [:For the =boost-1.58.0= release:]
152
153 [pre
154 git checkout boost-1.58.0
155 git submodule update --init
156 ]
157
158 [:For the =boost-1.57.0= release:]
159
160 [pre
161 git checkout boost-1.57.0
162 git submodule update --init
163 ]
164
165 Note that, while the initial =git submodule update= is quite slow, as it needs to download all the libraries, the
166 subsequent invocations are a lot faster.
167
168 Also note that if a new Boost library (=libs/convert=, for example) is present in, say, =master=, and you have it checked out,
169 when you later switch to =boost-1.58.0=, where this library doesn't exist, Git will not delete =libs/convert=. In this case,
170 =git status= will output
171
172 [pre
173 # HEAD detached at boost-1.58.0
174 # Untracked files:
175 # (use "git add <file>..." to include in what will be committed)
176 #
177 # libs/convert/
178 nothing added to commit but untracked files present (use "git add" to track)
179 ]
180
181 and you will have to remove =libs/convert= by hand.
182
183 Once you have the Boost contents which you want to analyze for dependencies, proceed with the next step, building /Boostdep/.
184
185 [endsect]
186
187 [section Building Boostdep]
188
189 To build /Boostdep/, issue the following command from the Boost root:
190
191 [pre
192 b2 tools/boostdep/build//install
193 ]
194
195 This will build /Boostdep/ from source using the default "toolset" (a Boost.Build term meaning "compiler") and if successful,
196 place it into the =dist/bin= subdirectory. The command assumes that =b2= (the Boost.Build executable) is somewhere in your path.
197 If you don't have =b2=, execute
198
199 [pre
200 .\bootstrap
201 ]
202
203 under Windows or
204
205 [pre
206 ./bootstrap.sh
207 ]
208
209 under Unix-like systems, which should build =b2= and place it into the current directory. You can then use =./b2= instead of =b2=.
210
211 [endsect]
212
213 [section Running Boostdep]
214
215 Once you have built /Boostdep/, execute it with the following command:
216
217 [pre
218 dist/bin/boostdep
219 ]
220
221 or
222
223 [pre
224 dist\bin\boostdep
225 ]
226
227 on Windows. The commands below are given as using =dist/bin/boostdep=; if you're using Windows, use =dist\bin\boostdep= instead.
228
229 This will print out the following help message:
230
231 [pre
232 Usage:
233
234 boostdep --list-modules
235 boostdep --list-buildable
236 boostdep \[--track-sources\] --list-dependencies
237
238 boostdep \[options\] --module-overview
239 boostdep \[options\] --module-levels
240 boostdep \[options\] --module-weights
241
242 boostdep \[options\] \[--primary\] <module>
243 boostdep \[options\] --secondary <module>
244 boostdep \[options\] --reverse <module>
245 boostdep \[options\] --subset <module>
246 boostdep \[options\] \[--header\] <header>
247
248 \[options\]: \[--track-sources\] \[--title <title>\] \[--footer <footer>\] \[--html\]
249 ]
250
251 (The 1.58.0 version of /Boostdep/ has an unfortunate bug that causes the above output to be truncated after =boostdep --list-modules=.
252 The rest of the functionality is intact though, so you can still use it as described.)
253
254 [endsect]
255
256 [endsect]
257
258 [section Usage]
259
260 [section Simple Queries]
261
262 To list the dependencies of a specific library, use the command
263
264 [pre
265 dist/bin/boostdep /library/
266 ]
267
268 For Boost.Filesystem, for example, type
269
270 [pre
271 dist/bin/boostdep filesystem
272 ]
273
274 This will print out something similar to the following:
275
276 [pre
277 Primary dependencies for filesystem:
278
279 assert:
280 <boost/assert.hpp>
281 from <boost/filesystem/operations.hpp>
282 from <boost/filesystem/path_traits.hpp>
283
284 config:
285 <boost/config.hpp>
286 from <boost/filesystem/config.hpp>
287 from <boost/filesystem/convenience.hpp>
288 from <boost/filesystem/fstream.hpp>
289 from <boost/filesystem/operations.hpp>
290 from <boost/filesystem/path.hpp>
291 from <boost/filesystem/path_traits.hpp>
292 /.../
293
294 functional:
295 <boost/functional/hash_fwd.hpp>
296 from <boost/filesystem/path.hpp>
297
298 io:
299 <boost/io/detail/quoted_manip.hpp>
300 from <boost/filesystem/path.hpp>
301
302 iterator:
303 <boost/iterator/iterator_facade.hpp>
304 from <boost/filesystem/path.hpp>
305 /.../
306 ]
307
308 This lists the immediate dependencies of Boost.Filesystem. =assert:= is the library,
309 =<boost/assert.hpp>= is the file that is being included, and =from <boost/filesystem/config.hpp>=
310 shows where =<boost/assert.hpp>= is being included.
311
312 /Boostdep/ names libraries (or modules) after their directory name. The =libs/filesystem=
313 directory, for example, is the =filesystem= module. The =libs/numeric/conversion= directory
314 is the =numeric~conversion= module, according to the /Boostdep/ naming convention.
315
316 The reason forward slashes are replaced with tildes is that =numeric~conversion= is a valid
317 file name, which makes generating HTML reports a bit easier.
318
319 To see where a given header resides and who includes it, type
320
321 [pre
322 dist/bin/boostdep /header/
323 ]
324
325 For =boost/filesystem.hpp=, for example, type
326
327 [pre
328 dist/bin/boostdep boost/filesystem.hpp
329 ]
330
331 This will print something along the lines of
332
333 [pre
334 Inclusion report for <boost/filesystem.hpp> (in module filesystem):
335
336 from spirit:
337 <boost/spirit/home/x3/support/utility/testing.hpp>
338 ]
339
340 What this tells you is that =boost/filesystem.hpp= is part of Boost.Filesystem and is only
341 included once, from =<boost/spirit/home/x3/support/utility/testing.hpp>=. Other headers,
342 such as =boost/shared_ptr.hpp=, are more widely used, as you can see if you try
343
344 [pre
345 dist/bin/boostdep boost/shared_ptr.hpp
346 ]
347
348 To print the reverse dependencies of a library, use
349
350 [pre
351 dist/bin/boostdep --reverse /library/
352 ]
353
354 For example,
355
356 [pre
357 dist/bin/boostdep --reverse filesystem
358 ]
359
360 will list which libraries depend on Boost.Filesystem:
361
362 [pre
363 Reverse dependencies for filesystem:
364
365 graph_parallel:
366 <boost/filesystem/operations.hpp>
367 from <boost/graph/distributed/adjlist/serialization.hpp>
368 <boost/filesystem/path.hpp>
369 from <boost/graph/distributed/adjlist/serialization.hpp>
370
371 log:
372 <boost/filesystem/config.hpp>
373 from <boost/log/detail/config.hpp>
374 <boost/filesystem/path.hpp>
375 from <boost/log/sinks/event_log_backend.hpp>
376 from <boost/log/sinks/text_file_backend.hpp>
377 from <boost/log/sinks/text_multifile_backend.hpp>
378
379 spirit:
380 <boost/filesystem.hpp>
381 from <boost/spirit/home/x3/support/utility/testing.hpp>
382 <boost/filesystem/fstream.hpp>
383 from <boost/spirit/home/x3/support/utility/testing.hpp>
384 <boost/filesystem/path.hpp>
385 from <boost/spirit/home/x3/support/utility/error_reporting.hpp>
386
387 wave:
388 <boost/filesystem/operations.hpp>
389 from <boost/wave/util/cpp_include_paths.hpp>
390 from <boost/wave/util/cpp_iterator.hpp>
391 from <boost/wave/util/filesystem_compatibility.hpp>
392 <boost/filesystem/path.hpp>
393 from <boost/wave/cpp_context.hpp>
394 from <boost/wave/util/cpp_include_paths.hpp>
395 from <boost/wave/util/cpp_iterator.hpp>
396 from <boost/wave/util/cpp_macromap.hpp>
397 from <boost/wave/util/filesystem_compatibility.hpp>
398 ]
399
400 [endsect]
401
402 [section HTML reports]
403
404 The primary purpose of /Boostdep/ is to generate HTML dependency reports. In
405 the typical case, two types of reports are generated: overviews that contain
406 information for all modules, and per-module ones that list information for a
407 specific library.
408
409 /Boostdep/ can generate three types of the first kind of report: module overview,
410 module levels and module weights. To generate a module overview, use the command
411
412 [pre
413 dist/bin/boostdep --html --module-overview > module-overview.html
414 ]
415
416 For a module level report, use
417
418 [pre
419 dist/bin/boostdep --html --module-levels > module-levels.html
420 ]
421
422 For a module weight report, use
423
424 [pre
425 dist/bin/boostdep --html --module-weights > module-weights.html
426 ]
427
428 In these reports, module names such as /module/ are HTML links to [^/module/.html].
429
430 To make these links work as expected, you can generate HTML reports for each module
431 as follows:
432
433 [pre
434 dist/bin/boostdep --title "Dependency Report for /module/" --html --primary /module/ --secondary /module/ --reverse /module/ > /module/.html
435 ]
436
437 This step can be automated if you generate a module list first with
438
439 [pre
440 dist/bin/boostdep --list-modules > list-modules.txt
441 ]
442
443 that will contain one module name per line, and then use a script to issue the previous
444 command for each module name.
445
446 For more information about the /Boostdep/ options and commands, see the [link boostdep.reference Reference] section.
447
448 For an example of a report generation script, see the file =tools/boostdep/examples/report.bat=.
449 This is a Windows batch file, but translating it to a Unix-style shell script should be
450 straightforward.
451
452 For convenience, the contents of =tools/boostdep/examples/report.bat= are given below:
453
454 [pre
455 SET BOOSTDEP=dist\bin\boostdep.exe
456
457 FOR /f %%i IN ('git rev-parse HEAD') DO @SET REV=%%i
458
459 FOR /f %%i IN ('git rev-parse --short HEAD') DO @SET SHREV=%%i
460
461 FOR /f %%i IN ('git rev-parse --abbrev-ref HEAD') DO @SET BRANCH=%%i
462
463 SET FOOTER=Generated on %DATE% %TIME% from revision %REV% on branch '%BRANCH%'
464
465 SET OUTDIR=..\report-%BRANCH%-%SHREV%
466
467 mkdir %OUTDIR%
468
469 %BOOSTDEP% --list-modules > %OUTDIR%\list-modules.txt
470
471 %BOOSTDEP% --footer "%FOOTER%" --html --module-overview > %OUTDIR%\module-overview.html
472 %BOOSTDEP% --footer "%FOOTER%" --html --module-levels > %OUTDIR%\module-levels.html
473 %BOOSTDEP% --footer "%FOOTER%" --html --module-weights > %OUTDIR%\module-weights.html
474
475 FOR /f %%i IN (%OUTDIR%\list-modules.txt) DO %BOOSTDEP% --title "Dependency Report for %%i" --footer "%FOOTER%" --html --primary %%i --secondary %%i --reverse %%i > %OUTDIR%\%%i.html
476 ]
477
478 [endsect]
479
480 [endsect]
481
482 [section Reference]
483
484 [section --list-modules]
485 =boostdep --list-modules= prints the module list. /Boostdep/ considers a
486 subdirectory of =libs= a module if it contains an =include= subdirectory.
487
488 This command is typically used from scripts which then use the list to execute
489 a command for each module.
490 [endsect]
491
492 [section --list-buildable]
493 =boostdep --list-buildable= prints a list of the modules that require building.
494 /Boostdep/ considers a module to require building if it contains subdirectories
495 named =build= and =src=.
496
497 This command is typically used from scripts.
498
499 [endsect]
500
501 [section --list-dependencies]
502 =boostdep --list-dependencies= prints a module list in which each line is of the
503 form
504
505 [pre
506 module -> dependency1 dependency2 /.../
507 ]
508
509 By default, only the =include= directory is scanned for `#include` directives. If
510 the option =--track-sources= is given, the =src= directory is also scanned.
511
512 This command is typically used from scripts. The output is virtually identical to
513 =--module-overview= in plain text, but slightly more machine-friendly.
514 [endsect]
515
516 [section --module-overview]
517 =boostdep --module-overview= generates a module overview, in plain text or HTML. The
518 plain text output is of the form
519
520 [pre
521 Module Overview:
522
523 accumulators -> array assert circular_buffer concept_check config core fusion iterator mpl numeric~conversion numeric~ublas parameter preprocessor range static_assert throw_exception tuple type_traits typeof
524 algorithm -> array assert bind concept_check config core exception function iterator mpl range regex static_assert tuple type_traits unordered
525 align -> assert config core static_assert throw_exception
526 ]
527
528 whereas the HTML output is similar to
529
530 [:
531 *Module Overview*
532
533 [*/accumulators/]
534
535 \u21E2 array assert circular_buffer concept_check config core fusion iterator mpl numeric~conversion numeric~ublas parameter preprocessor range static_assert throw_exception tuple type_traits typeof
536 ]
537
538 where /accumulators/ is a link to =accumulators.html=.
539
540 As before, if =--track-sources= is given, the =src= subdirectory is scanned for `#include` directives.
541
542 HTML output is enabled by the =--html= option. The =--title= and =--footer= options set the HTML =<title>=
543 and the page footer and need to precede =--html=, like in the following example:
544
545 [pre
546 dist/bin/boostdep --title "Module Overview" --footer "Generated on 21.05.2015 20:53:11" --html --module-overview > module-overview.html
547 ]
548
549 [endsect]
550
551 [section --module-levels]
552
553 =boostdep --module-levels= generates a report that groups modules by level. Levels are determined in such
554 a way so that a module of level =N= never depends on modules of levels greater than =N=, and in the absence
555 of cyclic dependencies, doesn't depend on other modules of level =N=. It takes the same options as
556 =--module-overview=.
557
558 [pre
559 dist/bin/boostdep --title "Module Levels" --footer "Generated on 21.05.2015 20:53:11" --html --module-levels > module-levels.html
560 ]
561
562 [endsect]
563
564 [section --module-weights]
565
566 =boostdep --module-weights= generates a report that lists modules by weight. A module weight is the total number of
567 its dependencies. This includes the indirect dependencies.
568
569 =--module-weights= takes the same options as =--module-overview=.
570
571 [pre
572 dist/bin/boostdep --title "Module Weights" --footer "Generated on 21.05.2015 20:53:11" --html --module-weights > module-weights.html
573 ]
574
575 [endsect]
576
577 [section --primary]
578
579 [^boostdep --primary /module/] lists the primary (direct) dependencies of /module/. It takes the same options as =--module-overview=.
580
581 [pre
582 dist/bin/boostdep --title "Primary Dependencies of filesystem" --footer "Generated on 21.05.2015 20:53:11" --html --primary filesystem > filesystem-primary.html
583 ]
584
585 [endsect]
586
587 [section --secondary]
588
589 [^boostdep --secondary /module/] lists the secondary (indirect) dependencies of /module/. It takes the same options as =--module-overview=.
590
591 [pre
592 dist/bin/boostdep --title "Secondary Dependencies of filesystem" --footer "Generated on 21.05.2015 20:53:11" --html --secondary filesystem > filesystem-secondary.html
593 ]
594
595 You can combine =--primary= and =--secondary= in one invocation.
596
597 [pre
598 dist/bin/boostdep --title "Dependencies of filesystem" --footer "Generated on 21.05.2015 20:53:11" --html --primary filesystem --secondary filesystem > filesystem.html
599 ]
600
601 [endsect]
602
603 [section --reverse]
604
605 [^boostdep --reverse /module/] lists the reverse dependencies of /module/, that is, it lists which modules depend on /module/. It takes the same options as =--module-overview=.
606
607 [pre
608 dist/bin/boostdep --title "Reverse Dependencies of filesystem" --footer "Generated on 21.05.2015 20:53:11" --html --reverse filesystem > filesystem-reverse.html
609 ]
610
611 You can combine =--reverse= with =--primary= and =--secondary= for a complete module report.
612
613 [pre
614 dist/bin/boostdep --title "Dependency Report for filesystem" --footer "Generated on 21.05.2015 20:53:11" --html --primary filesystem --secondary filesystem --reverse filesystem > filesystem.html
615 ]
616
617 [endsect]
618
619 [section --subset]
620
621 [^boostdep --subset /module/] lists the subset dependencies of /module/, that is, it lists which modules comprise the subset which /module/ requires in order to be usable.
622 The dependencies are determined by tracing the =#include= directives starting from /module/'s headers.
623
624 The difference between using the modules reported by =--subset= and those reported by the sum of =--primary= and =--secondary= is that the former only guarantees
625 that /module/ will be usable, whereas the latter guarantees it for every module in the subset.
626
627 =--subset= takes the same options as =--module-overview=.
628
629 [pre
630 dist/bin/boostdep --title "Subset Dependencies of filesystem" --footer "Generated on 21.05.2015 20:53:11" --html --subset filesystem > filesystem-subset.html
631 ]
632
633 You can combine =--subset= with the other module report options.
634
635 [endsect]
636
637 [section --header]
638
639 [^boostdep --header /header/] creates an inclusion report for /header/. It takes the same options as =--module-overview=.
640
641 [pre
642 dist/bin/boostdep --title "Inclusion Report for <boost/shared_ptr.hpp>" --footer "Generated on 21.05.2015 20:53:11" --html --header boost/shared_ptr.hpp > header-boost-shared_ptr.html
643 ]
644
645 [endsect]
646
647 [section --track-sources]
648
649 The =--track-sources= option instructs /Boostdep/ to scan the =src= library subdirectory for `#include` directives. By default,
650 only the =include= subdirectory is scanned.
651
652 [endsect]
653
654 [section --title]
655
656 [^--title /title/] sets the contents of the HTML =<title>= tag. It must precede =--html= to have an effect.
657
658 [endsect]
659
660 [section --footer]
661
662 [^--footer /footer/] sets the page footer text. It has no effect if =--html= is not given.
663
664 [endsect]
665
666 [section --html]
667
668 =--html= switches to HTML output mode (the default is plain text). It must precede the commands that generate output.
669
670 [endsect]
671
672 [endsect]