[sgen] Fix logging of major heap size with concurrent sweep
[mono.git] / mcs / build / gensources.sh
1 #! /bin/sh
2
3 outfile=$1
4 incfile=$2
5 excfile=$3
6 extfile=$4
7 extexcfile=$5
8
9 process_includes_1() {
10     sed -e '/^[ \t]*$/d' -e '/^[ \t]*#/d' $1 > $2
11     if cmp -s $1 $2; then
12         false
13     else
14         sed -n 's,^[ \t]*#include ,,p' $1 |
15         while read inc; do
16             cat $inc >> $2
17             echo $outfile: $inc >> $outfile.makefrag
18             echo $inc: >> $outfile.makefrag
19         done
20     fi
21 }
22
23 process_includes() {
24     i=$1; o=$2; t=${2}.tmp
25     while process_includes_1 $i $o; do
26         mv $o $t
27         i=$t
28     done
29     rm -f $t
30 }
31
32 rm -f $outfile.makefrag
33
34 process_includes $incfile $outfile.inc
35
36 if test x$extfile != x -a -f "$extfile"; then
37         process_includes $extfile $outfile.ext.inc
38         cat $outfile.ext.inc >> $outfile.inc
39         rm -f $outfile.ext.inc
40 fi
41
42 sort -u $outfile.inc > $outfile.inc_s
43 rm -f $outfile.inc
44
45
46 if test -n "$excfile"; then
47     process_includes $excfile $outfile.exc
48 fi
49
50 if test -n "$extexcfile"; then
51     process_includes $extexcfile $outfile.ext_exc
52         cat $outfile.ext_exc >> $outfile.exc
53         rm -f $outfile.ext_exc
54 fi
55
56 if test -f $outfile.exc; then
57         # So what we're doing below with uniq -u is that we take 
58         # lines that have not been duplicated. This computes the 
59         # symmetric difference between the files. This is not
60         # what we want. If a file is in the excludes but not in
61         # the sources, we want that file not to show up. By duplicating the
62         # excludes, we ensure that we won't end up in this failure state.
63         sort -u $outfile.exc > $outfile.exc_s
64
65         # Duplicate excludes
66         cat $outfile.exc_s >> $outfile.exc_s_dup
67         cat $outfile.exc_s >> $outfile.exc_s_dup
68
69         rm -f $outfile.exc $outfile.exc_s
70
71         cat $outfile.inc_s $outfile.exc_s_dup | sort | uniq -u > $outfile
72         rm -f $outfile.inc_s $outfile.exc_s_dup
73 else
74         mv $outfile.inc_s $outfile
75 fi
76
77