paul@95 | 1 | #!/bin/sh |
paul@95 | 2 | |
paul@95 | 3 | THISDIR=`dirname "$0"` |
paul@95 | 4 | PKGDIR=`realpath "$THISDIR/../.."` |
paul@95 | 5 | DOCS=`realpath "$THISDIR/.."` |
paul@95 | 6 | |
paul@95 | 7 | DOTFILE="$DOCS/depgraph.dot" |
paul@95 | 8 | SVGFILE="$DOCS/depgraph.svg" |
paul@95 | 9 | |
paul@95 | 10 | |
paul@95 | 11 | |
paul@95 | 12 | # Filter interface header files. |
paul@95 | 13 | |
paul@95 | 14 | filter_interfaces() |
paul@95 | 15 | { |
paul@95 | 16 | if [ "$WITH_INTERFACES" ] ; then |
paul@95 | 17 | tee |
paul@95 | 18 | else |
paul@95 | 19 | grep -v '_interface.h' |
paul@95 | 20 | fi |
paul@95 | 21 | } |
paul@95 | 22 | |
paul@95 | 23 | |
paul@95 | 24 | |
paul@95 | 25 | # Main program. |
paul@95 | 26 | |
paul@95 | 27 | if [ "$1" = '--with-interfaces' ] ; then |
paul@95 | 28 | WITH_INTERFACES="$1" |
paul@95 | 29 | shift 1 |
paul@95 | 30 | else |
paul@95 | 31 | WITH_INTERFACES= |
paul@95 | 32 | fi |
paul@95 | 33 | |
paul@95 | 34 | # Directories for processing. |
paul@95 | 35 | |
paul@95 | 36 | SOURCES="$PKGDIR/libfsserver $PKGDIR/libmem" |
paul@95 | 37 | |
paul@95 | 38 | # Generate prologue. |
paul@95 | 39 | |
paul@95 | 40 | cat <<EOF > "$DOTFILE" |
paul@95 | 41 | digraph depgraph { |
paul@95 | 42 | node [fontsize="13.0",fontname="sans-serif"]; |
paul@95 | 43 | edge [fontsize="13.0",fontname="sans-serif"]; |
paul@95 | 44 | |
paul@95 | 45 | EOF |
paul@95 | 46 | |
paul@95 | 47 | # Generate header file relationships. |
paul@95 | 48 | # Find header files. |
paul@95 | 49 | # Obtain include statements. |
paul@95 | 50 | # Remove interface references unless indicated. |
paul@95 | 51 | # Remove various library references. |
paul@95 | 52 | # Obtain basenames for header filenames. |
paul@95 | 53 | # Rewrite include references, producing edges between nodes. |
paul@95 | 54 | |
paul@95 | 55 | find $SOURCES -maxdepth 4 -name '*.h' \ |
paul@95 | 56 | | xargs -I{} grep -H include '{}' \ |
paul@95 | 57 | | filter_interfaces \ |
paul@95 | 58 | | grep -v '<l4\|<systypes\|<std\|<list>\|<map>\|<mutex>\|<condition_variable>' \ |
paul@95 | 59 | | sed 's/[^:]*\/\([^:]*\)/\1/' \ |
paul@95 | 60 | | sed 's/<.*\///g;s/<//g;s/>//g;s/"//g;s/\.h//g;s/:#include / -> /;s/^/ /;s/$/;/' \ |
paul@95 | 61 | >> "$DOTFILE" |
paul@95 | 62 | |
paul@95 | 63 | # Generate epilogue. |
paul@95 | 64 | |
paul@95 | 65 | cat <<EOF >> "$DOTFILE" |
paul@95 | 66 | } |
paul@95 | 67 | EOF |
paul@95 | 68 | |
paul@95 | 69 | # Produce the SVG output. |
paul@95 | 70 | |
paul@95 | 71 | dot -Tsvg -o "$SVGFILE" "$DOTFILE" |
paul@95 | 72 | |
paul@95 | 73 | # vim: tabstop=4 expandtab shiftwidth=4 |