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 basesummary.win.bash code, released 17# Nov 15, 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, 15-November-2002 26# 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. 38# 39# ***** END LICENSE BLOCK ***** 40 41 42# 43# Check for optional objdir 44# 45if [ "$1" = "-o" ]; then 46OBJROOT="$2" 47shift 48shift 49else 50OBJROOT="./mozilla" 51fi 52 53if [ "$1" = "-s" ]; then 54SRCROOT="$2" 55shift 56shift 57else 58SRCROOT="./mozilla" 59fi 60 61MANIFEST="$SRCROOT/embedding/config/basebrowser-win" 62 63# 64# A little help for my friends. 65# 66if [ "-h" == "$1" ];then 67 SHOWHELP="1" 68fi 69if [ "--help" == "$1" ];then 70 SHOWHELP="1" 71fi 72if [ "" == "$1" ]; then 73 SHOWHELP="1" 74fi 75if [ "" == "$2" ]; then 76 SHOWHELP="1" 77fi 78if [ "" == "$3" ]; then 79 SHOWHELP="1" 80fi 81 82 83# 84# Show the help if required. 85# 86if [ $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 108fi 109 110 111# 112# Stash our arguments away. 113# 114COPYSORTTSV="$1" 115OLDTSVFILE="$2" 116SUMMARYFILE="$3" 117 118 119# 120# Create our temporary directory. 121# 122MYTMPDIR=`mktemp -d ./codesighs.tmp.XXXXXXXX` 123 124 125# 126# Find the types of files we are interested in. 127# 128ONEFINDPASS="$MYTMPDIR/onefind.list" 129/usr/bin/find $OBJROOT -type f -name "*.obj" -or -name "*.map" | while read FNAME; do 130 cygpath -m $FNAME >> $ONEFINDPASS 131done 132 133 134# 135# Find all object files. 136# 137ALLOBJSFILE="$MYTMPDIR/allobjs.list" 138grep -i "\.obj$" < $ONEFINDPASS > $ALLOBJSFILE 139 140 141# 142# Get a dump of the symbols in every object file. 143# 144ALLOBJSYMSFILE="$MYTMPDIR/allobjsyms.list" 145xargs -n 1 dumpbin.exe /symbols < $ALLOBJSFILE > $ALLOBJSYMSFILE 2> /dev/null 146 147 148# 149# Produce the symdb for the symbols in all object files. 150# 151SYMDBFILE="$MYTMPDIR/symdb.tsv" 152$OBJROOT/dist/bin/msdump2symdb --input $ALLOBJSYMSFILE | /usr/bin/sort > $SYMDBFILE 2> /dev/null 153 154 155# 156# Find all map files. 157# 158ALLMAPSFILE="$MYTMPDIR/allmaps.list" 159grep -i "\.map$" < $ONEFINDPASS > $ALLMAPSFILE 160 161 162# 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. 166# 167RELEVANTSETFILE="$MYTMPDIR/relevant.set" 168grep -v '\;' < $MANIFEST | sed 's/.*\\//' | grep '\.[eEdD][xXlL][eElL]' | sed 's/\.[eEdD][xXlL][eElL]//' > $RELEVANTSETFILE 169RELEVANTARG=`xargs -n 1 echo --match-module < $RELEVANTSETFILE` 170 171 172# 173# Produce the TSV output. 174# 175RAWTSVFILE="$MYTMPDIR/raw.tsv" 176$OBJROOT/dist/bin/msmap2tsv --symdb $SYMDBFILE --batch $RELEVANTARG < $ALLMAPSFILE > $RAWTSVFILE 2> /dev/null 177 178 179# 180# Sort the TSV output for useful diffing and eyeballing in general. 181# 182/usr/bin/sort -r $RAWTSVFILE > $COPYSORTTSV 183 184 185# 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. 190# 191rm -f $SUMMARYFILE 192DIFFFILE="$MYTMPDIR/diff.txt" 193if [ -e $OLDTSVFILE ]; then 194 diff $OLDTSVFILE $COPYSORTTSV > $DIFFFILE 195 $OBJROOT/dist/bin/maptsvdifftool --negation --input $DIFFFILE | dos2unix >> $SUMMARYFILE 196else 197 $OBJROOT/dist/bin/codesighs --modules --input $COPYSORTTSV | dos2unix >> $SUMMARYFILE 198fi 199 200 201# 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. 207# 208 209if [ $TINDERBOX_OUTPUT ]; then 210 echo -n "__codesize:" 211fi 212$OBJROOT/dist/bin/codesighs --totalonly --input $COPYSORTTSV | dos2unix 213 214if [ -e $DIFFFILE ]; then 215if [ $TINDERBOX_OUTPUT ]; then 216 echo -n "__codesizeDiff:" 217fi 218 $OBJROOT/dist/bin/maptsvdifftool --negation --summary --input $DIFFFILE | dos2unix 219fi 220 221# 222# Remove our temporary directory. 223# 224rm -rf $MYTMPDIR 225