Files in the top-level directory from the latest check-in

  • src
  • build.zig
  • build.zig.zon
  • LICENSE
  • README.md

cgraph

Tool for statically analysing C source file dependencies.

Required dependencies

  • zig v0.15.2

Building the project

Release build:

zig build -Doptimize=ReleaseSafe

Debug build:

zig build -Doptimize=Debug

The resulting binary can be found at ./zig-out/bin/cgraph.

Configuration file

To avoid having an unwieldy list of include search paths on command line, each invocation of this tool requires a simple JSON configuration file. Path to it is passed as the first command line argument.

It should contain single JSON object with the following optional fields:

  • "system_search_paths"

A JSON array with paths to search when resolving system include directives. Order matches the search order during resolution.

  • "max_depth"

Number of maximum search depth, when resolving all dependencies of a source file. By default search depth is unrestricted.

  • "output_format"

Sets the desired output format, default being plain, human readable textual output. Allowed values: "plain", "json", "dot"

Example configuration file:

{
    "output_format": "json",
    "system_search_paths": [
        "/usr/include",
        "/project/path/include"
    ],
    "max_depth": 5
}

Commands

  • cgraph CONFIG.json resolve FILE

Resolves single FILE include directives.

  • cgraph CONFIG.json dependencies FILE

Resolves all dependencies of the FILE. Optionally specify maximum depth in configuration file.

Acknowledgments

This project is funded through the NGI0 Core Fund.

For more information, see the associated NLnet project's page.