4545from tools import colored_logger , diagnostics , building
4646from tools .shared import unsuffixed , unsuffixed_basename , WINDOWS , safe_copy
4747from tools .shared import run_process , read_and_preprocess , exit_with_error , DEBUG
48- from tools .shared import do_replace , strip_prefix
48+ from tools .shared import do_replace
4949from tools .response_file import substitute_response_files
5050from tools .minimal_runtime_shell import generate_minimal_runtime_html
5151import tools .line_endings
5555from tools import config
5656from tools import cache
5757from tools .settings import user_settings , settings , MEM_SIZE_SETTINGS , COMPILE_TIME_SETTINGS
58- from tools .utils import read_file , write_file , read_binary , delete_file
58+ from tools .utils import read_file , write_file , read_binary , delete_file , removeprefix
5959
6060logger = logging .getLogger ('emcc' )
6161
@@ -439,7 +439,7 @@ def apply_user_settings():
439439
440440 filename = None
441441 if value and value [0 ] == '@' :
442- filename = strip_prefix (value , '@' )
442+ filename = removeprefix (value , '@' )
443443 if not os .path .exists (filename ):
444444 exit_with_error ('%s: file not found parsing argument: %s=%s' % (filename , key , value ))
445445 value = read_file (filename ).strip ()
@@ -774,7 +774,7 @@ def is_dash_s_for_emcc(args, i):
774774 return False
775775 arg = args [i + 1 ]
776776 else :
777- arg = strip_prefix (args [i ], '-s' )
777+ arg = removeprefix (args [i ], '-s' )
778778 arg = arg .split ('=' )[0 ]
779779 return arg .isidentifier () and arg .isupper ()
780780
@@ -834,7 +834,7 @@ def process_dynamic_libs(dylibs, lib_dirs):
834834 # EM_JS function are exports with a special prefix. We need to strip
835835 # this prefix to get the actaul symbol name. For the main module, this
836836 # is handled by extract_metadata.py.
837- exports = [shared . maybe_strip_prefix (e , '__em_js__' ) for e in exports ]
837+ exports = [utils . removeprefix (e , '__em_js__' ) for e in exports ]
838838 settings .SIDE_MODULE_EXPORTS .extend (sorted (exports ))
839839
840840 imports = webassembly .get_imports (dylib )
@@ -874,7 +874,7 @@ def parse_s_args(args):
874874 key = args [i + 1 ]
875875 args [i + 1 ] = ''
876876 else :
877- key = strip_prefix (args [i ], '-s' )
877+ key = removeprefix (args [i ], '-s' )
878878 args [i ] = ''
879879
880880 # If not = is specified default to 1
@@ -1374,7 +1374,7 @@ def normalize_boolean_setting(name, value):
13741374 # and we can't just flip them, so leave them as-is to be
13751375 # handled in a special way later)
13761376 if name .startswith ('NO_' ) and value in ('0' , '1' ):
1377- name = strip_prefix (name , 'NO_' )
1377+ name = removeprefix (name , 'NO_' )
13781378 value = str (1 - int (value ))
13791379 return name , value
13801380
@@ -1490,7 +1490,7 @@ def phase_setup(options, state, newargs):
14901490 # For shared libraries that are neither bitcode nor wasm, assuming its local native
14911491 # library and attempt to find a library by the same name in our own library path.
14921492 # TODO(sbc): Do we really need this feature? See test_other.py:test_local_link
1493- libname = strip_prefix (get_library_basename (arg ), 'lib' )
1493+ libname = removeprefix (get_library_basename (arg ), 'lib' )
14941494 flag = '-l' + libname
14951495 diagnostics .warning ('map-unrecognized-libraries' , f'unrecognized file type: `{ arg } `. Mapping to `{ flag } ` and hoping for the best' )
14961496 add_link_flag (state , i , flag )
@@ -2963,7 +2963,7 @@ def get_language_mode(args):
29632963 return_next = True
29642964 continue
29652965 if item .startswith ('-x' ):
2966- return strip_prefix (item , '-x' )
2966+ return removeprefix (item , '-x' )
29672967 return ''
29682968
29692969 language_mode = get_language_mode (newargs )
@@ -3371,7 +3371,7 @@ def consume_arg_file():
33713371
33723372 if arg .startswith ('-O' ):
33733373 # Let -O default to -O2, which is what gcc does.
3374- requested_level = strip_prefix (arg , '-O' ) or '2'
3374+ requested_level = removeprefix (arg , '-O' ) or '2'
33753375 if requested_level == 's' :
33763376 requested_level = 2
33773377 settings .SHRINK_LEVEL = 1
@@ -3432,7 +3432,7 @@ def consume_arg_file():
34323432 settings .DEBUG_LEVEL = max (1 , settings .DEBUG_LEVEL )
34333433 elif arg .startswith ('-g' ):
34343434 options .requested_debug = arg
3435- requested_level = strip_prefix (arg , '-g' ) or '3'
3435+ requested_level = removeprefix (arg , '-g' ) or '3'
34363436 if is_int (requested_level ):
34373437 # the -gX value is the debug level (-g1, -g2, etc.)
34383438 settings .DEBUG_LEVEL = validate_arg_level (requested_level , 4 , 'invalid debug level: ' + arg )
@@ -3610,7 +3610,7 @@ def consume_arg_file():
36103610 elif arg == '-frtti' :
36113611 settings .USE_RTTI = 1
36123612 elif arg .startswith ('-jsD' ):
3613- key = strip_prefix (arg , '-jsD' )
3613+ key = removeprefix (arg , '-jsD' )
36143614 if '=' in key :
36153615 key , value = key .split ('=' )
36163616 else :
@@ -3626,7 +3626,7 @@ def consume_arg_file():
36263626 elif check_arg ('-o' ):
36273627 options .output_file = consume_arg ()
36283628 elif arg .startswith ('-o' ):
3629- options .output_file = strip_prefix (arg , '-o' )
3629+ options .output_file = removeprefix (arg , '-o' )
36303630 newargs [i ] = ''
36313631 elif arg == '-mllvm' :
36323632 # Ignore the next argument rather than trying to parse it. This is needed
@@ -4191,7 +4191,7 @@ def process_libraries(state, linker_inputs):
41914191 if not flag .startswith ('-l' ):
41924192 new_flags .append ((i , flag ))
41934193 continue
4194- lib = strip_prefix (flag , '-l' )
4194+ lib = removeprefix (flag , '-l' )
41954195
41964196 logger .debug ('looking for library "%s"' , lib )
41974197 js_libs , native_lib = building .map_to_js_libs (lib )
0 commit comments