@@ -322,6 +322,40 @@ def embed_memfile(options):
322
322
return shared .Settings .SINGLE_FILE or (shared .Settings .MEM_INIT_METHOD == 0 and (not shared .Settings .MAIN_MODULE and not shared .Settings .SIDE_MODULE and not use_source_map (options )))
323
323
324
324
325
+ def apply_settings (changes ):
326
+ """Take a list of settings in form `NAME=VALUE` and apply them to the global
327
+ Settings object.
328
+ """
329
+
330
+ for change in changes :
331
+ key , value = change .split ('=' , 1 )
332
+
333
+ # In those settings fields that represent amount of memory, translate suffixes to multiples of 1024.
334
+ if key in ('TOTAL_STACK' , 'TOTAL_MEMORY' , 'GL_MAX_TEMP_BUFFER_SIZE' ,
335
+ 'SPLIT_MEMORY' , 'WASM_MEM_MAX' , 'DEFAULT_PTHREAD_STACK_SIZE' ):
336
+ value = str (shared .expand_byte_size_suffixes (value ))
337
+
338
+ original_exported_response = False
339
+
340
+ if value [0 ] == '@' :
341
+ if key not in DEFERRED_REPONSE_FILES :
342
+ if key == 'EXPORTED_FUNCTIONS' :
343
+ original_exported_response = value
344
+ value = open (value [1 :]).read ()
345
+ else :
346
+ value = '"' + value + '"'
347
+ else :
348
+ value = value .replace ('\\ ' , '\\ \\ ' )
349
+ try :
350
+ setattr (shared .Settings , key , parse_value (value ))
351
+ except Exception as e :
352
+ exit_with_error ('a problem occured in evaluating the content after a "-s", specifically "%s": %s' , change , str (e ))
353
+
354
+ if key == 'EXPORTED_FUNCTIONS' :
355
+ # used for warnings in emscripten.py
356
+ shared .Settings .ORIGINAL_EXPORTED_FUNCTIONS = original_exported_response or shared .Settings .EXPORTED_FUNCTIONS [:]
357
+
358
+
325
359
#
326
360
# Main run() function
327
361
#
@@ -756,11 +790,11 @@ def detect_fixed_language_mode(args):
756
790
settings_key_changes = set ()
757
791
758
792
def setting_sub (s ):
759
- key , rest = s .split ('=' , 1 )
793
+ key , value = s .split ('=' , 1 )
760
794
settings_key_changes .add (key )
761
- return '=' .join ([settings_aliases .get (key , key ), rest ])
795
+ return '=' .join ([settings_aliases .get (key , key ), value ])
762
796
763
- settings_changes = list ( map ( setting_sub , settings_changes ))
797
+ settings_changes = [ setting_sub ( c ) for c in settings_changes ]
764
798
765
799
# Find input files
766
800
@@ -940,32 +974,7 @@ def check(input_file):
940
974
shared .Settings .ASM_JS = 1 if options .opt_level > 0 else 2
941
975
942
976
# Apply -s settings in newargs here (after optimization levels, so they can override them)
943
- for change in settings_changes :
944
- key , value = change .split ('=' , 1 )
945
-
946
- # In those settings fields that represent amount of memory, translate suffixes to multiples of 1024.
947
- if key in ['TOTAL_STACK' , 'TOTAL_MEMORY' , 'GL_MAX_TEMP_BUFFER_SIZE' , 'SPLIT_MEMORY' , 'WASM_MEM_MAX' , 'DEFAULT_PTHREAD_STACK_SIZE' ]:
948
- value = str (shared .expand_byte_size_suffixes (value ))
949
-
950
- original_exported_response = False
951
-
952
- if value [0 ] == '@' :
953
- if key not in DEFERRED_REPONSE_FILES :
954
- if key == 'EXPORTED_FUNCTIONS' :
955
- original_exported_response = value
956
- value = open (value [1 :]).read ()
957
- else :
958
- value = '"' + value + '"'
959
- else :
960
- value = value .replace ('\\ ' , '\\ \\ ' )
961
- try :
962
- setattr (shared .Settings , key , parse_value (value ))
963
- except Exception as e :
964
- exit_with_error ('a problem occured in evaluating the content after a "-s", specifically "%s": %s' , change , str (e ))
965
-
966
- if key == 'EXPORTED_FUNCTIONS' :
967
- # used for warnings in emscripten.py
968
- shared .Settings .ORIGINAL_EXPORTED_FUNCTIONS = original_exported_response or shared .Settings .EXPORTED_FUNCTIONS [:]
977
+ apply_settings (settings_changes )
969
978
970
979
shared .verify_settings ()
971
980
0 commit comments