android: disable NLS when building yasm.
[chromium-blink-merge.git] / third_party / codesighs / basesummary.win.bash
blob1e05859060784342337b48d24fe5376e8bfbf76a
1 #!/bin/bash
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
16 # The Original Code is basesummary.win.bash code, released
17 # Nov 15, 2002.
19 # The Initial Developer of the Original Code is
20 # Netscape Communications Corporation.
21 # Portions created by the Initial Developer are Copyright (C) 2002
22 # the Initial Developer. All Rights Reserved.
24 # Contributor(s):
25 # Garrett Arch Blythe, 15-November-2002
27 # Alternatively, the contents of this file may be used under the terms of
28 # either the GNU General Public License Version 2 or later (the "GPL"), or
29 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 # in which case the provisions of the GPL or the LGPL are applicable instead
31 # of those above. If you wish to allow use of your version of this file only
32 # under the terms of either the GPL or the LGPL, and not to allow others to
33 # use your version of this file under the terms of the MPL, indicate your
34 # decision by deleting the provisions above and replace them with the notice
35 # and other provisions required by the GPL or the LGPL. If you do not delete
36 # the provisions above, a recipient may use your version of this file under
37 # the terms of any one of the MPL, the GPL or the LGPL.
39 # ***** END LICENSE BLOCK *****
43 # Check for optional objdir
45 if [ "$1" = "-o" ]; then
46 OBJROOT="$2"
47 shift
48 shift
49 else
50 OBJROOT="./mozilla"
53 if [ "$1" = "-s" ]; then
54 SRCROOT="$2"
55 shift
56 shift
57 else
58 SRCROOT="./mozilla"
61 MANIFEST="$SRCROOT/embedding/config/basebrowser-win"
64 # A little help for my friends.
66 if [ "-h" == "$1" ];then
67 SHOWHELP="1"
69 if [ "--help" == "$1" ];then
70 SHOWHELP="1"
72 if [ "" == "$1" ]; then
73 SHOWHELP="1"
75 if [ "" == "$2" ]; then
76 SHOWHELP="1"
78 if [ "" == "$3" ]; then
79 SHOWHELP="1"
84 # Show the help if required.
86 if [ $SHOWHELP ]; then
87 echo "usage: $0 <save_results> <old_results> <summary>"
88 echo " <save_results> is a file that will receive the results of this run."
89 echo " This file can be used in a future run as the old results."
90 echo " <old_results> is a results file from a previous run."
91 echo " It is used to diff with current results and come up with a summary"
92 echo " of changes."
93 echo " It is OK if the file does not exist, just supply the argument."
94 echo " <summary> is a file which will contain a human readable report."
95 echo " This file is most useful by providing more information than the"
96 echo " normally single digit output of this script."
97 echo ""
98 echo "Run this command from the parent directory of the mozilla tree."
99 echo ""
100 echo "This command will output two numbers to stdout that will represent"
101 echo " the total size of all code and data, and a delta from the prior."
102 echo " the old results."
103 echo "For much more detail on size drifts refer to the summary report."
104 echo ""
105 echo "This tool reports on executables listed in the following file:"
106 echo "$MANIFEST"
107 exit
112 # Stash our arguments away.
114 COPYSORTTSV="$1"
115 OLDTSVFILE="$2"
116 SUMMARYFILE="$3"
120 # Create our temporary directory.
122 MYTMPDIR=`mktemp -d ./codesighs.tmp.XXXXXXXX`
126 # Find the types of files we are interested in.
128 ONEFINDPASS="$MYTMPDIR/onefind.list"
129 /usr/bin/find $OBJROOT -type f -name "*.obj" -or -name "*.map" | while read FNAME; do
130 cygpath -m $FNAME >> $ONEFINDPASS
131 done
135 # Find all object files.
137 ALLOBJSFILE="$MYTMPDIR/allobjs.list"
138 grep -i "\.obj$" < $ONEFINDPASS > $ALLOBJSFILE
142 # Get a dump of the symbols in every object file.
144 ALLOBJSYMSFILE="$MYTMPDIR/allobjsyms.list"
145 xargs -n 1 dumpbin.exe /symbols < $ALLOBJSFILE > $ALLOBJSYMSFILE 2> /dev/null
149 # Produce the symdb for the symbols in all object files.
151 SYMDBFILE="$MYTMPDIR/symdb.tsv"
152 $OBJROOT/dist/bin/msdump2symdb --input $ALLOBJSYMSFILE | /usr/bin/sort > $SYMDBFILE 2> /dev/null
156 # Find all map files.
158 ALLMAPSFILE="$MYTMPDIR/allmaps.list"
159 grep -i "\.map$" < $ONEFINDPASS > $ALLMAPSFILE
163 # Figure out which modules in specific we care about.
164 # The relevant set meaning that the map file name prefix must be found
165 # in the file mozilla/embedding/config/basebrowser-win.
167 RELEVANTSETFILE="$MYTMPDIR/relevant.set"
168 grep -v '\;' < $MANIFEST | sed 's/.*\\//' | grep '\.[eEdD][xXlL][eElL]' | sed 's/\.[eEdD][xXlL][eElL]//' > $RELEVANTSETFILE
169 RELEVANTARG=`xargs -n 1 echo --match-module < $RELEVANTSETFILE`
173 # Produce the TSV output.
175 RAWTSVFILE="$MYTMPDIR/raw.tsv"
176 $OBJROOT/dist/bin/msmap2tsv --symdb $SYMDBFILE --batch $RELEVANTARG < $ALLMAPSFILE > $RAWTSVFILE 2> /dev/null
180 # Sort the TSV output for useful diffing and eyeballing in general.
182 /usr/bin/sort -r $RAWTSVFILE > $COPYSORTTSV
186 # If a historical file was specified, diff it with our sorted tsv values.
187 # Run it through a tool to summaries the diffs to the module
188 # level report.
189 # Otherwise, generate the module level report from our new data.
191 rm -f $SUMMARYFILE
192 DIFFFILE="$MYTMPDIR/diff.txt"
193 if [ -e $OLDTSVFILE ]; then
194 diff $OLDTSVFILE $COPYSORTTSV > $DIFFFILE
195 $OBJROOT/dist/bin/maptsvdifftool --negation --input $DIFFFILE | dos2unix >> $SUMMARYFILE
196 else
197 $OBJROOT/dist/bin/codesighs --modules --input $COPYSORTTSV | dos2unix >> $SUMMARYFILE
202 # Output our numbers, that will let tinderbox specify everything all
203 # at once.
204 # First number is in fact the total size of all code and data in the map
205 # files parsed.
206 # Second number, if present, is growth/shrinkage.
209 if [ $TINDERBOX_OUTPUT ]; then
210 echo -n "__codesize:"
212 $OBJROOT/dist/bin/codesighs --totalonly --input $COPYSORTTSV | dos2unix
214 if [ -e $DIFFFILE ]; then
215 if [ $TINDERBOX_OUTPUT ]; then
216 echo -n "__codesizeDiff:"
218 $OBJROOT/dist/bin/maptsvdifftool --negation --summary --input $DIFFFILE | dos2unix
222 # Remove our temporary directory.
224 rm -rf $MYTMPDIR