As of RAD Studio 12.0, the Delphi compiler has an experimental feature to help understand the structure of a project and avoid circular unit references, slowing down compilation and causing side effects on the compiler when combining with other language features. This feature has the ability to generate a uses statement graph directly at the compiler level (without a separate parsing tool).
The compiler has a new --graphviz command option, which generates a unit dependency graph in a .gv GraphViz file, which can be later processed by GraphViz itself (an open source tool available at https://graphviz.org/) and also at http://magjac.com/graphviz-visual-editor/. There is also a second option to exclude units (individually or by family) from the graph:
--graphviz (Outputs <exename>.gv file)
--graphviz-exclude:<UnitList> (Excludes specific unit names from the output)
For --graphviz-exclude, the Unit name pattern can include the '*' wild card and multiple unit name patterns can be specified in <UnitList> separated by ';'.
For example: --graphviz-exclude:System.*;VCL.*;FMX.* excludes all System, VCL, and FireMonkey units.
Note: Required units, System, SysInit, and System.Variants are always excluded.
Considering an example of a simple application with a main form, a secondary dialog box, and a data module, they refer to each other via some uses statements in the interface or implementation section. You can build it with the following command line (excluding system units):
Note: The generation of the .gv file only works on the command line or when using external MSBUILD from the IDE, not while building directly from the IDE.