Skip to content

Commit 975f97d

Browse files
authored
Simplify parse_args. NFC (#25684)
There was some inconsistency in `parse_args` where some settings were set directly and others were adding to `changed_settings` and thus deferred. This change simplifies things by simply directly setting in all cases. The two differences between direct and deferred setting are: - Direct settings are always overwritten by explicitly `-s` settings, even when the `-s` setting comes first, because explcit `-s` flags are all processed later. - Direct settings don't end up in the `user_settings` map. I don't think either of these differences matter for the settings in question here.
1 parent 756dfdd commit 975f97d

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tools/cmdline.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ def parse_args(newargs): # noqa: C901, PLR0912, PLR0915
227227
To revalidate these numbers, run `ruff check --select=C901,PLR091`.
228228
"""
229229
options = EmccOptions()
230-
settings_changes = []
231230
user_js_defines = []
232231
should_exit = False
233232
skip = False
@@ -423,7 +422,7 @@ def consume_arg_file():
423422
if newargs[i] == '--memoryprofiler':
424423
options.memory_profiler = True
425424
newargs[i] = ''
426-
settings_changes.append('EMSCRIPTEN_TRACING=1')
425+
settings.EMSCRIPTEN_TRACING = 1
427426
elif check_flag('--emit-symbol-map'):
428427
options.emit_symbol_map = True
429428
settings.EMIT_SYMBOL_MAP = 1
@@ -489,7 +488,7 @@ def consume_arg_file():
489488
elif check_arg('--memory-init-file'):
490489
exit_with_error('--memory-init-file is no longer supported')
491490
elif check_flag('--proxy-to-worker'):
492-
settings_changes.append('PROXY_TO_WORKER=1')
491+
settings.PROXY_TO_WORKER = 1
493492
elif check_arg('--valid-abspath'):
494493
options.valid_abspaths.append(consume_arg())
495494
elif check_flag('--separate-asm'):
@@ -515,7 +514,7 @@ def consume_arg_file():
515514
elif check_flag('--cpuprofiler'):
516515
options.cpu_profiler = True
517516
elif check_flag('--threadprofiler'):
518-
settings_changes.append('PTHREADS_PROFILING=1')
517+
settings.PTHREADS_PROFILING = 1
519518
elif arg in ('-fcolor-diagnostics', '-fdiagnostics-color', '-fdiagnostics-color=always'):
520519
colored_logger.enable(force=True)
521520
elif arg in ('-fno-color-diagnostics', '-fno-diagnostics-color', '-fdiagnostics-color=never'):
@@ -643,7 +642,7 @@ def consume_arg_file():
643642
sys.exit(0)
644643

645644
newargs = [a for a in newargs if a]
646-
return options, settings_changes, user_js_defines, newargs
645+
return options, user_js_defines, newargs
647646

648647

649648
def expand_byte_size_suffixes(value):
@@ -855,14 +854,12 @@ def parse_arguments(args):
855854
newargs[i] += newargs[i + 1]
856855
newargs[i + 1] = ''
857856

858-
options, settings_changes, user_js_defines, newargs = parse_args(newargs)
857+
options, user_js_defines, newargs = parse_args(newargs)
859858

860859
if options.post_link or options.oformat == OFormat.BARE:
861860
diagnostics.warning('experimental', '--oformat=bare/--post-link are experimental and subject to change.')
862861

863-
explicit_settings_changes, newargs = parse_s_args(newargs)
864-
settings_changes += explicit_settings_changes
865-
862+
settings_changes, newargs = parse_s_args(newargs)
866863
for s in settings_changes:
867864
key, value = s.split('=', 1)
868865
key, value = normalize_boolean_setting(key, value)

0 commit comments

Comments
 (0)