-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Sourcetrail code viewer and linkage to Visual Studio, for Git
Sourcetrail is an interactive source explorer that simplifies navigation in existing source code. It is now open source. You can support them on Patreon.
This note is a quick start to setting up a Sourcetrail project for exploring the Git source code in conjunction with Visual Studio. Source trail is configurable and some parameter need to be set on initial project setup.
- Git-for-Windows is available as a Visual Studio build in the
main
branch. Visual Studio will detect theCMakeLists.txt
file in\contrib\buildsystems
to build the project. See that file for instructions on generating the.sln
andvcproj
files needed for Sourcetrail and other VS Extensions. The VS project comprises ~19 sub-projects includingALL BUILD
andlibgit
. - This was tested with the free VS2019 community edition.
- Build the project in Visual Studio so that it's
vcpkg
dependencies are downloaded and compiled (may take some time). - Download and install the Sourcetrail software. Check the documentation, especially the intro video.
- Download and install the VS Sourcetrail Extension.
For Git, Sourcetrail will need it's pre-processor dependencies which are numerous, so let's extract them from Visual Studio. We need to collect the main preprocessor directives from libgit
(which everything depends on) and git
.
- Browse the VS project properties. Find the
C/C++
tab list, open, find 'Preprocessor', then (see top of list) "Preprocessor Definitions" with a long list of ";" separated values. Copy them for bothgit
andlibgit
into your favourite editor. - Change ";" to "\n-D " (i.e. newline then -D ), with a
-D
for the first value from each original line as well, etc. - Remove the "-D %(additional..)" lines.
- Add
-std=c99
and-nologo
options to the end of the option list, which now should be one per line. - Don't worry about duplicates. Internally Sourcetrail uses a Clang compiler with a 'last one wins' where required.
Now let's create the Sourcetrail project
-
Open Sourcetrail. Leave at the initial prompt.
-
In VS, from the Sourcetrail menu, export the compile database, selecting C99 standard.
-
Switch back to Sourcetrail "New Source Group" window.
-
"Headers & directories to index": click 'select from Compilation database', then tick './' only (leave all the 'Windows Kits' unchecked). scroll down, "exluded's" left blank; Next.
(flicks back to the New Project dialog, but as it is still selecting the source groups (C/C++ from Compilation Database) its looks unchanged),
- scroll down, "Additional Compile Flags" selecting the scribble pen icon, paste in the "Preprocessor Definitions" (one per line) prepared above.
- select "General" in top left side, and update the project name to (e.g.) "Git_sourcetrail". Location is usually ok e.g."C:/git-sdk-64/usr/src/git". "Create" ! (or maybe Next)
- switch back to the other Sourcetrail window (now active, with a fresh blue 'start Indexing' dialog). "All files" (dot in circle) should already be selected.
- Click 'Start', wait ~one minute (00:01:38).
Should work.
This is the Git for Windows wiki. See how-to-participate.