summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2018-03-14 13:24:12 +0100
committerRichard Levitte <levitte@openssl.org>2018-03-15 15:21:52 +0100
commit23be743286c0f0a160de33365ef34af39427eac9 (patch)
tree8bdb4a65e3e3e5cf7ccf7b3cecff32b115b00295 /util
parent27c4490521261f7f53f494140d8a2b2a239306ef (diff)
util/postprocess-makedepend.pl: make an effort to collect dependencies
Instead of just working line by line, we collect all dependencies for every target and print everything out at the end, with each target getting a potentially long list of dependencies. Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5591)
Diffstat (limited to 'util')
-rw-r--r--util/postprocess-makedepend.pl45
1 files changed, 38 insertions, 7 deletions
diff --git a/util/postprocess-makedepend.pl b/util/postprocess-makedepend.pl
index 5d0cf3d02a..323ce9e0e4 100644
--- a/util/postprocess-makedepend.pl
+++ b/util/postprocess-makedepend.pl
@@ -48,9 +48,10 @@ my $procedure = {
# Finally, discard all empty lines or comment lines
return undef if $line =~ /:\s*$/ || $line =~ /^(#.*|\s*)$/;
- $line.="\n" unless $line =~ /\R$/g;
-
- return $line;
+ my ($target, $deps) = $line =~ /^((?:\\.|[^:])*):(.*)/;
+ $deps =~ s/^\s+//;
+ $deps =~ s/\s+$//;
+ return ($target, $deps);
},
'VMS C' =>
sub {
@@ -79,7 +80,10 @@ my $procedure = {
# .TLB.
return undef if /\.TLB\s*$/;
- return $line;
+ my ($target, $deps) = $line =~ /^(.*)\s:\s(.*)/;
+ $deps =~ s/^\s+//;
+ $deps =~ s/\s+$//;
+ return ($target, $deps);
},
'VC' =>
sub {
@@ -112,7 +116,7 @@ my $procedure = {
$tail = canonpath($tail);
if ($tail =~ m|^\Q$abs_srcdir\E|i
|| $tail =~ m|^\Q$abs_blddir\E|i) {
- return "${object}: \"$tail\"\n";
+ return ($object, "\"$tail\"");
}
}
@@ -122,8 +126,35 @@ my $procedure = {
die "Producer unrecognised: $producer\n" unless defined $procedure;
+my %collect = ();
while (<STDIN>) {
- if ($_ = $procedure->($_, @ARGV)) {
- print or die "$!\n";
+ s|\R$||; # The better chomp
+ my ($target, $deps) = $procedure->($_, @ARGV);
+ $collect{$target}->{$deps} = 1
+ if defined $target;
+}
+
+my $continuation = {
+ 'makedepend' => "\\",
+ 'VMS C' => "-",
+ 'VC' => "\\",
+} -> {$producer};
+
+die "Producer unrecognised: $producer\n" unless defined $continuation;
+
+foreach my $target (sort keys %collect) {
+ my $prefix = $target . ' :';
+ my @deps = sort keys %{$collect{$target}};
+
+ while (@deps) {
+ my $buf = $prefix;
+ $prefix = '';
+
+ while (@deps && ($buf eq '' || length($buf) + length($deps[0]) <= 77)) {
+ $buf .= ' ' . shift @deps;
+ }
+ $buf .= ' '.$continuation if @deps;
+
+ print $buf,"\n";
}
}