bug 659950 - implement a much simpler pair of codesize metrics: on-disk application size + installer size. r=glandium
authorTed Mielczarek <ted.mielczarek@gmail.com>
Tue, 28 Jun 2011 07:55:56 -0400
changeset 71963 a3b7bdf2e5e8bd645d9c5eab479c069fca3b6ad5
parent 71962 57ee54e41ef336dbc2aef4eb978f4275cd63075a
child 71964 8f2475ecc0d3fd1c544a0a71ba2c8ee815d40c9e
push idunknown
push userunknown
push dateunknown
reviewersglandium
bugs659950
milestone7.0a1
bug 659950 - implement a much simpler pair of codesize metrics: on-disk application size + installer size. r=glandium
Makefile.in
toolkit/mozapps/installer/packager.mk
tools/codesighs/codesighs.py
--- a/Makefile.in
+++ b/Makefile.in
@@ -192,16 +192,19 @@ endif
           zip -r9D "../$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip" . -i "*.sym" -i "*.txt"
 endif # MOZ_CRASHREPORTER
 
 uploadsymbols:
 ifdef MOZ_CRASHREPORTER
 	$(SHELL) $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.sh $(SYMBOL_INDEX_NAME) "$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip"
 endif
 
+codesighs:
+	$(MAKE) -C $(MOZ_BUILD_APP)/installer codesighs
+
 # defined in package-name.mk
 export MOZ_SOURCE_STAMP
 
 #XXX: this is a hack, since we don't want to clobber for MSVC
 # PGO support, but we can't do this test in client.mk
 ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_)
 # No point in clobbering if PGO has been explicitly disabled.
 ifndef NO_PROFILE_GUIDED_OPTIMIZE
--- a/toolkit/mozapps/installer/packager.mk
+++ b/toolkit/mozapps/installer/packager.mk
@@ -162,17 +162,17 @@ RPMBUILD_BUILDDIR=$(_ABS_DIST)/..
 
 SPEC_FILE = $(RPMBUILD_SPECDIR)/mozilla.spec
 RPM_INCIDENTALS=$(topsrcdir)/toolkit/mozapps/installer/linux/rpm
 
 RPM_CMD = \
   echo Creating RPM && \
   mkdir -p $(RPMBUILD_SOURCEDIR) && \
   $(PYTHON) $(topsrcdir)/config/Preprocessor.py \
-  	-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
+	-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
 	-DMOZ_APP_DISPLAYNAME=$(MOZ_APP_DISPLAYNAME) \
 	< $(RPM_INCIDENTALS)/mozilla.desktop \
 	> $(RPMBUILD_SOURCEDIR)/$(MOZ_APP_NAME).desktop && \
   rm -rf $(_ABS_DIST)/$(TARGET_CPU) && \
   $(RPMBUILD) -bb \
   $(SPEC_FILE) \
   --target $(TARGET_CPU) \
   --buildroot $(RPMBUILD_TOPDIR)/BUILDROOT \
@@ -818,16 +818,26 @@ checksum:
 	@echo "CHECKSUM FILE END"
 
 
 upload: checksum
 	$(PYTHON) $(MOZILLA_DIR)/build/upload.py --base-path $(DIST) \
 		$(UPLOAD_FILES) \
 		$(CHECKSUM_FILE)
 
+ifeq (WINNT,$(OS_TARGET))
+CODESIGHS_PACKAGE = $(INSTALLER_PACKAGE)
+else
+CODESIGHS_PACKAGE = $(DIST)/$(PACKAGE)
+endif
+
+codesighs:
+	$(PYTHON) $(topsrcdir)/tools/codesighs/codesighs.py \
+	  "$(DIST)/$(MOZ_PKG_DIR)" "$(CODESIGHS_PACKAGE)"
+
 ifndef MOZ_PKG_SRCDIR
 MOZ_PKG_SRCDIR = $(topsrcdir)
 endif
 
 DIR_TO_BE_PACKAGED ?= ../$(notdir $(topsrcdir))
 SRC_TAR_EXCLUDE_PATHS += \
   --exclude=".hg*" \
   --exclude="CVS" \
new file mode 100755
--- /dev/null
+++ b/tools/codesighs/codesighs.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+# Copyright 2011 Mozilla Foundation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#   1. Redistributions of source code must retain the above copyright
+#      notice, this list of conditions and the following disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above copyright
+#      notice, this list of conditions and the following disclaimer in
+#      the documentation and/or other materials provided with the
+#      distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE MOZILLA FOUNDATION ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MOZILLA FOUNDATION OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation
+# are those of the authors and should not be interpreted as representing
+# official policies, either expressed or implied, of the Mozilla
+# Foundation.
+
+import sys, os
+
+def sumDirectorySize(path):
+    """
+    Calculate the total size of all the files under |path|.
+    """
+    total = 0
+    def reraise(e):
+        raise e
+    for root, dirs, files in os.walk(path, onerror=reraise):
+        for f in files:
+            total += os.path.getsize(os.path.join(root, f))
+    return total
+
+def codesighs(stagepath, installerpath):
+    """
+    Calculate the total size of the files under |stagepath| on disk
+    and print it as "__codesize", and print the size of the file at
+    |installerpath| as "__installersize".
+    """
+    try:
+        print "__codesize:%d" % sumDirectorySize(stagepath)
+        print "__installersize:%d" % os.path.getsize(installerpath)
+    except OSError, e:
+        print >>sys.stderr, """Couldn't read file %s.
+Perhaps you need to run |make package| or |make installer|?""" % e.filename
+
+if __name__ == '__main__':
+    if len(sys.argv) < 3:
+        print >>sys.stderr, "Usage: codesighs.py <package stage path> <installer path>"
+        sys.exit(1)
+    codesighs(sys.argv[1], sys.argv[2])