guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Module dependency graph


From: Keisuke Nishida
Subject: Module dependency graph
Date: Tue, 13 Mar 2001 21:19:53 -0500
User-agent: Wanderlust/2.4.0 (Rio) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.0.99 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)

This is a little tool that generates a diagram of Guile's
module dependency.  An example output can be found at

  http://home.cwru.edu/~kxn30/module-dep.ps

How To Generate
---------------

  1. Save the following script with some name, say "use2dot.pl".

  2. Download Graphviz (http://www.research.att.com/sw/tools/graphviz/)
     and install it.

  3. Do the following:

     % perl use2dot.pl /usr/local/share/guile/1.4.1 > module-dep.dot
     % dot -Tps module-dep.dot -o module-dep.ps

Kei

------------------------------------------------------------------------
#!/usr/bin/perl

use File::Find;

# Header
print "digraph use2dot {\n";
print "  label = \"Guile Module Dependencies\";\n";
print "  rankdir = LR;\n";
print "  size = \"7.5,10\";\n";
print "  ratio = fill;\n";
print "  nodesep = \"0.05\";\n";

# Body
@ARGV = ('.') unless @ARGV;
while ($dir = shift) {
  find(\&wanted, $dir);
}

sub wanted {
  my $module;
  my @use;
  if (/\.scm$/) {
    open (SOURCE, $_) or die;
    while (<SOURCE>) {
      $module = $1 if (/define-module *(\([^\)]*\))/);
      push(@use, $1) if (/:use-module *(\([^\)]*\))/);
    }
    foreach $u (@use) {
      print "  \"$module\" -> \"$u\";\n";
    }
    close (SOURCE);
  }
}

# Footer
print "}\n";



reply via email to

[Prev in Thread] Current Thread [Next in Thread]