#!/usr/bin/perl # # Please comment any substantive changes with your email address and the date, # and add a short unique suffix to the version string. our $VERSION = '2.0'; =head1 NAME cppdeps - Perform static analysis of C++ code =head1 SYNOPSIS cppdeps [options] [file ...] =head1 DESCRIPTION Prints a table listing the interdependencies of all C++ source and header files found in the search directory. Dependency is determined by #include directives found in each file. You can specify a dependency without using #include, by using '#pragma depends "filename"' instead. Other preprocessor macros (e.g. #ifdef) are not honoured. Perl's @INC array is used when trying to locate named files. If files are listed on the command line, then those files will be inspected, otherwise a directory (usually the current directory) will be searched recursively for files with names ending in standard C++ extensions. The first stage lists each component (i.e. source/header pair) in alphanumeric order with its direct dependencies indented below. The second stage lists the "levels" and the components which are members of each one. Direct circular dependency is indicated by an asterisk ('*'). Indirect circular dependency is not supported and behaviour in this case is undefined. Finally, it prints a coupling metric computed from the amount of interdependency found. Smaller is better for this metric; anything < 1.5 is good, anything > 2.0 is getting bad. The members of level 1 are those components which can be tested independently of any other component. The members of level 2 are those components which can be tested independently of any component except one or more in level 1. The members of level N are those components which can be tested independently of any component in levels > N, but may depend on components in levels < N. =head1 OPTIONS =over 8 =item B<-d> | B<--dir> I Specifies the directory through which to search (recursively). In the absence of this option, the default is the current working directory. =item B<-h> | B<--help> Prints this manual page (synopsis and options only) and exits. =item B<-H> | B<--morehelp> Prints this manual page (including detailed description) and exits. =item B<-I> | B<--include> I Adds a directory name to Perl's @INC array, which is used when searching for source files included from other source files. =item B<-i> | B<--include-extract> I Specifies a snippet of Perl code which will extract the name of an include file from the $_ variable and return it. The $_ variable will contain a line of code taken from the input file, which may or may not include a '#include' directive. If it does not, the code snippet should return zero. Be sure to quote the code to avoid expansion by your shell. =item B<-l> | B<--lang> I Specifies the programming language of the files being processed. The effects of this specification can be conditionally overridden by the B, B<--regex> and B<--wildcard> options. The supported language specifiers are B and B. The default is B. =item B<-p> | B<--png> I In addition to printing a textual analysis to stdout, uses GraphViz to create a PNG image file with the specified name, showing the interdependencies diagramatically. =item B<-x> | B<--imageopt> I