Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable wasm source maps. #5335

Merged
merged 1 commit into from
Jun 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def __init__(self):
self.exclude_files = []
self.ignore_dynamic_linking = False
self.shell_path = shared.path_from_root('src', 'shell.html')
self.source_map_base = None
self.js_libraries = []
self.bind = False
self.emrun = False
Expand Down Expand Up @@ -1768,8 +1769,8 @@ def get_eliminate():
if shared.Settings.CYBERDWARF:
execute([shared.PYTHON, shared.path_from_root('tools', 'emdebug_cd_merger.py'), target + '.cd', target+'.symbols'])

if options.debug_level >= 4:
emit_source_maps(target, optimizer.js_transform_tempfiles)
if options.debug_level >= 4 and not shared.Settings.BINARYEN:
emit_js_source_maps(target, optimizer.js_transform_tempfiles)

# track files that will need native eols
generated_text_files_with_native_eols = []
Expand Down Expand Up @@ -1953,6 +1954,11 @@ def parse_args(newargs):
options.shell_path = newargs[i+1]
newargs[i] = ''
newargs[i+1] = ''
elif newargs[i].startswith('--source-map-base'):
check_bad_eq(newargs[i])
options.source_map_base = newargs[i+1]
newargs[i] = ''
newargs[i+1] = ''
elif newargs[i].startswith('--js-library'):
check_bad_eq(newargs[i])
options.js_libraries.append(newargs[i+1])
Expand Down Expand Up @@ -2139,7 +2145,7 @@ def emterpretify(js_target, optimizer, options):
final = real


def emit_source_maps(target, js_transform_tempfiles):
def emit_js_source_maps(target, js_transform_tempfiles):
logging.debug('generating source maps')
jsrun.run_js(shared.path_from_root('tools', 'source-maps', 'sourcemapper.js'),
shared.NODE_JS, js_transform_tempfiles +
Expand Down Expand Up @@ -2252,6 +2258,10 @@ def do_binaryen(final, target, asm_target, options, memfile, wasm_binary_target,
cmd = [os.path.join(binaryen_bin, 'wasm-as'), wasm_text_target, '-o', wasm_binary_target]
if options.debug_level >= 2 or options.profiling_funcs:
cmd += ['-g']
if options.debug_level >= 4:
cmd += ['--source-map=' + wasm_binary_target + '.map']
if options.source_map_base:
cmd += ['--source-map-url=' + options.source_map_base + wasm_binary_target + '.map']
logging.debug('wasm-as (text => binary): ' + ' '.join(cmd))
subprocess.check_call(cmd)
if import_mem_init:
Expand Down
6 changes: 6 additions & 0 deletions site/build/text/docs/tools_reference/emcc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ Options that are modified or new in *emcc* are listed below:
* This argument is ignored if a target other than HTML is
specified using the "-o" option.

"--source-map-base <base-url>"
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".

"--minify 0"
Identical to "-g1".

Expand Down
5 changes: 5 additions & 0 deletions site/source/docs/tools_reference/emcc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ Options that are modified or new in *emcc* are listed below:

- 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.
- This argument is ignored if a target other than HTML is specified using the ``-o`` option.

.. _emcc-source-map-base:

``--source-map-base <base-url>``
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``.

.. _emcc-minify:

Expand Down
2 changes: 1 addition & 1 deletion tools/ports/binaryen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os, shutil, logging

TAG = 'version_33'
TAG = 'version_34'

def needed(settings, shared, ports):
if not settings.BINARYEN: return False
Expand Down