]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/boostdep/doc/src/boostdep.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / tools / boostdep / doc / src / boostdep.qbk
CommitLineData
7c673cae
FG
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
28the header or source files of the Boost libraries for `#include`
29directives, builds a dependency graph from this information and outputs
30its findings in plain text or HTML.
31
32[section Modular Boost]
33
34/Boostdep/ requires the so-called "modular Boost" directory structure.
35
36If you already have a [@https://svn.boost.org/trac/boost/wiki/ModularBoost
37modular Boost installation], you can skip this section. Otherwise, read on.
38
39Boost libraries reside in subdirectories under the =libs= directory. For
40example, the contents of the Boost.Filesystem library are in =libs/filesystem=.
41This 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
45In the past, when Boost used SVN as its version control system, the header files
46were an exception. The header files of all libraries resided in the =boost= subdirectory,
47and it wasn't possible to accurately determine which header belonged to which library.
48
49When Boost moved to Git for version control, header files were moved to their corresponding
50libraries, into an =include= subdirectory. The header files of Boost.Filesystem are now in
51=libs/filesystem/include=.
52
53For compatibility, =boost= is now a "virtual" directory, containing links to the headers.
54It's maintained automatically by Boost.Build. (The command =b2 headers= creates or recreates
55the contents of the =boost= directory.)
56
57This 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
59that therefore, the current library being scanned depends on Boost.Filesystem.
60
61Unfortunately, Boost releases do not have this structure. For backward compatibility, they
62have an old-style =boost= directory containing all header files, whereas the per-library =include=
63subdirectories are missing. Therefore, /Boostdep/ will not work with a downloaded Boost release.
64
65To use /Boostdep/, you will have to clone the Boost Git repository instead. To do that, execute the
66following command:
67
68[pre
69git clone https://github.com/boostorg/boost.git boost
70]
71
72This will download the Boost "superproject" (the master project, without any libraries) and place it
73into the subdirectory =boost= of the current directory. To override the directory name, pass it as a
74second argument instead of =boost=:
75
76[pre
77git clone https://github.com/boostorg/boost.git /mydir/
78]
79
80You can now =cd= into the newly created directory with
81
82[pre
83cd /mydir/
84]
85
86This directory is called the "Boost root". All of the commands below assume that it is the current directory.
87
88The above =git clone= commands download the default branch of the Boost Git repository, which is =master=.
89This is the current more-or-less stable version of Boost.
90
91To verify this, issue the command
92
93[pre
94git status
95]
96
97from the Boost root. This will output
98
99[pre
100# On branch master
101nothing to commit, working directory clean
102]
103
104To download a specific release instead, such as 1.58.0, issue the following command after =git clone=, from
105the Boost root:
106
107[pre
108git checkout boost-1.58.0
109]
110
111=git status= will now say
112
113[pre
114# HEAD detached at boost-1.58.0
115nothing to commit, working directory clean
116]
117
118Then, download all the libraries:
119
120[pre
121git submodule update --init
122]
123
124This step will take a while.
125
126If all goes well, you will now have the complete contents of Boost's latest =master= branch (if you didn't =checkout=
127a specific release by name) or the corresponding Boost release (if you did).
128
129You can switch between the =master= branch, the =develop= (unstable) branch, and a release, by issuing the following
130commands:
131
132[:For the =master= branch:]
133
134[pre
135git checkout master
136git pull
137git 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
141checkout.)]
142
143[:For the =develop= branch:]
144
145[pre
146git checkout develop
147git pull
148git submodule update --init
149]
150
151[:For the =boost-1.58.0= release:]
152
153[pre
154git checkout boost-1.58.0
155git submodule update --init
156]
157
158[:For the =boost-1.57.0= release:]
159
160[pre
161git checkout boost-1.57.0
162git submodule update --init
163]
164
165Note that, while the initial =git submodule update= is quite slow, as it needs to download all the libraries, the
166subsequent invocations are a lot faster.
167
168Also note that if a new Boost library (=libs/convert=, for example) is present in, say, =master=, and you have it checked out,
169when 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/
178nothing added to commit but untracked files present (use "git add" to track)
179]
180
181and you will have to remove =libs/convert= by hand.
182
183Once 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
189To build /Boostdep/, issue the following command from the Boost root:
190
191[pre
192b2 tools/boostdep/build//install
193]
194
195This will build /Boostdep/ from source using the default "toolset" (a Boost.Build term meaning "compiler") and if successful,
196place it into the =dist/bin= subdirectory. The command assumes that =b2= (the Boost.Build executable) is somewhere in your path.
197If you don't have =b2=, execute
198
199[pre
200.\bootstrap
201]
202
203under Windows or
204
205[pre
206./bootstrap.sh
207]
208
209under 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
215Once you have built /Boostdep/, execute it with the following command:
216
217[pre
218dist/bin/boostdep
219]
220
221or
222
223[pre
224dist\bin\boostdep
225]
226
227on Windows. The commands below are given as using =dist/bin/boostdep=; if you're using Windows, use =dist\bin\boostdep= instead.
228
229This will print out the following help message:
230
231[pre
232Usage:
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=.
252The 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
262To list the dependencies of a specific library, use the command
263
264[pre
265dist/bin/boostdep /library/
266]
267
268For Boost.Filesystem, for example, type
269
270[pre
271dist/bin/boostdep filesystem
272]
273
274This will print out something similar to the following:
275
276[pre
277Primary dependencies for filesystem:
278
279assert:
280 <boost/assert.hpp>
281 from <boost/filesystem/operations.hpp>
282 from <boost/filesystem/path_traits.hpp>
283
284config:
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
294functional:
295 <boost/functional/hash_fwd.hpp>
296 from <boost/filesystem/path.hpp>
297
298io:
299 <boost/io/detail/quoted_manip.hpp>
300 from <boost/filesystem/path.hpp>
301
302iterator:
303 <boost/iterator/iterator_facade.hpp>
304 from <boost/filesystem/path.hpp>
305 /.../
306]
307
308This 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>=
310shows where =<boost/assert.hpp>= is being included.
311
312/Boostdep/ names libraries (or modules) after their directory name. The =libs/filesystem=
313directory, for example, is the =filesystem= module. The =libs/numeric/conversion= directory
314is the =numeric~conversion= module, according to the /Boostdep/ naming convention.
315
316The reason forward slashes are replaced with tildes is that =numeric~conversion= is a valid
317file name, which makes generating HTML reports a bit easier.
318
319To see where a given header resides and who includes it, type
320
321[pre
322dist/bin/boostdep /header/
323]
324
325For =boost/filesystem.hpp=, for example, type
326
327[pre
328dist/bin/boostdep boost/filesystem.hpp
329]
330
331This will print something along the lines of
332
333[pre
334Inclusion report for <boost/filesystem.hpp> (in module filesystem):
335
336 from spirit:
337 <boost/spirit/home/x3/support/utility/testing.hpp>
338]
339
340What this tells you is that =boost/filesystem.hpp= is part of Boost.Filesystem and is only
341included once, from =<boost/spirit/home/x3/support/utility/testing.hpp>=. Other headers,
342such as =boost/shared_ptr.hpp=, are more widely used, as you can see if you try
343
344[pre
345dist/bin/boostdep boost/shared_ptr.hpp
346]
347
348To print the reverse dependencies of a library, use
349
350[pre
351dist/bin/boostdep --reverse /library/
352]
353
354For example,
355
356[pre
357dist/bin/boostdep --reverse filesystem
358]
359
360will list which libraries depend on Boost.Filesystem:
361
362[pre
363Reverse dependencies for filesystem:
364
365graph_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
371log:
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
379spirit:
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
387wave:
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
404The primary purpose of /Boostdep/ is to generate HTML dependency reports. In
405the typical case, two types of reports are generated: overviews that contain
406information for all modules, and per-module ones that list information for a
407specific library.
408
409/Boostdep/ can generate three types of the first kind of report: module overview,
410module levels and module weights. To generate a module overview, use the command
411
412[pre
413dist/bin/boostdep --html --module-overview > module-overview.html
414]
415
416For a module level report, use
417
418[pre
419dist/bin/boostdep --html --module-levels > module-levels.html
420]
421
422For a module weight report, use
423
424[pre
425dist/bin/boostdep --html --module-weights > module-weights.html
426]
427
428In these reports, module names such as /module/ are HTML links to [^/module/.html].
429
430To make these links work as expected, you can generate HTML reports for each module
431as follows:
432
433[pre
434dist/bin/boostdep --title "Dependency Report for /module/" --html --primary /module/ --secondary /module/ --reverse /module/ > /module/.html
435]
436
437This step can be automated if you generate a module list first with
438
439[pre
440dist/bin/boostdep --list-modules > list-modules.txt
441]
442
443that will contain one module name per line, and then use a script to issue the previous
444command for each module name.
445
446For more information about the /Boostdep/ options and commands, see the [link boostdep.reference Reference] section.
447
448For an example of a report generation script, see the file =tools/boostdep/examples/report.bat=.
449This is a Windows batch file, but translating it to a Unix-style shell script should be
450straightforward.
451
452For convenience, the contents of =tools/boostdep/examples/report.bat= are given below:
453
454[pre
455SET BOOSTDEP=dist\bin\boostdep.exe
456
457FOR /f %%i IN ('git rev-parse HEAD') DO @SET REV=%%i
458
459FOR /f %%i IN ('git rev-parse --short HEAD') DO @SET SHREV=%%i
460
461FOR /f %%i IN ('git rev-parse --abbrev-ref HEAD') DO @SET BRANCH=%%i
462
463SET FOOTER=Generated on %DATE% %TIME% from revision %REV% on branch '%BRANCH%'
464
465SET OUTDIR=..\report-%BRANCH%-%SHREV%
466
467mkdir %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
475FOR /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
486subdirectory of =libs= a module if it contains an =include= subdirectory.
487
488This command is typically used from scripts which then use the list to execute
489a 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
495named =build= and =src=.
496
497This 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
503form
504
505[pre
506module -> dependency1 dependency2 /.../
507]
508
509By default, only the =include= directory is scanned for `#include` directives. If
510the option =--track-sources= is given, the =src= directory is also scanned.
511
512This 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
518plain text output is of the form
519
520[pre
521Module Overview:
522
523accumulators -> 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
524algorithm -> array assert bind concept_check config core exception function iterator mpl range regex static_assert tuple type_traits unordered
525align -> assert config core static_assert throw_exception
526]
527
528whereas 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
538where /accumulators/ is a link to =accumulators.html=.
539
540As before, if =--track-sources= is given, the =src= subdirectory is scanned for `#include` directives.
541
542HTML output is enabled by the =--html= option. The =--title= and =--footer= options set the HTML =<title>=
543and the page footer and need to precede =--html=, like in the following example:
544
545[pre
546dist/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
554a way so that a module of level =N= never depends on modules of levels greater than =N=, and in the absence
555of cyclic dependencies, doesn't depend on other modules of level =N=. It takes the same options as
556=--module-overview=.
557
558[pre
559dist/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
567its dependencies. This includes the indirect dependencies.
568
569=--module-weights= takes the same options as =--module-overview=.
570
571[pre
572dist/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
582dist/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
592dist/bin/boostdep --title "Secondary Dependencies of filesystem" --footer "Generated on 21.05.2015 20:53:11" --html --secondary filesystem > filesystem-secondary.html
593]
594
595You can combine =--primary= and =--secondary= in one invocation.
596
597[pre
598dist/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
608dist/bin/boostdep --title "Reverse Dependencies of filesystem" --footer "Generated on 21.05.2015 20:53:11" --html --reverse filesystem > filesystem-reverse.html
609]
610
611You can combine =--reverse= with =--primary= and =--secondary= for a complete module report.
612
613[pre
614dist/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.
622The dependencies are determined by tracing the =#include= directives starting from /module/'s headers.
623
624The difference between using the modules reported by =--subset= and those reported by the sum of =--primary= and =--secondary= is that the former only guarantees
625that /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
630dist/bin/boostdep --title "Subset Dependencies of filesystem" --footer "Generated on 21.05.2015 20:53:11" --html --subset filesystem > filesystem-subset.html
631]
632
633You 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
642dist/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
649The =--track-sources= option instructs /Boostdep/ to scan the =src= library subdirectory for `#include` directives. By default,
650only 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]