diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-01-12 18:25:01 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-12 18:25:01 -0800 |
commit | f2ab0ddbdd7e469a845bf4ede36c3e7c6f90c0b4 (patch) | |
tree | ffea5432cbfd38e359eccd87956a67098c16a792 /emcc | |
parent | e02762158e8f105fae65583fe9cfe331494b11c7 (diff) |
emcc option to compress js whitespace
Diffstat (limited to 'emcc')
-rwxr-xr-x | emcc | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -155,6 +155,14 @@ Options that are modified or new in %s include: list of arguments, for example, <cmd> of "python processor.py" will cause a python script to be run. + --compress <on> 0: Do not compress the generated JavaScript's + whitespace (default if closure compiler + will not be run) + 1: Compress the generated JavaScript's + whitespace (default if closure compiler + will be run). Note that this by itself + will not minify the code (closure does + that) The target file, if specified (-o <target>), defines what will be generated: @@ -272,6 +280,7 @@ try: llvm_opt_level = None closure = None js_transform = None + compress_whitespace = None def check_bad_eq(arg): assert '=' not in arg, 'Invalid parameter (do not use "=" with "--" options)' @@ -300,6 +309,11 @@ try: js_transform = newargs[i+1] newargs[i] = '' newargs[i+1] = '' + elif newargs[i].startswith('--compress'): + check_bad_eq(newargs[i]) + compress_whitespace = int(newargs[i+1]) + newargs[i] = '' + newargs[i+1] = '' elif newargs[i] == '-MF': # clang cannot handle this, so we fake it f = open(newargs[i+1], 'w') f.write('\n') @@ -310,6 +324,8 @@ try: if llvm_opt_level is None: llvm_opt_level = 1 if opt_level >= 1 else 0 if closure is None: closure = 1 if opt_level >= 2 else 0 + if compress_whitespace is None: + compress_whitespace = closure # if closure is run, compress whitespace if closure: assert os.path.exists(shared.CLOSURE_COMPILER), 'emcc: fatal: Closure compiler (%s) does not exist' % shared.CLOSURE_COMPILER @@ -546,6 +562,10 @@ try: final = shared.Building.js_optimizer(final, 'simplifyExpressionsPost') if DEBUG: save_intermediate('simplifyExpressionsPost') + if compress_whitespace: + final = shared.Building.js_optimizer(final, 'compress') + if DEBUG: save_intermediate('compress') + # If we were asked to also generate HTML, do that if final_suffix == 'html': if DEBUG: print >> sys.stderr, 'emcc: generating HTML' |