@@ -330,7 +330,7 @@ def expand_byte_size_suffixes(value):
330
330
331
331
332
332
def apply_settings (changes ):
333
- """Take a list of settings in form ` NAME= VALUE` and apply them to the global
333
+ """Take a map of users settings { NAME: VALUE} and apply them to the global
334
334
Settings object.
335
335
"""
336
336
@@ -344,8 +344,7 @@ def standardize_setting_change(key, value):
344
344
value = str (1 - int (value ))
345
345
return key , value
346
346
347
- for change in changes :
348
- key , value = change .split ('=' , 1 )
347
+ for key , value in changes .items ():
349
348
key , value = standardize_setting_change (key , value )
350
349
351
350
if key in shared .Settings .internal_settings :
@@ -365,14 +364,14 @@ def standardize_setting_change(key, value):
365
364
if value and value [0 ] == '@' :
366
365
filename = value [1 :]
367
366
if not os .path .exists (filename ):
368
- exit_with_error ('%s: file not found parsing argument: %s' % (filename , change ))
367
+ exit_with_error ('%s: file not found parsing argument: %=% s' % (filename , key , value ))
369
368
value = open (filename ).read ()
370
369
else :
371
370
value = value .replace ('\\ ' , '\\ \\ ' )
372
371
try :
373
372
value = parse_value (value )
374
373
except Exception as e :
375
- exit_with_error ('a problem occurred in evaluating the content after a "-s", specifically "%s": %s' , change , str (e ))
374
+ exit_with_error ('a problem occurred in evaluating the content after a "-s", specifically "%s=%s ": %s' , key , value , str (e ))
376
375
377
376
# Do some basic type checking by comparing to the existing settings.
378
377
# Sadly we can't do this generically in the SettingsManager since there are settings
@@ -1138,15 +1137,15 @@ def add_link_flag(i, f):
1138
1137
newargs [i ] = ''
1139
1138
newargs = [a for a in newargs if a ]
1140
1139
1141
- settings_key_changes = {}
1140
+ settings_map = {}
1142
1141
for s in settings_changes :
1143
1142
key , value = s .split ('=' , 1 )
1144
- settings_key_changes [key ] = value
1143
+ settings_map [key ] = value
1145
1144
1146
1145
# Libraries are searched before settings_changes are applied, so apply the
1147
1146
# value for STRICT from command line already now.
1148
1147
1149
- strict_cmdline = settings_key_changes .get ('STRICT' )
1148
+ strict_cmdline = settings_map .get ('STRICT' )
1150
1149
if strict_cmdline :
1151
1150
shared .Settings .STRICT = int (strict_cmdline )
1152
1151
@@ -1155,15 +1154,15 @@ def add_link_flag(i, f):
1155
1154
1156
1155
# For users that opt out of WARN_ON_UNDEFINED_SYMBOLS we assume they also
1157
1156
# want to opt out of ERROR_ON_UNDEFINED_SYMBOLS.
1158
- if settings_key_changes .get ('WARN_ON_UNDEFINED_SYMBOLS' ) == '0' :
1157
+ if settings_map .get ('WARN_ON_UNDEFINED_SYMBOLS' ) == '0' :
1159
1158
shared .Settings .ERROR_ON_UNDEFINED_SYMBOLS = 0
1160
1159
1161
- if shared .Settings .MINIMAL_RUNTIME or settings_key_changes .get ('MINIMAL_RUNTIME' ) in ('1' , '2' ):
1160
+ if shared .Settings .MINIMAL_RUNTIME or settings_map .get ('MINIMAL_RUNTIME' ) in ('1' , '2' ):
1162
1161
# Remove the default exported functions 'malloc', 'free', etc. those should only be linked in if used
1163
1162
shared .Settings .DEFAULT_LIBRARY_FUNCS_TO_INCLUDE = []
1164
1163
1165
1164
# Apply -s settings in newargs here (after optimization levels, so they can override them)
1166
- apply_settings (settings_changes )
1165
+ apply_settings (settings_map )
1167
1166
1168
1167
specified_target = options .output_file
1169
1168
@@ -1277,7 +1276,7 @@ def add_link_flag(i, f):
1277
1276
# reactor.
1278
1277
# 2. If the user doesn't export anything we default to exporting `_main` (unless `--no-entry`
1279
1278
# is specified (see above).
1280
- if 'EXPORTED_FUNCTIONS' in settings_key_changes :
1279
+ if 'EXPORTED_FUNCTIONS' in settings_map :
1281
1280
if '_main' not in shared .Settings .USER_EXPORTED_FUNCTIONS :
1282
1281
shared .Settings .EXPECT_MAIN = 0
1283
1282
else :
@@ -1289,7 +1288,7 @@ def add_link_flag(i, f):
1289
1288
# See https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
1290
1289
# For a command we always want EXIT_RUNTIME=1
1291
1290
# For a reactor we always want EXIT_RUNTIME=0
1292
- if 'EXIT_RUNTIME' in settings_key_changes :
1291
+ if 'EXIT_RUNTIME' in settings_map :
1293
1292
exit_with_error ('Explictly setting EXIT_RUNTIME not compatible with STANDALONE_WASM. EXIT_RUNTIME will always be True for programs (with a main function) and False for reactors (not main function).' )
1294
1293
shared .Settings .EXIT_RUNTIME = shared .Settings .EXPECT_MAIN
1295
1294
@@ -1332,7 +1331,7 @@ def filter_out_duplicate_dynamic_libs(inputs):
1332
1331
building .user_requested_exports = shared .Settings .EXPORTED_FUNCTIONS [:]
1333
1332
1334
1333
def default_setting (name , new_default ):
1335
- if name not in settings_key_changes :
1334
+ if name not in settings_map :
1336
1335
setattr (shared .Settings , name , new_default )
1337
1336
1338
1337
# -s ASSERTIONS=1 implies basic stack overflow checks, and ASSERTIONS=2
@@ -1774,7 +1773,7 @@ def check_memory_setting(setting):
1774
1773
1775
1774
if shared .Settings .EXPORT_ES6 and not shared .Settings .MODULARIZE :
1776
1775
# EXPORT_ES6 requires output to be a module
1777
- if 'MODULARIZE' in settings_key_changes :
1776
+ if 'MODULARIZE' in settings_map :
1778
1777
exit_with_error ('EXPORT_ES6 requires MODULARIZE to be set' )
1779
1778
shared .Settings .MODULARIZE = 1
1780
1779
@@ -1847,7 +1846,7 @@ def check_memory_setting(setting):
1847
1846
if options .use_closure_compiler == 2 and not shared .Settings .WASM2JS :
1848
1847
exit_with_error ('closure compiler mode 2 assumes the code is asm.js, so not meaningful for wasm' )
1849
1848
1850
- if 'MEM_INIT_METHOD' in settings_key_changes :
1849
+ if 'MEM_INIT_METHOD' in settings_map :
1851
1850
exit_with_error ('MEM_INIT_METHOD is not supported in wasm. Memory will be embedded in the wasm binary if threads are not used, and included in a separate file if threads are used.' )
1852
1851
1853
1852
if shared .Settings .WASM2JS :
@@ -2027,7 +2026,7 @@ def get_full_import_name(name):
2027
2026
2028
2027
# Any "pointers" passed to JS will now be i64's, in both modes.
2029
2028
if shared .Settings .MEMORY64 :
2030
- if settings_key_changes .get ('WASM_BIGINT' ) == '0' :
2029
+ if settings_map .get ('WASM_BIGINT' ) == '0' :
2031
2030
exit_with_error ('MEMORY64 is not compatible with WASM_BIGINT=0' )
2032
2031
shared .Settings .WASM_BIGINT = 1
2033
2032
0 commit comments