Skip to content

Commit c898bb4

Browse files
authored
Honor output-eol, even in SINGLE_FILE mode (#24505)
I traced the exclusion of this file from EOL conversion all the way back to 4c669e4. It seems like maybe there was a fear the EOL conversion might break the base64 encoded data? But IIUC EOL chars cannot appear in a base64 encoded string. Fixes: #24488
1 parent 43876d0 commit c898bb4

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

test/test_other.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9001,14 +9001,23 @@ def test_disable_inlining(self):
90019001
@parameterized({
90029002
'': ([],),
90039003
'proxy_to_worker': (['--proxy-to-worker'],),
9004+
'single_file': (['-sSINGLE_FILE'],),
90049005
'proxy_to_worker_wasm2js': (['--proxy-to-worker', '-sWASM=0'],),
90059006
})
90069007
def test_output_eol(self, params):
90079008
for eol in ('windows', 'linux'):
90089009
self.clear()
90099010
print('checking eol: ', eol)
9010-
self.run_process([EMCC, test_file('hello_world.c'), '-o', 'a.html', '--output-eol', eol] + params)
9011-
for f in ['a.html', 'a.js']:
9011+
if '-sSINGLE_FILE' not in params:
9012+
params.append('-oa.out.html')
9013+
self.run_process([EMCC, test_file('hello_world.c'), '--output-eol', eol] + params)
9014+
out_files = ['a.out.js']
9015+
html_file = 'a.out.html'
9016+
if '-sSINGLE_FILE' in params:
9017+
self.assertNotExists(html_file)
9018+
else:
9019+
out_files.append(html_file)
9020+
for f in out_files:
90129021
self.assertExists(f)
90139022
if eol == 'linux':
90149023
expected_ending = '\n'

tools/link.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,8 @@ def phase_final_emitting(options, target, js_target, wasm_target):
22482248

22492249
target_basename = unsuffixed_basename(target)
22502250

2251+
utils.convert_line_endings_in_file(js_target, options.output_eol)
2252+
22512253
# If we were asked to also generate HTML, do that
22522254
if options.oformat == OFormat.HTML:
22532255
generate_html(target, options, js_target, target_basename,
@@ -2259,9 +2261,6 @@ def phase_final_emitting(options, target, js_target, wasm_target):
22592261
diagnostics.warning('experimental', 'the SPLIT_MODULE setting is experimental and subject to change')
22602262
do_split_module(wasm_target, options)
22612263

2262-
if not settings.SINGLE_FILE:
2263-
utils.convert_line_endings_in_file(js_target, options.output_eol)
2264-
22652264
if options.executable:
22662265
make_js_executable(js_target)
22672266

tools/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def removeprefix(string, prefix):
4949

5050
def convert_line_endings_in_file(filename, to_eol):
5151
if to_eol == os.linesep:
52+
assert os.path.exists(filename)
5253
return # No conversion needed
5354

5455
text = read_file(filename)

0 commit comments

Comments
 (0)