Graphing the garnome dependencies



For a little bit of fun while waiting for the compiler, here is a little
script which makes a dot file of the dependencies in the gnome
directory.

How to use:

   * cd to the gnome directory of the unpacked garnome release
   * run the script, it will generate a garnome.dot file
   * run "dot -Tps > garnome.ps" (requires the graphviz package)
   * Use your favourite postscript viewer to view the file
   * Marvel at the mess :-)


It shows lots of unnecessary dependencies. An example would be
libmrproject which depends on glib and libxml2. The dependency on
libxml2 isn't necessary since glib depends on gtk-doc which in turn
depends on libxslt which depends on libxml2.

It is quite good fun to watch how the layout of the graph changes as the
superfluous dependencies are removed.


Cheers,
Jens

Note, it will also work in the bootstrap, misc and mono directories.
#!/usr/bin/perl -w

use strict;

my $outfile = "garnome.dot";


my @makefiles = `find . -maxdepth 2 -name Makefile`;
print "makefils: @makefiles";

open DOT, ">$outfile" or die "Failed to open $outfile for write: $!\n";
print DOT "digraph garnome {\n";

foreach my $makefile (@makefiles) {
    open FH, $makefile or die "Failed to open $makefile: $!\n";
    my @lines = <FH>;
    close FH;

    my ($garname, @deps);
    foreach (@lines) {
	if (/^GARNAME\s*=\s*(\S*)\s*/) {
	    $garname = $1;
	    next;
	}

	if (/^LIBDEPS\s*=\s*(.*)/) {
	    @deps = split " ", $1;
	    next;
	}
    }

    foreach (@deps) {
	my ($dummy, $depname) = split '/', $_;
	print DOT "\"$garname\" -> \"$depname\"\n";
    }
}
print DOT "}\n";
close DOT;


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