A C++ utility for walking the include trees of a list of source files.
It assumes gcc
as a C++ compiler, and that it is used with C++, not C code.
- Ensure you have a cmake project at location
<project_root>
, with its build directory in<project_root>/build
- Generate a
<project_root>/build/compile_commands.json
file for the project by setting theCMAKE_EXPORT_COMPILE_COMMANDS
cmake flag. Might require reconfiguration or rebuilding the project. - Invoke
header_walker.py --from_cmake_build_dir <project_root>/build
All settings of the tool can be controlled with a json config file. Example:
{
"db_file" : "<project_root>/build/compile_commands.json",
"project_root": "<project_root>",
"filter_out_system_search_paths": true,
"filter_out_paths_outside_project_root": true,
"print_all_unique_header": true,
"print_header_dependencies": true,
"excluded_directories": [
"<project_root>/external",
"<project_root>/build",
"<project_root>/test",
]
}
Both the filter_*
and excludeed_directories
options can be used to filter out files. Typically you would use them to hide system header, external libraries or generated source code.
Usage:
- Invoke
header_walker.py --config config.json
You can use a config file for the basic settings, and override and extend its values with commandline parameters.