Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / codesighs / autosummary.win.bash
blobd501625b0aef3bde20aefda947aa43d3157bbbd7
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 autosummary.win.bash code, released
17 # Oct 3, 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, 03-October-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 *****
42 # Check for optional objdir
44 if [ "$1" = "-o" ]; then
45 OBJROOT="$2"
46 shift
47 shift
48 else
49 OBJROOT="./mozilla"
52 if [ "$1" = "-s" ]; then
53 SRCROOT="$2"
54 shift
55 shift
56 else
57 SRCROOT="./mozilla"
61 # A little help for my friends.
63 if [ "-h" == "$1" ];then
64 SHOWHELP="1"
66 if [ "--help" == "$1" ];then
67 SHOWHELP="1"
69 if [ "" == "$1" ]; then
70 SHOWHELP="1"
72 if [ "" == "$2" ]; then
73 SHOWHELP="1"
75 if [ "" == "$3" ]; then
76 SHOWHELP="1"
81 # Show the help if required.
83 if [ $SHOWHELP ]; then
84 echo "usage: $0 <save_results> <old_results> <summary>"
85 echo " <save_results> is a file that will receive the results of this run."
86 echo " This file can be used in a future run as the old results."
87 echo " <old_results> is a results file from a previous run."
88 echo " It is used to diff with current results and come up with a summary"
89 echo " of changes."
90 echo " It is OK if the file does not exist, just supply the argument."
91 echo " <summary> is a file which will contain a human readable report."
92 echo " This file is most useful by providing more information than the"
93 echo " normally single digit output of this script."
94 echo ""
95 echo "Run this command from the parent directory of the mozilla tree."
96 echo ""
97 echo "This command will output two numbers to stdout that will represent"
98 echo " the total size of all code and data, and a delta from the prior."
99 echo " the old results."
100 echo "For much more detail on size drifts refer to the summary report."
101 echo ""
102 echo "This tool reports on all executables in the directory tree."
103 exit
108 # Stash our arguments away.
110 COPYSORTTSV="$1"
111 OLDTSVFILE="$2"
112 SUMMARYFILE="$3"
116 # Create our temporary directory.
118 MYTMPDIR=`mktemp -d ./codesighs.tmp.XXXXXXXX`
122 # Find the types of files we are interested in.
124 ONEFINDPASS="$MYTMPDIR/onefind.list"
125 /usr/bin/find $OBJROOT -type f -name "*.obj" -or -name "*.map" | while read FNAME; do
126 cygpath -m $FNAME >> $ONEFINDPASS
127 done
131 # Find all object files.
133 ALLOBJSFILE="$MYTMPDIR/allobjs.list"
134 grep -i "\.obj$" < $ONEFINDPASS > $ALLOBJSFILE
138 # Get a dump of the symbols in every object file.
140 ALLOBJSYMSFILE="$MYTMPDIR/allobjsyms.list"
141 xargs -n 1 dumpbin.exe /symbols < $ALLOBJSFILE > $ALLOBJSYMSFILE 2> /dev/null
145 # Produce the symdb for the symbols in all object files.
147 SYMDBFILE="$MYTMPDIR/symdb.tsv"
148 $OBJROOT/dist/bin/msdump2symdb --input $ALLOBJSYMSFILE | /usr/bin/sort > $SYMDBFILE 2> /dev/null
152 # Find all map files.
154 ALLMAPSFILE="$MYTMPDIR/allmaps.list"
155 grep -i "\.map$" < $ONEFINDPASS > $ALLMAPSFILE
159 # Produce the TSV output.
161 RAWTSVFILE="$MYTMPDIR/raw.tsv"
162 $OBJROOT/dist/bin/msmap2tsv --symdb $SYMDBFILE --batch < $ALLMAPSFILE > $RAWTSVFILE 2> /dev/null
166 # Sort the TSV output for useful diffing and eyeballing in general.
168 /usr/bin/sort -r $RAWTSVFILE > $COPYSORTTSV
172 # If a historical file was specified, diff it with our sorted tsv values.
173 # Run it through a tool to summaries the diffs to the module
174 # level report.
175 # Otherwise, generate the module level report from our new data.
177 rm -f $SUMMARYFILE
178 DIFFFILE="$MYTMPDIR/diff.txt"
179 if [ -e $OLDTSVFILE ]; then
180 diff $OLDTSVFILE $COPYSORTTSV > $DIFFFILE
181 $OBJROOT/dist/bin/maptsvdifftool --negation --input $DIFFFILE | dos2unix >> $SUMMARYFILE
182 else
183 $OBJROOT/dist/bin/codesighs --modules --input $COPYSORTTSV | dos2unix >> $SUMMARYFILE
188 # Output our numbers, that will let tinderbox specify everything all
189 # at once.
190 # First number is in fact the total size of all code and data in the map
191 # files parsed.
192 # Second number, if present, is growth/shrinkage.
195 if [ $TINDERBOX_OUTPUT ]; then
196 echo -n "__codesize:"
198 $OBJROOT/dist/bin/codesighs --totalonly --input $COPYSORTTSV | dos2unix
201 if [ -e $DIFFFILE ]; then
202 if [ $TINDERBOX_OUTPUT ]; then
203 echo -n "__codesizeDiff:"
205 $OBJROOT/dist/bin/maptsvdifftool --negation --summary --input $DIFFFILE | dos2unix
209 # Remove our temporary directory.
211 rm -rf $MYTMPDIR