[/
Copyright 2015-2020 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE_1_0.txt or copy at
http://boost.org/LICENSE_1_0.txt
]
[article Boostdep
[quickbook 1.6]
[id boostdep]
[copyright 2014-2020 Peter Dimov]
[license Distributed under the
[@http://boost.org/LICENSE_1_0.txt Boost Software License, Version 1.0].
]
]
[template simplesect[title]
[block ''''''[title]'''''']]
[template endsimplesect[]
[block '''''']]
[section Introduction]
/Boostdep/ is a tool for generating Boost dependency reports. It scans
the header or source files of the Boost libraries for `#include`
directives, builds a dependency graph from this information and outputs
its findings in plain text or HTML.
[section Modular Boost]
/Boostdep/ requires the so-called "modular Boost" directory structure.
If you already have a [@https://svn.boost.org/trac/boost/wiki/ModularBoost
modular Boost installation], you can skip this section. Otherwise, read on.
Boost libraries reside in subdirectories under the =libs= directory. For
example, the contents of the Boost.Filesystem library are in =libs/filesystem=.
This includes the build scripts (in =libs/filesystem/build=), the source files
(in =libs/filesystem/src=), the tests (in =libs/filesystem/test=), the documentation
(in =libs/filesystem/doc=), and so on.
In the past, when Boost used SVN as its version control system, the header files
were an exception. The header files of all libraries resided in the =boost= subdirectory,
and it wasn't possible to accurately determine which header belonged to which library.
When Boost moved to Git for version control, header files were moved to their corresponding
libraries, into an =include= subdirectory. The header files of Boost.Filesystem are now in
=libs/filesystem/include=.
For compatibility, =boost= is now a "virtual" directory, containing links to the headers.
It's maintained automatically by Boost.Build. (The command =b2 headers= creates or recreates
the contents of the =boost= directory.)
This new structure allows /Boostdep/ to determine that, when faced with an
`#include ` directive, that this header is part of Boost.Filesystem, and
that therefore, the current library being scanned depends on Boost.Filesystem.
Unfortunately, Boost releases do not have this structure. For backward compatibility, they
have an old-style =boost= directory containing all header files, whereas the per-library =include=
subdirectories are missing. Therefore, /Boostdep/ will not work with a downloaded Boost release.
To use /Boostdep/, you will have to clone the Boost Git repository instead. To do that, execute the
following command:
[pre
git clone https://github.com/boostorg/boost.git boost
]
This will download the Boost "superproject" (the master project, without any libraries) and place it
into the subdirectory =boost= of the current directory. To override the directory name, pass it as a
second argument instead of =boost=:
[pre
git clone https://github.com/boostorg/boost.git /mydir/
]
You can now =cd= into the newly created directory with
[pre
cd /mydir/
]
This directory is called the "Boost root". All of the commands below assume that it is the current directory.
The above =git clone= commands download the default branch of the Boost Git repository, which is =master=.
This is the current more-or-less stable version of Boost.
To verify this, issue the command
[pre
git status
]
from the Boost root. This will output
[pre
# On branch master
nothing to commit, working directory clean
]
To download a specific release instead, such as 1.58.0, issue the following command after =git clone=, from
the Boost root:
[pre
git checkout boost-1.58.0
]
=git status= will now say
[pre
# HEAD detached at boost-1.58.0
nothing to commit, working directory clean
]
Then, download all the libraries:
[pre
git submodule update --init
]
This step will take a while.
If all goes well, you will now have the complete contents of Boost's latest =master= branch (if you didn't =checkout=
a specific release by name) or the corresponding Boost release (if you did).
You can switch between the =master= branch, the =develop= (unstable) branch, and a release, by issuing the following
commands:
[:For the =master= branch:]
[pre
git checkout master
git pull
git submodule update --init
]
[:(=git pull= updates your local copy of the =master= branch from the server, in case it has changed since your initial
checkout.)]
[:For the =develop= branch:]
[pre
git checkout develop
git pull
git submodule update --init
]
[:For the =boost-1.58.0= release:]
[pre
git checkout boost-1.58.0
git submodule update --init
]
[:For the =boost-1.57.0= release:]
[pre
git checkout boost-1.57.0
git submodule update --init
]
Note that, while the initial =git submodule update= is quite slow, as it needs to download all the libraries, the
subsequent invocations are a lot faster.
Also note that if a new Boost library (=libs/convert=, for example) is present in, say, =master=, and you have it checked out,
when you later switch to =boost-1.58.0=, where this library doesn't exist, Git will not delete =libs/convert=. In this case,
=git status= will output
[pre
# HEAD detached at boost-1.58.0
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# libs/convert/
nothing added to commit but untracked files present (use "git add" to track)
]
and you will have to remove =libs/convert= by hand.
Once you have the Boost contents which you want to analyze for dependencies, proceed with the next step, building /Boostdep/.
[endsect]
[section Building Boostdep]
To build /Boostdep/, issue the following command from the Boost root:
[pre
b2 tools/boostdep/build
]
This will build /Boostdep/ from source using the default "toolset" (a Boost.Build term meaning "compiler") and if successful,
place it into the =dist/bin= subdirectory. The command assumes that =b2= (the Boost.Build executable) is somewhere in your path.
If you don't have =b2=, execute
[pre
.\bootstrap
]
under Windows or
[pre
./bootstrap.sh
]
under Unix-like systems, which should build =b2= and place it into the current directory. You can then use =./b2= instead of =b2=.
[endsect]
[section Running Boostdep]
Once you have built /Boostdep/, execute it with the following command:
[pre
dist/bin/boostdep
]
or
[pre
dist\bin\boostdep
]
on Windows. The commands below are given as using =dist/bin/boostdep=; if you're using Windows, use =dist\bin\boostdep= instead.
This will print out the following help message:
[pre
Usage:
boostdep --list-modules
boostdep --list-buildable
boostdep \[--track-sources\] \[--track-tests\] --list-dependencies
boostdep --list-exceptions
boostdep --list-missing-headers
boostdep --list-buildable-dependencies
boostdep \[options\] --module-overview
boostdep \[options\] --module-levels
boostdep \[options\] --module-weights
boostdep \[options\] \[--primary\]
boostdep \[options\] --secondary
boostdep \[options\] --reverse
boostdep \[options\] --subset
boostdep \[options\] \[--header\]
boostdep --test
boostdep --cmake
boostdep --pkgconfig \[=\] \[=\]...
boostdep \[options\] --subset-for
\[options\]: \[--boost-root \]
\[--\[no-\]track-sources\] \[--\[no-\]track-tests\]
\[--html-title \] \[--html-footer