From 7ef09d323f2de715aacb8fc56854efa41b746282 Mon Sep 17 00:00:00 2001 From: bala Date: Sat, 15 Dec 2001 17:19:26 +0000 Subject: ChangeLogTag: --- ChangeLog_Reactor_Rewrite | 5 + bin/dep.pl | 244 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+) create mode 100755 bin/dep.pl diff --git a/ChangeLog_Reactor_Rewrite b/ChangeLog_Reactor_Rewrite index 8684eefb428..cae4353dc5a 100644 --- a/ChangeLog_Reactor_Rewrite +++ b/ChangeLog_Reactor_Rewrite @@ -1,3 +1,8 @@ +Sat Dec 15 11:17:35 2001 Balachandran Natarajan + + * bin/dep.pl: Script to generate dependecies. To be run as "dep.pl + . Script given by Carlos. + Fri Dec 14 07:00:50 2001 Balachandran Natarajan * Merged with the main trunk and moved things to a new branch. diff --git a/bin/dep.pl b/bin/dep.pl new file mode 100755 index 00000000000..038df36097a --- /dev/null +++ b/bin/dep.pl @@ -0,0 +1,244 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# -*- perl -*- +# $Id$ + +$DESTINATION = shift; + +use File::Basename; + +# Compute the dependencies using lorder +@DEPS = (); +@FILES = (); + +open(LORDER, "lorder ".join(' ',@ARGV)." |") + || die "Cannot run lorder\n"; +while() { + chomp; + @files = split ' '; + + my ($source,,) = fileparse($files[0],"\.o"); + my ($target,,) = fileparse($files[1],"\.o"); + push @FILES, $source; + push @FILES, $target; + push @DEPS, join(':', $source, $target); +} +close (LORDER); + +@DEPS = &unique(@DEPS); +@FILES = &unique(@FILES); + +#foreach $i (@DEPS) { +# print $i, "\n"; +#} + +my $doxfont_source = $ENV{'HOME'}; +system ("cp $doxfont_source/doxfont.ttf doxfont.ttf"); + +foreach $file (@FILES) { + my @dotfile = &gen_deps_dot_file ($file, '_deps', @DEPS); + &gen_files ($file, '_deps', + $file.' Direct Dependencies', @dotfile); +} +my @fulldotfile = &gen_dot_file('index', "_deps", @DEPS); +&gen_files ('index', '_deps', + 'Full Dependencies for All Files', @fulldotfile); + +foreach $file (@FILES) { + my @dotfile = &gen_closure_dot_file ($file, '_close', @DEPS); + &gen_files ($file, '_close', + $file.' Direct and Indirect Dependencies', @dotfile); +} + +if (0) { +@fulldotfile = &gen_dot_file('AllFiles', "_close", @DEPS); +&gen_files ('AllFiles', '_close', + 'Full Dependencies for All Files', @fulldotfile); +} + +################################################################ + +sub unique { + my $last = ''; + my @uniq = (); + foreach my $i (sort @_) { + if ($i eq $last) { + next; + } + push @uniq, $i; + $last = $i; + } + return @uniq; +} + +sub deps_for_file { + my $file = shift; + + my @deps = (); + foreach my $i (@_) { + if ($i =~ m/^$file\:/ + || $i =~ m/:$file$/) { + push @deps, $i; + } + } + return @deps; +} + +sub gen_deps_dot_file { + my $file = shift; + my $suffix = shift; + + my @related = &deps_for_file ($file, @_); + + return &gen_dot_file ($file, $suffix, @related); +} + +sub file_deps { + my $file = shift; + + my @deps = (); + foreach my $i (@_) { + if ($i =~ m/^$file\:/) { + push @deps, $i; + } + } + return @deps; +} + +sub gen_closure_dot_file { + my $file = shift; + my $suffix = shift; + + my @related = &file_deps ($file, @_); + + my $count = $#related; + for (;;) { + my @list = @related; + foreach my $i (@related) { + my @f = split ':', $i; + push @list, &file_deps ($f[0], @_); + push @list, &file_deps ($f[1], @_); + } + @related = &unique (sort @list); + if ($count == $#related) { + last; + } + $count = $#related; + } + + foreach my $i (@_) { + if ($i =~ m/:$file$/) { + push @related, $i; + } + } + @related = &unique (sort @related); + + return &gen_dot_file ($file, $suffix, @related); +} + +sub gen_dot_file { + my $file = shift; + my $suffix = shift; + my @related = @_; + + my @dot_file = (); + push @dot_file, ("digraph $file {\n", + " size=\"50,50\";\n", + " rankdir=LR;\n", + " node [fontname=doxfont,shape=box," + ."color=green,style=filled];\n", + " $file [color=red];\n"); + + my @other_files = &unique(map {split ':'} @related); + + foreach my $other (@other_files) { + my $htmlother = $other.$suffix.".html"; + if ($other eq $file) { + my $alt = '_deps'; + if ($suffix eq '_deps') { + $alt = '_close'; + } + $htmlother = $other.$alt.".html"; + } + push @dot_file, " $other [URL=\"$htmlother\"];\n"; + } + foreach my $d (@related) { + my @f = split ':', $d; + if ($f[0] eq $f[1]) { + next; + } + push @dot_file, " ".$f[0].' -> '.$f[1].";\n"; + } + push @dot_file, "}\n"; + return @dot_file; +} + +sub gen_files { + my $file = shift; + my $suffix = shift; + my $title = shift; + my @dotfile = @_; + + my $htmlfile = $DESTINATION."/".$file.$suffix.".html"; + my $ismapfile = $DESTINATION."/".$file.$suffix.".ismap"; + my $gifbase = $file.$suffix.".gif"; + my $giffile = $DESTINATION."/".$gifbase; + + #print "######\n"; + #print @dotfile; + #print "######\n"; + open (DOT, "|/usr/local/bin/dot -Tgif -o $giffile") + || die "Cannot run 'dot' to generate the GIF file for $file\n"; + print DOT @dotfile; + close(DOT) + || die "Error when closing 'dot' for $file GIF's\n"; + + open (DOT, "|/usr/local/bin/dot -Tismap -o $ismapfile") + || die "Cannot run 'dot' to generate the ISMAP file for $file\n"; + print DOT @dotfile; + close(DOT) + || die "Error when closing 'dot' for $file ISMAP's\n"; + + open (HTML, ">".$htmlfile) + || die "Cannot open HTML output for $file\n"; + print HTML <<_HEADER_; + + + + $title + + + +
+

$title

+ + +
+ +_HEADER_ + + open (ISMAP, $ismapfile) + || die "Cannot open $file ISMAP for reading\n"; + while () { + chomp; + s/\(//g; + s/\)//g; + s/,/ /g; + my @f = split ' '; + print HTML "\n\n"; + } + close (ISMAP) + || die "Error closing $file ISMAP\n"; + print HTML <<_FOOTER_; + + + +_FOOTER_ + close(HTML) + || die "Error closing HTML output for $file\n"; + +} -- cgit v1.2.1