]> matita.cs.unibo.it Git - helm.git/commitdiff
Added generation of dependency graph for the ocaml modules in matita/
authorStefano Zacchiroli <zack@upsilon.cc>
Wed, 27 Sep 2006 09:20:29 +0000 (09:20 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Wed, 27 Sep 2006 09:20:29 +0000 (09:20 +0000)
WARNING (and happyness ...): first Ruby script added to our repository

matita/Makefile
matita/dep2dot.rb [new file with mode: 0755]

index c51e7b7b653e6f6e2e936c77077d57641a156c65..896529cf43b4ccb6f412278c63abb43fe4acf580 100644 (file)
@@ -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 (executable)
index 0000000..813b2af
--- /dev/null
@@ -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 '}'
+