source: tags/ms_r16q3/SOURCE_TOOLS/dependency_graphs.pl

Last change on this file was 14425, checked in by westram, 8 years ago
  • Property svn:executable set to *
File size: 1.9 KB
Line 
1#!/usr/bin/perl
2
3my $ARBHOME = $ENV{ARBHOME};
4if (not -d $ARBHOME) {
5  die "ARBHOME has to be defined and has to mark a directory";
6}
7chdir($ARBHOME);
8
9sub make_suffix($) {
10  my ($name) = @_;
11
12  $name =~ s/[\/\.]/_/g;
13
14  $name =~ s/needs_libs//;
15
16  $name =~ s/__*/_/g;
17  $name =~ s/^_//;
18  $name =~ s/_$//;
19
20  return $name;
21}
22
23sub execute($) {
24  my ($cmd) = @_;
25  system($cmd)==0 || die "error calling '$cmd'";
26}
27
28sub main() {
29  my @dep_files = map {
30    if (/\.svn/) { ; }
31    else { chomp; s/^\.\///; $_; }
32  } `cd $ARBHOME;find . -name "needs_libs*"`;
33
34  my %gif_suffix = map { $_ => make_suffix($_); } @dep_files;
35
36  my $dest = 'dep_graphs';
37  if (not -d $dest) {
38    mkdir($dest) || die "can't create dir '$dest' (Reason: $!)";
39  }
40
41  my @childs = ();
42  foreach (@dep_files) {
43    my $pid = fork();
44    while (not defined $pid) {
45      print "Warning: could not fork\n";
46      sleep(1);
47      $pid = fork(); # retry
48    }
49    if ($pid == 0) { # child
50      my $destgif = "$dest/".$gif_suffix{$_}.".gif";
51      execute("SOURCE_TOOLS/needed_libs.pl -G $destgif -U -B -S $_");
52      exit(0);
53    }
54
55    push @childs, $pid;
56  }
57
58  # ----------------------------------------
59  # create custom dependency gifs:
60  my $custom_gifbase = "$dest/custom";
61  # my $custom_libs    = "SL/ITEMS/ITEMS.a SL/DB_QUERY/DB_QUERY.a SL/DB_UI/DB_UI.a";
62  my $custom_libs    = "arb_edit4 arb_ntree";
63
64  execute("SOURCE_TOOLS/needed_libs.pl -G ${custom_gifbase}_both.gif        -U -B -S $custom_libs");
65  execute("SOURCE_TOOLS/needed_libs.pl -G ${custom_gifbase}_inheritents.gif -U -I -S $custom_libs");
66  execute("SOURCE_TOOLS/needed_libs.pl -G ${custom_gifbase}_depends.gif     -U    -S $custom_libs");
67  execute("SOURCE_TOOLS/needed_libs.pl -G ${custom_gifbase}_reduced.gif     -U -n -S $custom_libs");
68  # ----------------------------------------
69
70  print "Waiting for childs...\n";
71  foreach (@childs) {
72    waitpid($_, 0);
73  }
74  print "All childs terminated\n";
75}
76main();
Note: See TracBrowser for help on using the repository browser.