Add cheapo module visualization tool to repository.

Change-Id: I0f7e5da6122ffbe92574de14ff4a73f967a5b28a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/54994
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/tools/modules/graph_modules.sh b/tools/modules/graph_modules.sh
new file mode 100755
index 0000000..7e4b0f9
--- /dev/null
+++ b/tools/modules/graph_modules.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+#
+# Copyright 2019 PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Generate a chart of dependencies and includes in "dot" format.
+# Invoke in pdfium/ top-level directory
+
+BUILD_DIR=out/Default
+
+function crunch {
+  echo '  edge [color=black,constraint=true]'
+  gn desc $BUILD_DIR $1 deps | grep -v '//:' | grep -v test | \
+      grep -v samples | grep -v matches | sed "s|\\(.*\\)|  \"$1\" -> \"\\1\"|"
+  echo '  edge [color=red,constraint=false]'
+  gn desc $BUILD_DIR $1 allow_circular_includes_from | grep -v '//:' | \
+      grep -v test | grep -v samples | grep -v matches | \
+      grep -v 'how to display' | sed "s|\\(.*\\)|  \"\\1\" -> \"$1\"|"
+}
+
+TARGETS=`gn ls $BUILD_DIR | grep -v test | grep -v v8 | grep -v third_party | \
+             grep -v build | grep -v '//:'`
+
+echo 'digraph FRED {'
+echo '  node [shape=rectangle]'
+for TARGET in $TARGETS; do
+  crunch $TARGET
+done
+echo '}'