Bug 786743 - Disable JS minification for debug builds.
authorTill Schneidereit <tschneidereit@gmail.com>
Thu, 06 Sep 2012 17:43:22 +0200
changeset 108068 2f83e74b38ff702f57ce22df899f531c9b252ec0
parent 108067 dbff58387e66183671be5d32301d26a4ba69613c
child 108069 4fdce7d4f4b3ecb16c14b645f1557b9edf96c71a
push idunknown
push userunknown
push dateunknown
bugs786743
milestone18.0a1
Bug 786743 - Disable JS minification for debug builds.
js/src/Makefile.in
js/src/builtin/embedjs.py
js/src/builtin/js2c.py
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -804,19 +804,23 @@ selfhosting_srcs := \
 
 selfhosted_out_h_deps := \
   $(selfhosting_srcs) \
   $(srcdir)/js.msg \
   $(srcdir)/builtin/macros.py \
   $(srcdir)/builtin/js2c.py \
   $(srcdir)/builtin/embedjs.py
 
+ifeq ($(MOZ_DEBUG),1)
+selfhosting_embed_flags += -d
+endif
+
 selfhosted.out.h: $(selfhosted_out_h_deps)
-	$(PYTHON) $(srcdir)/builtin/embedjs.py $@ $(srcdir)/js.msg \
-	  $(srcdir)/builtin/macros.py $(selfhosting_srcs)
+	$(PYTHON) $(srcdir)/builtin/embedjs.py $(selfhosting_embed_flags) $@ \
+	  $(srcdir)/js.msg $(srcdir)/builtin/macros.py $(selfhosting_srcs)
 
 ###############################################
 # BEGIN kludges for the Nitro assembler
 #
 
 # Needed to "configure" it correctly.  Unfortunately these
 # flags wind up being applied to all code in js/src, not just
 # the code in js/src/assembler.
--- a/js/src/builtin/embedjs.py
+++ b/js/src/builtin/embedjs.py
@@ -31,19 +31,22 @@ def buildMessagesTable(messages_file):
 def replaceMessages(line, messages):
     if not 'JSMSG_' in line:
         return line
     for message_str, message_num in messages.iteritems():
         line = line.replace(message_str, message_num)
     return line
 
 def main():
+    debug = sys.argv[1] == '-d'
+    if debug:
+        sys.argv.pop(1)
     output_file = sys.argv[1]
     messages_file = sys.argv[2]
     macros_file = sys.argv[3]
     source_files = sys.argv[4:]
     combined_file = 'combined.js'
     replaceErrorMsgs(source_files, messages_file, combined_file)
-    js2c.JS2C([combined_file, macros_file], [output_file], { 'TYPE': 'CORE', 'COMPRESSION': 'off' })
+    js2c.JS2C([combined_file, macros_file], [output_file], { 'TYPE': 'CORE', 'COMPRESSION': 'off', 'DEBUG':debug })
     os.remove(combined_file)
 
 if __name__ == "__main__":
     main()
\ No newline at end of file
--- a/js/src/builtin/js2c.py
+++ b/js/src/builtin/js2c.py
@@ -273,17 +273,18 @@ def JS2C(source, target, env):
   all_sources = []
   for module in modules:
     filename = str(module)
     debugger = filename.endswith('-debugger.js')
     lines = ReadFile(filename)
     lines = ExpandConstants(lines, consts)
     lines = ExpandMacros(lines, macros)
     Validate(lines, filename)
-    lines = minifier.JSMinify(lines)
+    if not env['DEBUG']:
+      lines = minifier.JSMinify(lines)
     id = (os.path.split(filename)[1])[:-3]
     if debugger: id = id[:-9]
     raw_length = len(lines)
     if debugger:
       debugger_ids.append((id, raw_length, module_offset))
     else:
       ids.append((id, raw_length, module_offset))
     all_sources.append(lines)