]> matita.cs.unibo.it Git - helm.git/blob - matita/dep2dot.rb
experimental branch with no set baseuri command and no developments
[helm.git] / matita / dep2dot.rb
1 #!/usr/bin/ruby -w
2 # filter converting from .depend to .dot
3 # tested on .depend generated by ocamldep
4 # $Id$
5
6 require 'set'
7
8 edges = Set.new
9 $stdin.each {|line|
10   target, deps = line.split(/\s*:\s*/)
11   while deps =~ /\\\s*$/  # deal with lines continued with trailing \
12     deps.sub!(/\s*\\\s*$/, '')
13     line = $stdin.readline
14     deps += ' ' + line.lstrip
15   end
16   sources, targets = target.split, deps.split
17   for src in sources
18     for tgt in targets  # ignore file extensions
19       src.sub!(/\.[^.]+/, '')
20       tgt.sub!(/\.[^.]+/, '')
21       edges << [src, tgt] unless src == tgt   # ignore self deps
22     end
23   end
24 }
25 puts 'digraph G {'
26 for src, tgt in edges
27   print "\"#{src}\" -> \"#{tgt}\";\n"
28 end
29 puts '}'
30