Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: third_party/codesighs/autosummary.unix.bash

Issue 93155: Capture Mozilla's codesighs, for use in executable sizing.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/codesighs/README.chromium ('k') | third_party/codesighs/autosummary.win.bash » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:executable
+ *
OLDNEW
(Empty)
1 #!/bin/bash
2 #
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 #
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/
10 #
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.
15 #
16 # The Original Code is autosummary.linx.bash code, released
17 # Oct 10, 2002.
18 #
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.
23 #
24 # Contributor(s):
25 # Garrett Arch Blythe, 10-October-2002
26 # Simon Fraser <sfraser@netscape.com>
27 #
28 # Alternatively, the contents of this file may be used under the terms of
29 # either the GNU General Public License Version 2 or later (the "GPL"), or
30 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 # in which case the provisions of the GPL or the LGPL are applicable instead
32 # of those above. If you wish to allow use of your version of this file only
33 # under the terms of either the GPL or the LGPL, and not to allow others to
34 # use your version of this file under the terms of the MPL, indicate your
35 # decision by deleting the provisions above and replace them with the notice
36 # and other provisions required by the GPL or the LGPL. If you do not delete
37 # the provisions above, a recipient may use your version of this file under
38 # the terms of any one of the MPL, the GPL or the LGPL.
39 #
40 # ***** END LICENSE BLOCK *****
41
42 #
43 # Check for optional objdir
44 #
45 if [ "$1" = "-o" ]; then
46 OBJROOT="$2"
47 shift
48 shift
49 else
50 OBJROOT="./mozilla"
51 fi
52
53 if [ "$1" = "-s" ]; then
54 SRCROOT="$2"
55 shift
56 shift
57 else
58 SRCROOT="./mozilla"
59 fi
60
61 #
62 # A little help for my friends.
63 #
64 if [ "-h" == "$1" ];then
65 SHOWHELP="1"
66 fi
67 if [ "--help" == "$1" ];then
68 SHOWHELP="1"
69 fi
70 if [ "" == "$1" ]; then
71 SHOWHELP="1"
72 fi
73 if [ "" == "$2" ]; then
74 SHOWHELP="1"
75 fi
76 if [ "" == "$3" ]; then
77 SHOWHELP="1"
78 fi
79
80
81 #
82 # Show the help if required.
83 #
84 if [ $SHOWHELP ]; then
85 echo "usage: $0 <save_results> <old_results> <summary>"
86 echo " <save_results> is a file that will receive the results of this run."
87 echo " This file can be used in a future run as the old results."
88 echo " <old_results> is a results file from a previous run."
89 echo " It is used to diff with current results and come up with a summary "
90 echo " of changes."
91 echo " It is OK if the file does not exist, just supply the argument."
92 echo " <summary> is a file which will contain a human readable report."
93 echo " This file is most useful by providing more information than the"
94 echo " normally single digit output of this script."
95 echo ""
96 echo "Run this command from the parent directory of the mozilla tree."
97 echo ""
98 echo "This command will output two numbers to stdout that will represent"
99 echo " the total size of all code and data, and a delta from the prior."
100 echo " the old results."
101 echo "For much more detail on size drifts refer to the summary report."
102 echo ""
103 echo "This tool reports on all executables in the directory tree."
104 exit
105 fi
106
107 #
108 # Stash our arguments away.
109 #
110 COPYSORTTSV="$1"
111 OLDTSVFILE="$2"
112 SUMMARYFILE="$3"
113
114 OSTYPE=`uname -s`
115
116 #
117 # On Mac OS X, use the --zerodrift option to maptsvdifftool
118 #
119 if [ $OSTYPE == "Darwin" ]; then
120 ZERODRIFT="--zerodrift"
121 else
122 ZERODRIFT=""
123 fi
124
125 #
126 # Create our temporary directory.
127 # mktemp on Darwin doesn't support -d (suckage)
128 #
129 if [ $OSTYPE == "Darwin" ]; then
130 ZERODRIFT="--zerodrift"
131 MYTMPDIR=`mktemp ./codesighs.tmp.XXXXXXXX`
132 rm $MYTMPDIR
133 mkdir $MYTMPDIR
134 else
135 MYTMPDIR=`mktemp -d ./codesighs.tmp.XXXXXXXX`
136 fi
137
138 #
139 # Find all relevant files.
140 #
141 ALLFILES="$MYTMPDIR/allfiles.list"
142
143 if [ $OSTYPE == "Darwin" ] || [ $OSTYPE == "SunOS" ]; then
144 find $OBJROOT/dist/bin ! -type d > $ALLFILES
145 else
146 find $OBJROOT/dist/bin -not -type d > $ALLFILES
147 fi
148
149 # Check whether we have 'eu-readelf' or 'readelf' available.
150 # If we do, it will give more accurate symbol sizes than nm.
151
152 if [ $OSTYPE == "Darwin" ]; then
153 USE_READELF=
154 else
155 READELF_PROG=`which eu-readelf 2>/dev/null | grep /eu-readelf$`
156 if test "$READELF_PROG"; then
157 USE_READELF=1
158 else
159 READELF_PROG=`which readelf 2>/dev/null | grep /readelf$`
160 if test "$READELF_PROG"; then
161 # Check whether we need -W
162 if readelf --help | grep "\--wide" >&/dev/null; then
163 READELF_PROG="readelf -W"
164 else
165 READELF_PROG="readelf"
166 fi
167 USE_READELF=1
168 else
169 USE_READELF=
170 fi
171 fi
172 fi
173
174 RAWTSVFILE="$MYTMPDIR/raw.tsv"
175 if test "$USE_READELF"; then
176 export READELF_PROG
177 xargs -n 1 $SRCROOT/tools/codesighs/readelf_wrap.pl < $ALLFILES > $RAWTSVFILE 2> /dev/null
178 else
179
180 #
181 # Produce the cumulative nm output.
182 # We are very particular on what switches to use.
183 # nm --format=bsd --size-sort --print-file-name --demangle
184 #
185 # Darwin (Mac OS X) has a lame nm that we have to wrap in a perl
186 # script to get decent output.
187 #
188 NMRESULTS="$MYTMPDIR/nm.txt"
189 if [ $OSTYPE == "Darwin" ]; then
190 xargs -n 1 $SRCROOT/tools/codesighs/nm_wrap_osx.pl < $ALLFILES > $NMRESULTS 2> /dev/null
191 else
192 xargs -n 1 nm --format=bsd --size-sort --print-file-name --demangle < $ALLFILES > $NMRESULTS 2> /dev/null
193 fi
194
195
196 #
197 # Produce the TSV output.
198 #
199
200 $OBJROOT/dist/bin/nm2tsv --input $NMRESULTS > $RAWTSVFILE
201
202 fi # USE_READELF
203
204 #
205 # Sort the TSV output for useful diffing and eyeballing in general.
206 #
207 sort -r $RAWTSVFILE > $COPYSORTTSV
208
209
210 #
211 # If a historical file was specified, diff it with our sorted tsv values.
212 # Run it through a tool to summaries the diffs to the module
213 # level report.
214 # Otherwise, generate the module level report from our new data.
215 #
216
217 rm -f $SUMMARYFILE
218 DIFFFILE="$MYTMPDIR/diff.txt"
219 if [ -e $OLDTSVFILE ]; then
220 diff $OLDTSVFILE $COPYSORTTSV > $DIFFFILE
221 $OBJROOT/dist/bin/maptsvdifftool $ZERODRIFT --input $DIFFFILE >> $SUMMARYFILE
222 else
223 $OBJROOT/dist/bin/codesighs --modules --input $COPYSORTTSV >> $SUMMARYFILE
224 fi
225
226
227 #
228 # Output our numbers, that will let tinderbox specify everything all
229 # at once.
230 # First number is in fact the total size of all code and data in the map
231 # files parsed.
232 # Second number, if present, is growth/shrinkage.
233 #
234
235 if [ $TINDERBOX_OUTPUT ]; then
236 echo -n "__codesize:"
237 fi
238 $OBJROOT/dist/bin/codesighs --totalonly --input $COPYSORTTSV
239
240 if [ -e $DIFFFILE ]; then
241 if [ $TINDERBOX_OUTPUT ]; then
242 echo -n "__codesizeDiff:"
243 fi
244 $OBJROOT/dist/bin/maptsvdifftool $ZERODRIFT --summary --input $DIFFFILE
245 fi
246
247 #
248 # Remove our temporary directory.
249 #
250 rm -rf $MYTMPDIR
OLDNEW
« no previous file with comments | « third_party/codesighs/README.chromium ('k') | third_party/codesighs/autosummary.win.bash » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698