Skip to content

Commit

Permalink
Fix relative paths in wasm backend source maps. Fixes #9837
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken committed Nov 21, 2019
1 parent c2b82bf commit a213913
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -8909,6 +8909,21 @@ def test_wasm_sourcemap_dead(self):
# has only two entries
self.assertRegexpMatches(output, r'"mappings":\s*"[A-Za-z0-9+/]+,[A-Za-z0-9+/]+"')

def test_wasm_sourcemap_relative_paths(self):
filename = 'a.cpp'
shutil.copyfile(path_from_root('tests', 'hello_123.c'), 'a.cpp')
filenames = [
filename,
os.path.abspath(filename)
]
if not WINDOWS:
filenames.append('./' + filename)
for curr in filenames:
print(curr)
run_process([PYTHON, EMCC, curr, '-g4'])
with open('a.out.wasm.map', 'r') as f:
self.assertIn('"a.cpp"', str(f.read()))

def test_wasm_producers_section(self):
# no producers section by default
run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.c')])
Expand Down
2 changes: 1 addition & 1 deletion tools/wasm-sourcemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def build_sourcemap(entries, code_section_offset, prefixes, collect_sources):
if column == 0:
column = 1
address = entry['address'] + code_section_offset
file_name = entry['file']
file_name = os.path.relpath(entry['file'])
source_name = prefixes.sources.resolve(file_name)
if source_name not in sources_map:
source_id = len(sources)
Expand Down

0 comments on commit a213913

Please sign in to comment.