Skip to content

Commit 0199225

Browse files
committed
Enable wasm source maps.
1 parent 7654279 commit 0199225

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

emcc.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def __init__(self):
145145
self.exclude_files = []
146146
self.ignore_dynamic_linking = False
147147
self.shell_path = shared.path_from_root('src', 'shell.html')
148+
self.source_map_base = None
148149
self.js_libraries = []
149150
self.bind = False
150151
self.emrun = False
@@ -1768,8 +1769,8 @@ def get_eliminate():
17681769
if shared.Settings.CYBERDWARF:
17691770
execute([shared.PYTHON, shared.path_from_root('tools', 'emdebug_cd_merger.py'), target + '.cd', target+'.symbols'])
17701771

1771-
if options.debug_level >= 4:
1772-
emit_source_maps(target, optimizer.js_transform_tempfiles)
1772+
if options.debug_level >= 4 and not shared.Settings.BINARYEN:
1773+
emit_js_source_maps(target, optimizer.js_transform_tempfiles)
17731774

17741775
# track files that will need native eols
17751776
generated_text_files_with_native_eols = []
@@ -1953,6 +1954,11 @@ def parse_args(newargs):
19531954
options.shell_path = newargs[i+1]
19541955
newargs[i] = ''
19551956
newargs[i+1] = ''
1957+
elif newargs[i].startswith('--source-map-base'):
1958+
check_bad_eq(newargs[i])
1959+
options.source_map_base = newargs[i+1]
1960+
newargs[i] = ''
1961+
newargs[i+1] = ''
19561962
elif newargs[i].startswith('--js-library'):
19571963
check_bad_eq(newargs[i])
19581964
options.js_libraries.append(newargs[i+1])
@@ -2139,7 +2145,7 @@ def emterpretify(js_target, optimizer, options):
21392145
final = real
21402146

21412147

2142-
def emit_source_maps(target, js_transform_tempfiles):
2148+
def emit_js_source_maps(target, js_transform_tempfiles):
21432149
logging.debug('generating source maps')
21442150
jsrun.run_js(shared.path_from_root('tools', 'source-maps', 'sourcemapper.js'),
21452151
shared.NODE_JS, js_transform_tempfiles +
@@ -2252,6 +2258,10 @@ def do_binaryen(final, target, asm_target, options, memfile, wasm_binary_target,
22522258
cmd = [os.path.join(binaryen_bin, 'wasm-as'), wasm_text_target, '-o', wasm_binary_target]
22532259
if options.debug_level >= 2 or options.profiling_funcs:
22542260
cmd += ['-g']
2261+
if options.debug_level >= 4:
2262+
cmd += ['--source-map=' + wasm_binary_target + '.map']
2263+
if options.source_map_base:
2264+
cmd += ['--source-map-url=' + options.source_map_base + wasm_binary_target + '.map']
22552265
logging.debug('wasm-as (text => binary): ' + ' '.join(cmd))
22562266
subprocess.check_call(cmd)
22572267
if import_mem_init:

site/build/text/docs/tools_reference/emcc.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,12 @@ Options that are modified or new in *emcc* are listed below:
350350
* This argument is ignored if a target other than HTML is
351351
specified using the "-o" option.
352352

353+
"--source-map-base <base-url>"
354+
The URL for the location where WebAssembly source maps will be
355+
published. When this option is provided, the **.wasm** file is
356+
updated to have a "sourceMappingURL" section. The resulting URL
357+
will have format: "<base-url>" + "<wasm-file-name>" + ".map".
358+
353359
"--minify 0"
354360
Identical to "-g1".
355361

site/source/docs/tools_reference/emcc.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ Options that are modified or new in *emcc* are listed below:
304304

305305
- See `src/shell.html <https://github.com/kripken/emscripten/blob/master/src/shell.html>`_ and `src/shell_minimal.html <https://github.com/kripken/emscripten/blob/master/src/shell_minimal.html>`_ for examples.
306306
- This argument is ignored if a target other than HTML is specified using the ``-o`` option.
307+
308+
.. _emcc-source-map-base:
309+
310+
``--source-map-base <base-url>``
311+
The URL for the location where WebAssembly source maps will be published. When this option is provided, the **.wasm** file is updated to have a ``sourceMappingURL`` section. The resulting URL will have format: ``<base-url>`` + ``<wasm-file-name>`` + ``.map``.
307312

308313
.. _emcc-minify:
309314

tools/ports/binaryen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os, shutil, logging
22

3-
TAG = 'version_33'
3+
TAG = 'version_34'
44

55
def needed(settings, shared, ports):
66
if not settings.BINARYEN: return False

0 commit comments

Comments
 (0)