Skip to content

Commit fdd89cc

Browse files
committed
Copy source files into source map file
1 parent 8c81cac commit fdd89cc

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

tools/building.py

+1
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,7 @@ def emit_wasm_source_map(wasm_file, map_file, final_wasm):
11271127
wasm_file,
11281128
'--dwarfdump=' + LLVM_DWARFDUMP,
11291129
'-o', map_file,
1130+
'--sources',
11301131
'--basepath=' + base_path]
11311132
check_call(sourcemap_cmd)
11321133

tools/wasm-sourcemap.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def resolve(self, name):
6161
if name in self.cache:
6262
return self.cache[name]
6363

64+
result = name
6465
for p in self.prefixes:
6566
if name.startswith(p['prefix']):
6667
if p['replacement'] is None:
@@ -285,20 +286,20 @@ def build_sourcemap(entries, code_section_offset, prefixes, collect_sources, bas
285286
if prefixes.provided():
286287
source_name = prefixes.sources.resolve(file_name)
287288
else:
289+
source_name = file_name
288290
try:
289-
file_name = os.path.relpath(file_name, base_path)
291+
source_name = os.path.relpath(source_name, base_path)
290292
except ValueError:
291-
file_name = os.path.abspath(file_name)
292-
file_name = utils.normalize_path(file_name)
293-
source_name = file_name
293+
source_name = os.path.abspath(source_name)
294+
source_name = utils.normalize_path(source_name)
294295
if source_name not in sources_map:
295296
source_id = len(sources)
296297
sources_map[source_name] = source_id
297298
sources.append(source_name)
298299
if collect_sources:
299300
load_name = prefixes.load.resolve(file_name)
300301
try:
301-
with open(load_name, 'r') as infile:
302+
with open(os.path.normpath(load_name), 'r') as infile:
302303
source_content = infile.read()
303304
sources_content.append(source_content)
304305
except IOError:

0 commit comments

Comments
 (0)