bump product version to 4.1.6.2
[LibreOffice.git] / solenv / bin / concat-deps.pl
blob97dfc28e8d1c1c70d8ed71f7ccebf480c4ec9da2
1 #! /usr/bin/env perl
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # reads a list of dependency files from a file, opens and
11 # concatenates them, while eliding duplicate nop rules.
12 use File::Spec;
14 sub read_depfiles($)
16 my $name = shift;
17 my $depfh;
18 my @files;
19 open ($depfh, $name) || die "Can't open list of dependencies: $name: $!";
20 while (<$depfh>) {
21 push @files, split(/\s+/, $_);
23 close ($depfh);
25 # print STDERR "dep files: " . join ("'", @files) . "\n";
26 return @files;
29 my @depfiles = read_depfiles (shift @ARGV);
31 my %rules;
32 print "# concatenated, reduced dependencies generated by solenv/bin/concat-deps.pl\n";
33 print "# generated with \$(SRCDIR) = $ENV{SRCDIR}\n";
34 print "# generated with \$(OUTDIR) = $ENV{OUTDIR}\n";
36 my $boost_path = $ENV{OUTDIR} . '/inc/boost/';
38 for my $fname (@depfiles) {
39 my $fileh;
41 next if ($fname eq '');
42 open ($fileh, $fname) || die "Can't open $fname: $!\n";
44 my $last = '';
45 my $rule_count = 0;
46 my $with_boost_count = 0;
47 while (<$fileh>) {
48 # canonicalise path
49 m/^(\s*)([^\s\n:]*)(.*\n?)$/;
50 my $pre = $1;
51 my $path = $2;
52 my $post = $3;
53 $rule_count++ if ($post =~ m/:/);
54 if (length($path) > 0 && index($path,$ENV{SRCDIR}) == 0) {
55 $path = File::Spec->rel2abs($2);
56 if (index($path,$ENV{OUTDIR}) == 0) {
57 my $solverpath = substr($path, length($ENV{OUTDIR}));
58 if ($solverpath =~ m|/inc/boost/|) {
59 if ($with_boost_count != $rule_count || !($post =~ m/\\/)) {
60 $path = '$(OUTDIR)/inc/boost/deliver.log';
61 $with_boost_count = $rule_count;
62 } else { # elide it
63 $path = ''; $pre = ''; $post = '';
65 } else {
66 $path = "\$(OUTDIR)" . $solverpath;
68 } else {
69 $path = "\$(SRCDIR)" . substr($path, length($ENV{SRCDIR}));
72 $line = "$pre$path$post";
74 if ($line eq "\n") {
75 if ($last =~ /^(.*):\s*$/) {
76 if (defined $rules{$1}) {
77 $last = '';
78 next;
80 $rules{$1} = 1;
83 print $last;
84 $last = $line;
86 print "$last\n"; # in case of missing newline
88 close ($fileh);