forked from emolch/kiwi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjdepend.pl
executable file
·54 lines (44 loc) · 1.13 KB
/
objdepend.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl -w
use strict;
my $pn = 'objdepend';
sub aggregate {
my ($deps, $agg, $have, $entry, $depth) = @_;
$have->{$entry} = 1;
push @$agg, $entry;
foreach my $dep (@{$deps->{$entry}}) {
unless ( exists $have->{$dep} ) {
aggregate($deps, $agg, $have, $dep, $depth+1);
}
}
}
my %deps;
my @targs;
while (1) {
my $x = shift @ARGV;
defined $x or die "no -- found";
last if $x eq "--";
push @targs, $x;
}
foreach my $fn (@ARGV) {
open(IN,"<".$fn) or die $pn.": can't open file: '".$fn."'\n";
while (<IN>) {
my @toks = split /\s+:\s+/, $_;
next if scalar(@toks) != 2;
my @a = split /\s+/, $toks[0];
my @b = split /\s+/, $toks[1];
foreach my $aa (@a) {
next unless $aa;
foreach my $bb (@b) {
next unless $bb;
push @{$deps{$aa}}, $bb;
}
}
}
}
foreach my $x (@targs) {
my %have;
my @agg;
aggregate(\%deps, \@agg, \%have, $x.".o", 0);
my @objects = grep { /.o$/ } @agg;
print $x, " : ", join(" ", @objects), "\n";
}