Setting Up Sourcetrail with Bitcoin
I was listening to a recent CppCast podcast episode where the guest, Eberhard Gräther, described the software he built: “Sourcetrail, a cross-platform source explorer for faster understanding of unfamiliar source code”.
The visualization feature of Sourcetrail caught my attention as I enjoy using a similar call graph feature in Doxygen.
I downloaded Sourcetrail. Sourcetrail relies on a compile_commands.json
file
to automatically identify all the source files that need to be indexed. This file can be exported with CMake but Bitcoin uses
Autotools for its build system. After attempting a number of different solutions1 the
resulting compile_commands.json
only included 9 source files. If you’re able to do better with an automated tool, let
me know! Instead I manually set up Sourcetrail:
Sourcetrail setup:
- Open Sourcetrail
- Click the
New Project
button Sourcetrail Project Name
can be anything, I used bitcoinSourcetrail Project Location
can be anywhere, I used ~/src/sourcetrail/- Click the
Add Source Group
button - Click the
Empty C++ Source Group
andNext
buttons - Change the
C++ Standard
toc++11
and clickNext
- In
Files & Directories to Index
add yourbitcoin/src
directory and clickNext
- Exclude
bitcoin/src/leveldb
- Click
auto-detect
andStart
forInclude Paths
, click the pencil icon and paste in the following (if you don’t know what version to use, search inbitcoin/Makefile
after running./autogen.sh && ./configure
):/usr/local/Cellar/openssl/1.0.2p/include /usr/local/Cellar/libevent/2.1.8/include /usr/local/opt/berkeley-db@4/include /usr/local/Cellar/qt/5.11.1/include /usr/local/Cellar/qt/5.11.1/include/QtNetwork /usr/local/Cellar/qt/5.11.1/include/QtWidgets /usr/local/Cellar/qt/5.11.1/include/QtGui /usr/local/Cellar/qt/5.11.1/include/QtCore /usr/local/Cellar/qt/5.11.1/include/QtDBus /usr/local/Cellar/qt/5.11.1/include/QtTest
- Click
detect
forGlobal Include Paths
and theNext
button - For
Global Framework Search Paths
click thedetect
button andSave
- No compiler flags, click
Next
- Click
Create
- Click
Start
for the indexing
All done!
footnote
1. Build and install Bear or
scan-build. On macOS they do not work with the default make
due to a
system security policy. To work around this, brew install make && pip install scan-build
and run PATH="/usr/local/opt/make/libexec/gnubin:$PATH" && ./autogen.sh && ./configure && gmake clean && intercept-build --override-compiler --append gmake -j8
in your bitcoin directory.