55
55
56
56
logger = logging .getLogger ('emcc' )
57
57
58
- # endings = dot + a suffix, safe to test by filename.endswith(endings )
58
+ # endings = dot + a suffix, compare against result of shared.suffix( )
59
59
C_ENDINGS = ('.c' , '.i' )
60
60
CXX_ENDINGS = ('.cpp' , '.cxx' , '.cc' , '.c++' , '.CPP' , '.CXX' , '.C' , '.CC' , '.C++' , '.ii' )
61
61
OBJC_ENDINGS = ('.m' , '.mi' )
@@ -753,7 +753,7 @@ def emsdk_ldflags(user_args):
753
753
library_paths = [
754
754
shared .Cache .get_lib_dir (absolute = True )
755
755
]
756
- ldflags = ['-L' + l for l in library_paths ]
756
+ ldflags = [f '-L{ l } ' for l in library_paths ]
757
757
758
758
if '-nostdlib' in user_args :
759
759
return ldflags
@@ -1775,7 +1775,7 @@ def default_setting(name, new_default):
1775
1775
state .forced_stdlibs .append ('libfetch' )
1776
1776
settings .JS_LIBRARIES .append ((0 , 'library_fetch.js' ))
1777
1777
if settings .USE_PTHREADS :
1778
- settings .FETCH_WORKER_FILE = unsuffixed ( os . path . basename ( target ) ) + '.fetch.js'
1778
+ settings .FETCH_WORKER_FILE = unsuffixed_basename ( target ) + '.fetch.js'
1779
1779
1780
1780
if settings .DEMANGLE_SUPPORT :
1781
1781
settings .EXPORTED_FUNCTIONS += ['___cxa_demangle' ]
@@ -1894,7 +1894,7 @@ def default_setting(name, new_default):
1894
1894
building .user_requested_exports .add ('_emscripten_current_thread_process_queued_calls' )
1895
1895
1896
1896
# set location of worker.js
1897
- settings .PTHREAD_WORKER_FILE = unsuffixed ( os . path . basename ( target ) ) + '.worker.js'
1897
+ settings .PTHREAD_WORKER_FILE = unsuffixed_basename ( target ) + '.worker.js'
1898
1898
else :
1899
1899
settings .JS_LIBRARIES .append ((0 , 'library_pthread_stub.js' ))
1900
1900
@@ -2090,7 +2090,7 @@ def check_memory_setting(setting):
2090
2090
settings .MEM_INIT_IN_WASM = True
2091
2091
2092
2092
# wasm side modules have suffix .wasm
2093
- if settings .SIDE_MODULE and target . endswith ( '.js' ) :
2093
+ if settings .SIDE_MODULE and shared . suffix ( target ) == '.js' :
2094
2094
diagnostics .warning ('emcc' , 'output suffix .js requested, but wasm side modules are just wasm files; emitting only a .wasm, no .js' )
2095
2095
2096
2096
sanitize = set ()
@@ -2350,10 +2350,11 @@ def get_language_mode(args):
2350
2350
def use_cxx (src ):
2351
2351
if 'c++' in language_mode or run_via_emxx :
2352
2352
return True
2353
+ suffix = shared .suffix (src )
2353
2354
# Next consider the filename
2354
- if src . endswith ( C_ENDINGS + OBJC_ENDINGS ) :
2355
+ if suffix in C_ENDINGS + OBJC_ENDINGS :
2355
2356
return False
2356
- if src . endswith ( CXX_ENDINGS ) :
2357
+ if suffix in CXX_ENDINGS :
2357
2358
return True
2358
2359
# Finally fall back to the default
2359
2360
if settings .DEFAULT_TO_CXX :
@@ -2393,7 +2394,7 @@ def get_clang_command_asm(src_file):
2393
2394
if state .mode == Mode .PCH :
2394
2395
headers = [header for _ , header in input_files ]
2395
2396
for header in headers :
2396
- if not header . endswith ( HEADER_ENDINGS ) :
2397
+ if not shared . suffix ( header ) in HEADER_ENDINGS :
2397
2398
exit_with_error (f'cannot mix precompiled headers with non-header inputs: { headers } : { header } ' )
2398
2399
cmd = get_clang_command (header )
2399
2400
if options .output_file :
@@ -2423,7 +2424,7 @@ def get_object_filename(input_file):
2423
2424
return in_temp (unsuffixed (uniquename (input_file )) + options .default_object_extension )
2424
2425
2425
2426
def compile_source_file (i , input_file ):
2426
- logger .debug ('compiling source file: ' + input_file )
2427
+ logger .debug (f 'compiling source file: { input_file } ' )
2427
2428
output_file = get_object_filename (input_file )
2428
2429
if state .mode not in (Mode .COMPILE_ONLY , Mode .PREPROCESS_ONLY ):
2429
2430
linker_inputs .append ((i , output_file ))
@@ -2452,10 +2453,10 @@ def compile_source_file(i, input_file):
2452
2453
if file_suffix in SOURCE_ENDINGS + ASSEMBLY_ENDINGS or (state .has_dash_c and file_suffix == '.bc' ):
2453
2454
compile_source_file (i , input_file )
2454
2455
elif file_suffix in DYNAMICLIB_ENDINGS :
2455
- logger .debug ('using shared library: ' + input_file )
2456
+ logger .debug (f 'using shared library: { input_file } ' )
2456
2457
linker_inputs .append ((i , input_file ))
2457
2458
elif building .is_ar (input_file ):
2458
- logger .debug ('using static library: ' + input_file )
2459
+ logger .debug (f 'using static library: { input_file } ' )
2459
2460
ensure_archive_index (input_file )
2460
2461
linker_inputs .append ((i , input_file ))
2461
2462
elif language_mode :
@@ -2464,7 +2465,7 @@ def compile_source_file(i, input_file):
2464
2465
exit_with_error ('-E or -x required when input is from standard input' )
2465
2466
else :
2466
2467
# Default to assuming the inputs are object files and pass them to the linker
2467
- logger .debug ('using object file: ' + input_file )
2468
+ logger .debug (f 'using object file: { input_file } ' )
2468
2469
linker_inputs .append ((i , input_file ))
2469
2470
2470
2471
return linker_inputs
@@ -2586,7 +2587,7 @@ def phase_source_transforms(options, target):
2586
2587
file_args .append ('--use-preload-plugins' )
2587
2588
if not settings .ENVIRONMENT_MAY_BE_NODE :
2588
2589
file_args .append ('--no-node' )
2589
- file_code = shared .check_call ([shared .FILE_PACKAGER , unsuffixed (target ) + '.data' ] + file_args , stdout = PIPE ).stdout
2590
+ file_code = shared .check_call ([shared .FILE_PACKAGER , shared . replace_suffix (target , '.data' ) ] + file_args , stdout = PIPE ).stdout
2590
2591
options .pre_js = js_manipulation .add_files_pre_js (options .pre_js , file_code )
2591
2592
2592
2593
# Apply pre and postjs files
@@ -3529,7 +3530,7 @@ def generate_worker_js(target, js_target, target_basename):
3529
3530
3530
3531
# compiler output goes in .worker.js file
3531
3532
else :
3532
- move_file (js_target , unsuffixed (js_target ) + '.worker.js' )
3533
+ move_file (js_target , shared . replace_suffix (js_target , '.worker.js' ) )
3533
3534
worker_target_basename = target_basename + '.worker'
3534
3535
proxy_worker_filename = (settings .PROXY_TO_WORKER_FILENAME or worker_target_basename ) + '.js'
3535
3536
0 commit comments