1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/docs/tools/depgraph Thu Apr 15 23:15:51 2021 +0200
1.3 @@ -0,0 +1,73 @@
1.4 +#!/bin/sh
1.5 +
1.6 +THISDIR=`dirname "$0"`
1.7 +PKGDIR=`realpath "$THISDIR/../.."`
1.8 +DOCS=`realpath "$THISDIR/.."`
1.9 +
1.10 +DOTFILE="$DOCS/depgraph.dot"
1.11 +SVGFILE="$DOCS/depgraph.svg"
1.12 +
1.13 +
1.14 +
1.15 +# Filter interface header files.
1.16 +
1.17 +filter_interfaces()
1.18 +{
1.19 + if [ "$WITH_INTERFACES" ] ; then
1.20 + tee
1.21 + else
1.22 + grep -v '_interface.h'
1.23 + fi
1.24 +}
1.25 +
1.26 +
1.27 +
1.28 +# Main program.
1.29 +
1.30 +if [ "$1" = '--with-interfaces' ] ; then
1.31 + WITH_INTERFACES="$1"
1.32 + shift 1
1.33 +else
1.34 + WITH_INTERFACES=
1.35 +fi
1.36 +
1.37 +# Directories for processing.
1.38 +
1.39 +SOURCES="$PKGDIR/libfsserver $PKGDIR/libmem"
1.40 +
1.41 +# Generate prologue.
1.42 +
1.43 +cat <<EOF > "$DOTFILE"
1.44 +digraph depgraph {
1.45 + node [fontsize="13.0",fontname="sans-serif"];
1.46 + edge [fontsize="13.0",fontname="sans-serif"];
1.47 +
1.48 +EOF
1.49 +
1.50 +# Generate header file relationships.
1.51 +# Find header files.
1.52 +# Obtain include statements.
1.53 +# Remove interface references unless indicated.
1.54 +# Remove various library references.
1.55 +# Obtain basenames for header filenames.
1.56 +# Rewrite include references, producing edges between nodes.
1.57 +
1.58 + find $SOURCES -maxdepth 4 -name '*.h' \
1.59 +| xargs -I{} grep -H include '{}' \
1.60 +| filter_interfaces \
1.61 +| grep -v '<l4\|<systypes\|<std\|<list>\|<map>\|<mutex>\|<condition_variable>' \
1.62 +| sed 's/[^:]*\/\([^:]*\)/\1/' \
1.63 +| sed 's/<.*\///g;s/<//g;s/>//g;s/"//g;s/\.h//g;s/:#include / -> /;s/^/ /;s/$/;/' \
1.64 +>> "$DOTFILE"
1.65 +
1.66 +# Generate epilogue.
1.67 +
1.68 +cat <<EOF >> "$DOTFILE"
1.69 +}
1.70 +EOF
1.71 +
1.72 +# Produce the SVG output.
1.73 +
1.74 +dot -Tsvg -o "$SVGFILE" "$DOTFILE"
1.75 +
1.76 +# vim: tabstop=4 expandtab shiftwidth=4