Skip to content

Commit 2adabcd

Browse files
yurydelendikbuu700
authored andcommitted
Enable wasm source maps. (emscripten-core#5335)
1 parent a2bdaad commit 2adabcd

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
@@ -1764,8 +1765,8 @@ def get_eliminate():
17641765
if shared.Settings.CYBERDWARF:
17651766
execute([shared.PYTHON, shared.path_from_root('tools', 'emdebug_cd_merger.py'), target + '.cd', target+'.symbols'])
17661767

1767-
if options.debug_level >= 4:
1768-
emit_source_maps(target, optimizer.js_transform_tempfiles)
1768+
if options.debug_level >= 4 and not shared.Settings.BINARYEN:
1769+
emit_js_source_maps(target, optimizer.js_transform_tempfiles)
17691770

17701771
# track files that will need native eols
17711772
generated_text_files_with_native_eols = []
@@ -1952,6 +1953,11 @@ def parse_args(newargs):
19521953
options.shell_path = newargs[i+1]
19531954
newargs[i] = ''
19541955
newargs[i+1] = ''
1956+
elif newargs[i].startswith('--source-map-base'):
1957+
check_bad_eq(newargs[i])
1958+
options.source_map_base = newargs[i+1]
1959+
newargs[i] = ''
1960+
newargs[i+1] = ''
19551961
elif newargs[i].startswith('--js-library'):
19561962
check_bad_eq(newargs[i])
19571963
options.js_libraries.append(newargs[i+1])
@@ -2138,7 +2144,7 @@ def emterpretify(js_target, optimizer, options):
21382144
final = real
21392145

21402146

2141-
def emit_source_maps(target, js_transform_tempfiles):
2147+
def emit_js_source_maps(target, js_transform_tempfiles):
21422148
logging.debug('generating source maps')
21432149
jsrun.run_js(shared.path_from_root('tools', 'source-maps', 'sourcemapper.js'),
21442150
shared.NODE_JS, js_transform_tempfiles +
@@ -2251,6 +2257,10 @@ def do_binaryen(final, target, asm_target, options, memfile, wasm_binary_target,
22512257
cmd = [os.path.join(binaryen_bin, 'wasm-as'), wasm_text_target, '-o', wasm_binary_target]
22522258
if options.debug_level >= 2 or options.profiling_funcs:
22532259
cmd += ['-g']
2260+
if options.debug_level >= 4:
2261+
cmd += ['--source-map=' + wasm_binary_target + '.map']
2262+
if options.source_map_base:
2263+
cmd += ['--source-map-url=' + options.source_map_base + wasm_binary_target + '.map']
22542264
logging.debug('wasm-as (text => binary): ' + ' '.join(cmd))
22552265
subprocess.check_call(cmd)
22562266
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)