Skip to content

Commit c239ade

Browse files
authored
Move convert_line_endings_in_file into link.py. NFC (#26360)
This is the only file that uses it so we don't need to it in the shared utils.
1 parent 6166bb7 commit c239ade

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

tools/link.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,15 @@ def create_esm_wrapper(wrapper_file, support_target, wasm_target):
21842184
shared.check_call(cmd, input=mod)
21852185

21862186

2187+
def convert_line_endings_in_file(filename, to_eol):
2188+
if to_eol == os.linesep:
2189+
assert os.path.exists(filename)
2190+
return # No conversion needed
2191+
2192+
text = read_file(filename)
2193+
write_file(filename, text, line_endings=to_eol)
2194+
2195+
21872196
@ToolchainProfiler.profile_block('final emitting')
21882197
def phase_final_emitting(options, target, js_target, wasm_target):
21892198
global final_js
@@ -2246,7 +2255,7 @@ def phase_final_emitting(options, target, js_target, wasm_target):
22462255

22472256
target_basename = unsuffixed_basename(target)
22482257

2249-
utils.convert_line_endings_in_file(js_target, options.output_eol)
2258+
convert_line_endings_in_file(js_target, options.output_eol)
22502259

22512260
# If we were asked to also generate HTML, do that
22522261
if options.oformat == OFormat.HTML:
@@ -2636,7 +2645,7 @@ def generate_html(target, options, js_target, target_basename, wasm_target):
26362645
if settings.MINIFY_HTML and (settings.OPT_LEVEL >= 1 or settings.SHRINK_LEVEL >= 1):
26372646
minify_html(target)
26382647

2639-
utils.convert_line_endings_in_file(target, options.output_eol)
2648+
convert_line_endings_in_file(target, options.output_eol)
26402649

26412650

26422651
def find_library(lib, lib_dirs):

tools/utils.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,6 @@ def safe_copy(src, dst):
152152
make_writable(dst)
153153

154154

155-
def convert_line_endings_in_file(filename, to_eol):
156-
if to_eol == os.linesep:
157-
assert os.path.exists(filename)
158-
return # No conversion needed
159-
160-
text = read_file(filename)
161-
write_file(filename, text, line_endings=to_eol)
162-
163-
164155
def read_file(file_path):
165156
"""Read from a file opened in text mode"""
166157
with open(file_path, encoding='utf-8') as fh:

0 commit comments

Comments
 (0)