blob: e360dbc280cb6a1cde167d6eb7c66801996f55a1 (
plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#! /usr/bin/env perl
# reads a list of dependency files from a file, opens and
# concatenates them, while eliding duplicate nop rules.
use File::Spec;
sub read_depfiles($)
{
my $name = shift;
my $depfh;
my @files;
open ($depfh, $name) || die "Can't open list of dependencies: $name: $!";
while (<$depfh>) {
push @files, split(/\s+/, $_);
}
close ($depfh);
# print STDERR "dep files: " . join ("'", @files) . "\n";
return @files;
}
my @depfiles = read_depfiles (shift @ARGV);
my %rules;
print "# concatenated, reduced dependencies generated by solenv/bin/concat-deps.pl\n";
print "# generated with \$(SRCDIR) = $ENV{SRCDIR}\n";
print "# generated with \$(OUTDIR) = $ENV{OUTDIR}\n";
my $boost_path = $ENV{OUTDIR} . '/inc/boost/';
for my $fname (@depfiles) {
my $fileh;
next if ($fname eq '');
open ($fileh, $fname) || die "Can't open $fname: $!\n";
my $last = '';
my $rule_count = 0;
my $with_boost_count = 0;
while (<$fileh>) {
# canonicalise path
m/^(\s*)([^\s\n:]*)(.*\n?)$/;
my $pre = $1;
my $path = $2;
my $post = $3;
$rule_count++ if ($post =~ m/:/);
if (length($path) > 0 && index($path,$ENV{SRCDIR}) == 0) {
$path = File::Spec->rel2abs($2);
if (index($path,$ENV{OUTDIR}) == 0) {
my $solverpath = substr($path, length($ENV{OUTDIR}));
if ($solverpath =~ m|/inc/boost/|) {
if ($with_boost_count != $rule_count || !($post =~ m/\\/)) {
$path = '$(OUTDIR)/inc/boost/deliver.log';
$with_boost_count = $rule_count;
} else { # elide it
$path = ''; $pre = ''; $post = '';
}
} else {
$path = "\$(OUTDIR)" . $solverpath;
}
} else {
$path = "\$(SRCDIR)" . substr($path, length($ENV{SRCDIR}));
}
}
$line = "$pre$path$post";
if ($line eq "\n") {
if ($last =~ /^(.*):\s*$/) {
if (defined $rules{$1}) {
$last = '';
next;
}
$rules{$1} = 1;
}
}
print $last;
$last = $line;
}
print "$last\n"; # in case of missing newline
close ($fileh);
}
|