From 4249aee66e4ac7bacf28cf9cc250cd5f722070c7 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Fri, 23 Jun 2017 09:15:37 -0500 Subject: [PATCH] Enable wasm source maps. --- emcc.py | 12 +++++++++++- site/build/text/docs/tools_reference/emcc.txt | 6 ++++++ site/source/docs/tools_reference/emcc.rst | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/emcc.py b/emcc.py index 2ecef784908e5..0af48168baabb 100755 --- a/emcc.py +++ b/emcc.py @@ -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 @@ -1768,7 +1769,7 @@ 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: + if options.debug_level >= 4 and not shared.Settings.BINARYEN: emit_source_maps(target, optimizer.js_transform_tempfiles) # track files that will need native eols @@ -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]) @@ -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: diff --git a/site/build/text/docs/tools_reference/emcc.txt b/site/build/text/docs/tools_reference/emcc.txt index 7489b201de789..b503362fc036a 100644 --- a/site/build/text/docs/tools_reference/emcc.txt +++ b/site/build/text/docs/tools_reference/emcc.txt @@ -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 " + 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: "" + "" + ".map". + "--minify 0" Identical to "-g1". diff --git a/site/source/docs/tools_reference/emcc.rst b/site/source/docs/tools_reference/emcc.rst index cda2ab112c867..16d9595e3bbd5 100644 --- a/site/source/docs/tools_reference/emcc.rst +++ b/site/source/docs/tools_reference/emcc.rst @@ -304,6 +304,11 @@ Options that are modified or new in *emcc* are listed below: - See `src/shell.html `_ and `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 `` + 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: ```` + ```` + ``.map``. .. _emcc-minify: