From 92a345e67066fc5a039a87b0fb07caa838103780 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Wed, 27 Sep 2006 09:20:29 +0000 Subject: [PATCH] Added generation of dependency graph for the ocaml modules in matita/ WARNING (and happyness ...): first Ruby script added to our repository --- matita/Makefile | 5 +++++ matita/dep2dot.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 matita/dep2dot.rb diff --git a/matita/Makefile b/matita/Makefile index c51e7b7b6..896529cf4 100644 --- a/matita/Makefile +++ b/matita/Makefile @@ -405,6 +405,11 @@ endif $(CMOS): $(LIB_DEPS) $(CMOS:%.cmo=%.cmx): $(LIBX_DEPS) +deps.ps: deps.dot + dot -Tps -o $@ $< +deps.dot: .depend + ./dep2dot.rb < $< | tred > $@ + ifeq ($(MAKECMDGOALS),all) $(CMOS:%.cmo=%.cmi): $(LIB_DEPS) endif diff --git a/matita/dep2dot.rb b/matita/dep2dot.rb new file mode 100755 index 000000000..813b2afeb --- /dev/null +++ b/matita/dep2dot.rb @@ -0,0 +1,30 @@ +#!/usr/bin/ruby -w +# filter converting from .depend to .dot +# tested on .depend generated by ocamldep +# $Id$ + +require 'set' + +edges = Set.new +$stdin.each {|line| + target, deps = line.split(/\s*:\s*/) + while deps =~ /\\\s*$/ # deal with lines continued with trailing \ + deps.sub!(/\s*\\\s*$/, '') + line = $stdin.readline + deps += ' ' + line.lstrip + end + sources, targets = target.split, deps.split + for src in sources + for tgt in targets # ignore file extensions + src.sub!(/\.[^.]+/, '') + tgt.sub!(/\.[^.]+/, '') + edges << [src, tgt] unless src == tgt # ignore self deps + end + end +} +puts 'digraph G {' +for src, tgt in edges + print "\"#{src}\" -> \"#{tgt}\";\n" +end +puts '}' + -- 2.39.2