Skip to content

Commit 9803070

Browse files
authored
Refactor inlining code in generate_traditional_runtime_html. NFC (emscripten-core#22548)
I noticed we had an `if SINGLE_FILE` block following an `if not SINGLE_FILE` block. This change combines them into and `if`/`else`.
1 parent 3073806 commit 9803070

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tools/link.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,7 +2535,15 @@ def generate_traditional_runtime_html(target, options, js_target, target_basenam
25352535
# Normal code generation path
25362536
script.src = base_js_target
25372537

2538-
if not settings.SINGLE_FILE:
2538+
# inline script for SINGLE_FILE output
2539+
if settings.SINGLE_FILE:
2540+
js_contents = script.inline or ''
2541+
if script.src:
2542+
js_contents += read_file(js_target)
2543+
delete_file(js_target)
2544+
script.src = None
2545+
script.inline = js_contents
2546+
else:
25392547
if not settings.WASM_ASYNC_COMPILATION:
25402548
# We need to load the wasm file before anything else, since it
25412549
# has be synchronously ready.
@@ -2569,15 +2577,6 @@ def generate_traditional_runtime_html(target, options, js_target, target_basenam
25692577
}
25702578
''' % (script.inline, get_subresource_location(wasm_target) + '.js')
25712579

2572-
# inline script for SINGLE_FILE output
2573-
if settings.SINGLE_FILE:
2574-
js_contents = script.inline or ''
2575-
if script.src:
2576-
js_contents += read_file(js_target)
2577-
delete_file(js_target)
2578-
script.src = None
2579-
script.inline = js_contents
2580-
25812580
shell = do_replace(shell, '{{{ SCRIPT }}}', script.replacement())
25822581
shell = shell.replace('{{{ SHELL_CSS }}}', utils.read_file(utils.path_from_root('src/shell.css')))
25832582
logo_filename = utils.path_from_root('media/powered_by_logo_shell.png')

0 commit comments

Comments
 (0)