Cpp Dependency Graph
Generates useful component dependency visualisations (dot
or d3.js
) to study the architecture of C/C++ projects.
Why do all the other languages have awesome tools to analyse codebases but C/C++ does not?
It's time to change that.
This tool aims to -
- provide multiple views into the architecture of a codebase
- generate views at multiple levels of the architecture
- make the resulting views genuinely useful, rich, dynamic and interactive (static views are boring)
Inspiration
This tool is inspired by a number of projects rubrowser, cpp-dependencies and objc-dependency-visualizer.
The pretty d3
visualisations are directly copied from objc-dependency-visualiser
.
A huge shout out to the people behind these projects.
Comparison With Other Tools
cpp-dependencies
cinclude2dot
dep-matrix
Usage
Installation
gem install cpp_dependency_graph
Help
cpp_dependency_graph -h
Overall component dependency graph
To generate the overall component dependency graph for a project, use it like so -
cpp_dependency_graph visualise_project -r spec\test\example_project\ -o deps.svg -f svg
Below is the overall dot
and d3
component dependency visualisations for leveldb
NOTE - If your project has a large number of components (> 100 and lots of connections between them), then generation (and subsequent rendering) may take some time.
Individual component dependency graph
This will highlight the dependencies coming in and going out of a specific component. This allows you to filter out extraneous detail and study individual components in more detail.
cpp_dependency_graph visualise_component -r spec\test\example_project\ --component Engine -o deps.dot -f dot
Here's a component dependency visualisation generated for the queue
component in rethinkdb
Component include dependency graph
This will highlight dependencies of includes within a specific component
cpp_dependency_graph visualise_component_includes -r spec\test\example_project\ --component Engine
Here's a component include dependency visualisation generated for the queue
component in rethinkdb
Header file include dependency graph
This will highlight include dependencies of header files globally within the project
cpp_dependency_graph visualise_header_includes -r spec\test\example_project\ --header Engine.h
Here's a component include dependency visualisation generated for the errors.hpp
header file in rethinkdb
Cyclic dependencies only graph
This will highlight cyclic dependencies between components within a project. This is especially useful for targeted refactoring activities to reduce coupling between components.
cpp_dependency_graph visualise_cyclic_deps -r spec\test\example_project\
Here's the cyclic dependencies only visualisation generated for rethinkdb and leveldb
Development
bundle exec cpp_dependency_graph <cmd> -r <dir> ...
Running all unit tests
rake spec
Running a single test
rake spec SPEC=<path_to_spec_file>
License
cpp_dependency_graph is available under the MIT license.
Warranty
This software is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose.