source: branches/properties/SOURCE_TOOLS/dependency_graphs.pl

Last change on this file was 17993, checked in by westram, 5 years ago
  • improve error message when wrong library specified (e.g. if path is missing).
  • Property svn:executable set to *
File size: 2.0 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|git)/o) { ; }
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
62  # my $custom_libs = "SL/ITEMS/ITEMS.a SL/DB_QUERY/DB_QUERY.a SL/DB_UI/DB_UI.a";
63  # my $custom_libs = "SL/PVP/PVP.a SL/TREE_READ/TREE_READ.a";
64  # my $custom_libs = "arb_edit4 arb_ntree";
65  my $custom_libs   = "AWTI/AWTI.a MERGE/MERGE.a SL/ITEMS/ITEMS.a";
66
67  execute("SOURCE_TOOLS/needed_libs.pl -G ${custom_gifbase}_both.gif        -U -B -S $custom_libs");
68  execute("SOURCE_TOOLS/needed_libs.pl -G ${custom_gifbase}_inheritents.gif -U -I -S $custom_libs");
69  execute("SOURCE_TOOLS/needed_libs.pl -G ${custom_gifbase}_depends.gif     -U    -S $custom_libs");
70  execute("SOURCE_TOOLS/needed_libs.pl -G ${custom_gifbase}_reduced.gif     -U -n -S $custom_libs");
71  # ----------------------------------------
72
73  print "Waiting for childs...\n";
74  foreach (@childs) {
75    waitpid($_, 0);
76  }
77  print "All childs terminated\n";
78}
79main();
Note: See TracBrowser for help on using the repository browser.