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 Projectbutton Sourcetrail Project Namecan be anything, I used bitcoinSourcetrail Project Locationcan be anywhere, I used ~/src/sourcetrail/- Click the
Add Source Groupbutton - Click the
Empty C++ Source GroupandNextbuttons - Change the
C++ Standardtoc++11and clickNext - In
Files & Directories to Indexadd yourbitcoin/srcdirectory and clickNext - Exclude
bitcoin/src/leveldb - Click
auto-detectandStartforInclude Paths, click the pencil icon and paste in the following (if you don’t know what version to use, search inbitcoin/Makefileafter 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
detectforGlobal Include Pathsand theNextbutton - For
Global Framework Search Pathsclick thedetectbutton andSave - No compiler flags, click
Next - Click
Create - Click
Startfor 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.