aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-03-24 20:23:11 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-03-24 20:23:11 -0700
commit5817cd8af0036d6593f6e0fb314a291f40e8056a (patch)
tree51457d9f89b0eef4983d93ca996006c327194709 /tools
parent63ed033209d1880d6f8f6b47c5e1bedb01f0b330 (diff)
--emit-symbol-map option
Diffstat (limited to 'tools')
-rw-r--r--tools/js_optimizer.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py
index 4821cc81..d0284528 100644
--- a/tools/js_optimizer.py
+++ b/tools/js_optimizer.py
@@ -32,6 +32,7 @@ class Minifier:
def __init__(self, js, js_engine):
self.js = js
self.js_engine = js_engine
+ self.symbols_file = None
def minify_shell(self, shell, minify_whitespace, source_map=False):
# Run through js-optimizer.js to find and minify the global symbols
@@ -61,6 +62,14 @@ class Minifier:
#print >> sys.stderr, "minified SHELL 3333333333333333", output, "\n44444444444444444444"
code, metadata = output.split('// EXTRA_INFO:')
self.globs = json.loads(metadata)
+
+ if self.symbols_file:
+ mapfile = open(self.symbols_file, 'w')
+ for key, value in self.globs.iteritems():
+ mapfile.write(value + ':' + key + '\n')
+ mapfile.close()
+ print >> sys.stderr, 'wrote symbol map file to', self.symbols_file
+
return code.replace('13371337', '0.0')
@@ -162,6 +171,12 @@ EMSCRIPTEN_FUNCS();
# we assume there is a maximum of one new name per line
minifier = Minifier(js, js_engine)
+ def check_symbol_mapping(p):
+ if p.startswith('symbolMap='):
+ minifier.symbols_file = p.split('=')[1]
+ return False
+ return True
+ passes = filter(check_symbol_mapping, passes)
asm_shell_pre, asm_shell_post = minifier.minify_shell(asm_shell, 'minifyWhitespace' in passes, source_map).split('EMSCRIPTEN_FUNCS();');
asm_shell_post = asm_shell_post.replace('});', '})');
pre += asm_shell_pre + '\n' + start_funcs_marker