From 5a2c69b6cb752a7e47d2a14eca093303c9c7d598 Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Tue, 12 Apr 2011 15:38:06 -0400 Subject: [PATCH] Bug 647453 - Removed serialized JS from omnijar, r=taras,khuey --- browser/installer/Makefile.in | 14 ++++++++++++-- browser/installer/precompile_cache.js | 25 ++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/browser/installer/Makefile.in b/browser/installer/Makefile.in index acea03715aa..fcfd352c68e 100644 --- a/browser/installer/Makefile.in +++ b/browser/installer/Makefile.in @@ -122,13 +122,23 @@ ifdef RUN_TEST_PROGRAM _ABS_RUN_TEST_PROGRAM = $(call core_abspath,$(RUN_TEST_PROGRAM)) endif +ifndef MOZ_DEBUG +# The precompile_cache.js script outputs a list of files that were +# serialized and do not need to be included in the omnijar anymore +STRIP_ORIGINAL_FILES = zip -d omni.jar `cat sc_log.txt` +else +STRIP_ORIGINAL_FILES = true +endif + GENERATE_CACHE = \ - $(_ABS_RUN_TEST_PROGRAM) $(_ABS_DIST)/bin/xpcshell$(BIN_SUFFIX) -g "$$PWD" -f $(topsrcdir)/browser/installer/precompile_cache.js -e 'populate_startupcache("omni.jar", "startupCache.zip");' && \ + $(_ABS_RUN_TEST_PROGRAM) $(_ABS_DIST)/bin/xpcshell$(BIN_SUFFIX) -g "$$PWD" -f $(topsrcdir)/browser/installer/precompile_cache.js -e 'populate_startupcache("omni.jar", "startupCache.zip", "sc_log.txt");' && \ rm -rf jsloader && \ $(UNZIP) startupCache.zip && \ rm startupCache.zip && \ find jsloader | xargs touch -t 201001010000 && \ - $(ZIP) -r9mX omni.jar jsloader + $(ZIP) -r9mX omni.jar jsloader && \ + $(STRIP_ORIGINAL_FILES) && \ + rm sc_log.txt endif include $(topsrcdir)/toolkit/mozapps/installer/packager.mk diff --git a/browser/installer/precompile_cache.js b/browser/installer/precompile_cache.js index ff3593255b8..942b4af5367 100644 --- a/browser/installer/precompile_cache.js +++ b/browser/installer/precompile_cache.js @@ -43,6 +43,14 @@ const Cc = Components.classes; const Ci = Components.interfaces; const Cu = Components.utils; +const MODE_RDONLY = 0x01; +const MODE_WRONLY = 0x02; +const MODE_CREATE = 0x08; +const MODE_APPEND = 0x10; +const MODE_TRUNCATE = 0x20; + +var out; + function setenv(name, val) { try { var environment = Components.classes["@mozilla.org/process/environment;1"]. @@ -71,6 +79,7 @@ function load_entries(entries, prefix) { continue; if (c.indexOf("services-crypto") >= 0) continue; + out.writeString(c + "\n"); load(prefix + c); } } @@ -78,6 +87,7 @@ function load_entries(entries, prefix) { function load_custom_entries(entries, subst) { while (entries.hasMore()) { var c = entries.getNext(); + out.writeString(c + "\n"); load("resource://" + subst + "/" + c.replace("modules/" + subst + "/", "")); } } @@ -94,7 +104,7 @@ function openJar(file) { return zipreader; } -function populate_startupcache(omnijarName, startupcacheName) { +function populate_startupcache(omnijarName, startupcacheName, logName) { var file = getGreDir(); file.append(omnijarName); zipreader = openJar(file); @@ -103,6 +113,18 @@ function populate_startupcache(omnijarName, startupcacheName) { scFile.append(startupcacheName); setenv("MOZ_STARTUP_CACHE", scFile.path); + var logFile = getGreDir(); + logFile.append(logName); + var stream = Cc["@mozilla.org/network/file-output-stream;1"] + .createInstance(Ci.nsIFileOutputStream); + + stream.init(logFile, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, 0666, 0); + + out = Cc["@mozilla.org/intl/converter-output-stream;1"] + .createInstance(Ci.nsIConverterOutputStream); + + out.init(stream, "UTF-8", 0, 0); + // the sync part below doesn't work as smoothly let ioService = Cc["@mozilla.org/network/io-service;1"]. getService(Ci.nsIIOService); @@ -126,4 +148,5 @@ function populate_startupcache(omnijarName, startupcacheName) { load_entries(zipreader.findEntries("modules/*js"), "resource://gre/"); load_entries(zipreader.findEntries("modules/*jsm"), "resource://gre/"); zipreader.close(); + out.close(); }