From 89e7e9b636d2364ef766b97c533dc3f685a794d6 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 1 Oct 2022 12:46:30 -0700 Subject: [PATCH] Makefile: add moduledeps target. make moduledeps ROOTNODE=T.P.Parsing --- Makefile | 5 +++++ tools/depthfirst.gvpr | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tools/depthfirst.gvpr diff --git a/Makefile b/Makefile index 9388c5d6f..4d58079bc 100644 --- a/Makefile +++ b/Makefile @@ -180,6 +180,11 @@ modules.dot: $(SOURCEFILES) modules.pdf: modules.dot gvpr -f tools/cliptree.gvpr -a '"$(ROOTNODE)"' $< | dot -Tpdf > $@ +# make moduledeps ROOTNODE=T.P.Parsing +moduledeps: modules.dot ## Print dependencies of a module ROOTNODE + gvpr -f tools/depthfirst.gvpr -a '"$(ROOTNODE)"' modules.dot +.PHONY: moduledeps + clean: ## clean up cabal clean .PHONY: clean diff --git a/tools/depthfirst.gvpr b/tools/depthfirst.gvpr new file mode 100644 index 000000000..5539be22e --- /dev/null +++ b/tools/depthfirst.gvpr @@ -0,0 +1,18 @@ +BEGIN { + int i, indent; + int seen[string]; + void prInd (int cnt) { + for (i = 0; i < cnt; i++) printf (" "); } +} +BEG_G { + $tvtype = TV_prepostfwd; $tvroot = node($,ARGV[0]); +} N{ + if (seen[$.name]) { + indent--; + if (indent == 0) exit(0); + } else { + prInd(indent); print ($.name); + seen[$.name] = 1; + indent++; + } +}