dependency-graph.sh improved

master
Marc Wäckerlin 8 years ago
parent ca0837c04f
commit e1f6fa76c0
  1. 44
      scripts/dependency-graph.sh

@ -38,8 +38,10 @@ success() {
# commandline parameter evaluation
files=${0%/*}/configure.ac
short=0
while test $# -gt 0; do
case "$1" in
(--short|-s) short=1;;
(--help|-h) less <<EOF
SYNOPSIS
@ -48,6 +50,7 @@ SYNOPSIS
OPTIONS
--help, -h show this help
--short, -s short graph with no external dependencies
<files> list of zero or more configure.ac files
(default: ${files})
@ -135,19 +138,34 @@ trap 'traperror "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FU
##########################################################################################
echo "digraph G {"
for file in $files; do
if ! test -e $file; then
error "file $file not found"; exit 1
filter() {
if test $short -eq 1; then
all=$(cat)
allowed=$(sed -n '/"\(.*\)" \[style=solid\];/{s//\1/;H};${x;s/\n//;s/\n/\\|/gp}' <<<"${all}")
sed -n '/"\('"${allowed}"'\)" -> "\('"${allowed}"'\)"/p' <<<"${all}"
else
cat
fi
sed -n '
/^ *m4_define(x_package_name, */ {s///;s/ *).*//;h;s/.*/& [shape=doublecircle];/p}
/^ *AX_REQUIRE_QT/ {s/.*/qt -> /;G;s/\n//;s/.*/&;/p}
/^ *AX_PKG_REQUIRE(\[\?\([^],]\+\)\]\?, \[\?\([^],]\+\)\]\?.*/ {s//\2 -> /;G;s/\n//;s/.*/&;/p}
/^ *AX_PKG_REQUIRE(\[\?\([^],]\+\)\]\?.*/ {s//\1 -> /;G;s/\n//;s/.*/&;/p}
/^ *AX_CHECK_QT/ {s/.*/qt -> /;G;s/\n//;s/.*/& [style=dotted];/p}
/^ *AX_PKG_CHECK(\[\?\([^],]\+\)\]\?, \[\?\([^],]\+\)\]\?.*/ {s//\2 -> /;G;s/\n//;s/.*/& [style=dotted];/p}
/^ *AX_PKG_CHECK(\[\?\([^],]\+\)\]\?.*/ {s//\1 -> /;G;s/\n//;s/.*/& [style=dotted];/p}
}
echo "digraph G {"
if test $short -eq 0; then
echo "node [style=dashed];"
fi
(
for file in $files; do
if ! test -e $file; then
error "file $file not found"; exit 1
fi
sed -n '
/^ *m4_define(x_package_name, */ {s//"/;s/ *).*/"/;h;s/.*/& [style=solid];/p}
/^ *AX_REQUIRE_QT/ {s/.*/"qt" -> /;G;s/\n//;s/.*/&;/p}
/^ *AX_PKG_REQUIRE(\[\?\([^],)]\+\)\]\?, \[\?\([^],)]\+\)\]\?.*/ {s//"\2" -> /;G;s/\n//;s/.*/&;/p}
/^ *AX_PKG_REQUIRE(\[\?\([^],)]\+\)\]\?.*/ {s//"\1" -> /;G;s/\n//;s/.*/&;/p}
/^ *AX_CHECK_QT/ {s/.*/"qt" -> /;G;s/\n//;s/.*/& [style=dashed];/p}
/^ *AX_PKG_CHECK(\[\?\([^],)]\+\)\]\?, \[\?\([^],)]\+\)\]\?.*/ {s//"\2" -> /;G;s/\n//;s/.*/& [style=dotted];/p}
/^ *AX_PKG_CHECK(\[\?\([^],)]\+\)\]\?.*/ {s//"\1" -> /;G;s/\n//;s/.*/& [style=dotted];/p}
' $file
done
done
) | filter
echo "}"

Loading…
Cancel
Save