https://github.com/shreyasbharath/cpp-dependency-graph
A Ruby gem that generates useful visualisations (dot, d3.js) to study the architecture of C/C++ projects
https://github.com/shreyasbharath/cpp-dependency-graph
architecture c cplusplus d3-visualization d3js dependency-graph dependency-tree dotfiles rubygem visualization
Last synced: 9 months ago
JSON representation
A Ruby gem that generates useful visualisations (dot, d3.js) to study the architecture of C/C++ projects
- Host: GitHub
- URL: https://github.com/shreyasbharath/cpp-dependency-graph
- Owner: shreyasbharath
- License: mit
- Created: 2018-03-16T03:10:47.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-12T11:34:14.000Z (over 2 years ago)
- Last Synced: 2025-04-06T06:25:22.815Z (10 months ago)
- Topics: architecture, c, cplusplus, d3-visualization, d3js, dependency-graph, dependency-tree, dotfiles, rubygem, visualization
- Language: Ruby
- Homepage: https://shreyasbharath.github.io/cpp_dependency_graph/
- Size: 650 KB
- Stars: 44
- Watchers: 3
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Cpp Dependency Graph
[](https://gitter.im/cpp_dependency_graph/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://opensource.org/licenses/MIT)
[](https://travis-ci.org/shreyasbharath/cpp_dependency_graph)
[](https://codeclimate.com/github/shreyasbharath/cpp_dependency_graph/maintainability)
[](https://www.codacy.com/app/shreyasbharath/cpp_dependency_graph?utm_source=github.com&utm_medium=referral&utm_content=shreyasbharath/cpp_dependency_graph&utm_campaign=Badge_Grade)
[](https://codeclimate.com/github/shreyasbharath/cpp_dependency_graph/test_coverage)
[](https://badge.fury.io/rb/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](http://www.emadelsaid.com/rubrowser/), [cpp-dependencies](https://github.com/tomtom-international/cpp-dependencies) and [objc-dependency-visualizer](https://github.com/PaulTaykalo/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](https://github.com/google/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](https://github.com/rethinkdb/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](https://github.com/rethinkdb/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](https://github.com/rethinkdb/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](https://github.com/rethinkdb/rethinkdb) and [leveldb](https://github.com/google/leveldb)


## Development
`bundle exec cpp_dependency_graph -r ...`
### Running all unit tests
`rake spec`
### Running a single test
`rake spec SPEC=`
## 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.