@@ -57,7 +57,7 @@ def __init__(self, js, js_engine):
57
57
if curr not in INVALID_3 : self .names .append (curr )
58
58
#print >> sys.stderr, self.names
59
59
60
- def minify_shell (self , shell , compress , debug = False ):
60
+ def minify_shell (self , shell , compress , source_map = False ):
61
61
#print >> sys.stderr, "MINIFY SHELL 1111111111", shell, "\n222222222222222"
62
62
# Run through js-optimizer.js to find and minify the global symbols
63
63
# We send it the globals, which it parses at the proper time. JS decides how
@@ -80,7 +80,7 @@ def minify_shell(self, shell, compress, debug=False):
80
80
output = subprocess .Popen (self .js_engine +
81
81
[JS_OPTIMIZER , temp_file , 'minifyGlobals' , 'noPrintMetadata' ] +
82
82
(['compress' ] if compress else []) +
83
- (['--debug' ] if debug else []),
83
+ (['--debug' ] if source_map else []),
84
84
stdout = subprocess .PIPE ).communicate ()[0 ]
85
85
assert len (output ) > 0 and not output .startswith ('Assertion failed' ), 'Error in js optimizer: ' + output
86
86
#print >> sys.stderr, "minified SHELL 3333333333333333", output, "\n44444444444444444444"
@@ -107,7 +107,7 @@ def run_on_chunk(command):
107
107
if DEBUG and not shared .WINDOWS : print >> sys .stderr , '.' # Skip debug progress indicator on Windows, since it doesn't buffer well with multiple threads printing to console.
108
108
return filename
109
109
110
- def run_on_js (filename , passes , js_engine , jcache , debug = False ):
110
+ def run_on_js (filename , passes , js_engine , jcache , source_map = False ):
111
111
if isinstance (jcache , bool ) and jcache : jcache = shared .JCache
112
112
if jcache : shared .JCache .ensure ()
113
113
@@ -175,7 +175,7 @@ def process(line):
175
175
js = js [start_funcs + len (start_funcs_marker ):end_funcs ]
176
176
177
177
minifier = Minifier (js , js_engine )
178
- asm_shell_pre , asm_shell_post = minifier .minify_shell (asm_shell , 'compress' in passes , debug ).split ('EMSCRIPTEN_FUNCS();' );
178
+ asm_shell_pre , asm_shell_post = minifier .minify_shell (asm_shell , 'compress' in passes , source_map ).split ('EMSCRIPTEN_FUNCS();' );
179
179
asm_shell_post = asm_shell_post .replace ('});' , '})' );
180
180
pre += asm_shell_pre + '\n ' + start_funcs_marker
181
181
post = end_funcs_marker + asm_shell_post + post
@@ -211,7 +211,9 @@ def process(line):
211
211
total_size = len (js )
212
212
js = None
213
213
214
- cores = int (os .environ .get ('EMCC_CORES' ) or multiprocessing .cpu_count ())
214
+ # if we are making source maps, we want our debug numbering to start from the
215
+ # top of the file, so avoid breaking the JS into chunks
216
+ cores = 1 if source_map else int (os .environ .get ('EMCC_CORES' ) or multiprocessing .cpu_count ())
215
217
intended_num_chunks = int (round (cores * NUM_CHUNKS_PER_CORE ))
216
218
chunk_size = min (MAX_CHUNK_SIZE , max (MIN_CHUNK_SIZE , total_size / intended_num_chunks ))
217
219
@@ -253,7 +255,7 @@ def write_chunk(chunk, i):
253
255
# XXX Use '--nocrankshaft' to disable crankshaft to work around v8 bug 1895, needed for older v8/node (node 0.6.8+ should be ok)
254
256
commands = map (lambda filename : js_engine +
255
257
[JS_OPTIMIZER , filename , 'noPrintMetadata' ] +
256
- (['--debug' ] if debug else []) + passes , filenames )
258
+ (['--debug' ] if source_map else []) + passes , filenames )
257
259
#print [' '.join(command) for command in commands]
258
260
259
261
cores = min (cores , filenames )
@@ -321,6 +323,6 @@ def write_chunk(chunk, i):
321
323
322
324
return filename
323
325
324
- def run (filename , passes , js_engine , jcache , debug = False ):
325
- return temp_files .run_and_clean (lambda : run_on_js (filename , passes , js_engine , jcache , debug ))
326
+ def run (filename , passes , js_engine , jcache , source_map = False ):
327
+ return temp_files .run_and_clean (lambda : run_on_js (filename , passes , js_engine , jcache , source_map ))
326
328
0 commit comments