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