Skip to content

Commit 8432190

Browse files
authored
Rename _ENDINGS -> _EXTENSIONS. NFC (#23472)
This is the more common form I believe.
1 parent 12ca58d commit 8432190

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

emcc.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from tools.shared import unsuffixed, unsuffixed_basename, get_file_suffix
4141
from tools.shared import run_process, exit_with_error, DEBUG
4242
from tools.shared import in_temp, OFormat
43-
from tools.shared import DYNAMICLIB_ENDINGS
43+
from tools.shared import DYLIB_EXTENSIONS
4444
from tools.response_file import substitute_response_files
4545
from tools import config
4646
from tools import cache
@@ -59,17 +59,17 @@
5959
bootstrap.check()
6060

6161
# endings = dot + a suffix, compare against result of shared.suffix()
62-
C_ENDINGS = ['.c', '.i']
63-
CXX_ENDINGS = ['.cppm', '.pcm', '.cpp', '.cxx', '.cc', '.c++', '.CPP', '.CXX', '.C', '.CC', '.C++', '.ii']
64-
OBJC_ENDINGS = ['.m', '.mi']
65-
PREPROCESSED_ENDINGS = ['.i', '.ii']
66-
OBJCXX_ENDINGS = ['.mm', '.mii']
62+
C_EXTENSIONS = ['.c', '.i']
63+
CXX_EXTENSIONS = ['.cppm', '.pcm', '.cpp', '.cxx', '.cc', '.c++', '.CPP', '.CXX', '.C', '.CC', '.C++', '.ii']
64+
OBJC_EXTENSIONS = ['.m', '.mi']
65+
PREPROCESSED_EXTENSIONS = ['.i', '.ii']
66+
OBJCXX_EXTENSIONS = ['.mm', '.mii']
6767
SPECIAL_ENDINGLESS_FILENAMES = [os.devnull]
68-
C_ENDINGS += SPECIAL_ENDINGLESS_FILENAMES # consider the special endingless filenames like /dev/null to be C
68+
C_EXTENSIONS += SPECIAL_ENDINGLESS_FILENAMES # consider the special endingless filenames like /dev/null to be C
6969

70-
SOURCE_ENDINGS = C_ENDINGS + CXX_ENDINGS + OBJC_ENDINGS + OBJCXX_ENDINGS + ['.bc', '.ll', '.S']
71-
ASSEMBLY_ENDINGS = ['.s']
72-
HEADER_ENDINGS = ['.h', '.hxx', '.hpp', '.hh', '.H', '.HXX', '.HPP', '.HH']
70+
SOURCE_EXTENSIONS = C_EXTENSIONS + CXX_EXTENSIONS + OBJC_EXTENSIONS + OBJCXX_EXTENSIONS + ['.bc', '.ll', '.S']
71+
ASSEMBLY_EXTENSIONS = ['.s']
72+
HEADER_EXTENSIONS = ['.h', '.hxx', '.hpp', '.hh', '.H', '.HXX', '.HPP', '.HH']
7373

7474
# These symbol names are allowed in INCOMING_MODULE_JS_API but are not part of the
7575
# default set.
@@ -823,7 +823,7 @@ def phase_setup(options, state):
823823
"""Second phase: configure and setup the compiler based on the specified settings and arguments.
824824
"""
825825

826-
has_header_inputs = any(get_file_suffix(f) in HEADER_ENDINGS for f in options.input_files)
826+
has_header_inputs = any(get_file_suffix(f) in HEADER_EXTENSIONS for f in options.input_files)
827827

828828
if options.post_link:
829829
state.mode = Mode.POST_LINK_ONLY
@@ -983,7 +983,7 @@ def get_clang_command_asm():
983983
if state.mode == Mode.COMPILE_ONLY:
984984
if options.output_file and get_file_suffix(options.output_file) == '.bc' and not settings.LTO and '-emit-llvm' not in state.orig_args:
985985
diagnostics.warning('emcc', '.bc output file suffix used without -flto or -emit-llvm. Consider using .o extension since emcc will output an object file, not a bitcode file')
986-
if all(get_file_suffix(i) in ASSEMBLY_ENDINGS for i in options.input_files):
986+
if all(get_file_suffix(i) in ASSEMBLY_EXTENSIONS for i in options.input_files):
987987
cmd = get_clang_command_asm() + newargs
988988
else:
989989
cmd = get_clang_command() + newargs
@@ -1011,9 +1011,9 @@ def compile_source_file(i, input_file):
10111011
logger.debug(f'compiling source file: {input_file}')
10121012
output_file = get_object_filename(input_file)
10131013
linker_inputs.append((i, output_file))
1014-
if get_file_suffix(input_file) in ASSEMBLY_ENDINGS:
1014+
if get_file_suffix(input_file) in ASSEMBLY_EXTENSIONS:
10151015
cmd = get_clang_command_asm()
1016-
elif get_file_suffix(input_file) in PREPROCESSED_ENDINGS:
1016+
elif get_file_suffix(input_file) in PREPROCESSED_EXTENSIONS:
10171017
cmd = get_clang_command_preprocessed()
10181018
else:
10191019
cmd = get_clang_command()
@@ -1037,9 +1037,9 @@ def compile_source_file(i, input_file):
10371037
# First, generate LLVM bitcode. For each input file, we get base.o with bitcode
10381038
for i, input_file in input_files:
10391039
file_suffix = get_file_suffix(input_file)
1040-
if file_suffix in SOURCE_ENDINGS + ASSEMBLY_ENDINGS or (options.dash_c and file_suffix == '.bc'):
1040+
if file_suffix in SOURCE_EXTENSIONS + ASSEMBLY_EXTENSIONS or (options.dash_c and file_suffix == '.bc'):
10411041
compile_source_file(i, input_file)
1042-
elif file_suffix in DYNAMICLIB_ENDINGS:
1042+
elif file_suffix in DYLIB_EXTENSIONS:
10431043
logger.debug(f'using shared library: {input_file}')
10441044
linker_inputs.append((i, input_file))
10451045
elif building.is_ar(input_file):

tools/link.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from .utils import read_file, write_file, delete_file
3737
from .utils import removeprefix, exit_with_error
3838
from .shared import in_temp, safe_copy, do_replace, OFormat
39-
from .shared import DEBUG, WINDOWS, DYNAMICLIB_ENDINGS
39+
from .shared import DEBUG, WINDOWS, DYLIB_EXTENSIONS
4040
from .shared import unsuffixed, unsuffixed_basename, get_file_suffix
4141
from .settings import settings, default_setting, user_settings, JS_ONLY_SETTINGS, DEPRECATED_SETTINGS
4242
from .minimal_runtime_shell import generate_minimal_runtime_html
@@ -56,7 +56,7 @@
5656

5757
VALID_ENVIRONMENTS = ('web', 'webview', 'worker', 'node', 'shell')
5858

59-
EXECUTABLE_ENDINGS = ['.wasm', '.html', '.js', '.mjs', '.out', '']
59+
EXECUTABLE_EXTENSIONS = ['.wasm', '.html', '.js', '.mjs', '.out', '']
6060

6161
# Supported LLD flags which we will pass through to the linker.
6262
SUPPORTED_LINKER_FLAGS = (
@@ -742,7 +742,7 @@ def phase_linker_setup(options, state): # noqa: C901, PLR0912, PLR0915
742742
# we support a compatibility mode where shared libraries are actually just
743743
# object files linked with `wasm-ld --relocatable` or `llvm-link` in the case
744744
# of LTO.
745-
if final_suffix in EXECUTABLE_ENDINGS:
745+
if final_suffix in EXECUTABLE_EXTENSIONS:
746746
diagnostics.warning('emcc', '-shared/-r used with executable output suffix. This behaviour is deprecated. Please remove -shared/-r to build an executable or avoid the executable suffix (%s) when building object files.' % final_suffix)
747747
else:
748748
if options.shared:
@@ -2828,7 +2828,7 @@ def process_libraries(state):
28282828
# when statically linking. The native linker (wasm-ld) will otherwise
28292829
# ignore .so files in this mode.
28302830
found_dylib = False
2831-
for ext in DYNAMICLIB_ENDINGS:
2831+
for ext in DYLIB_EXTENSIONS:
28322832
name = 'lib' + lib + ext
28332833
path = find_library(name, state.lib_dirs)
28342834
if path:
@@ -2892,7 +2892,7 @@ def replacement(self):
28922892
def filter_out_dynamic_libs(options, inputs):
28932893
# Filters out "fake" dynamic libraries that are really just intermediate object files.
28942894
def check(input_file):
2895-
if get_file_suffix(input_file) in DYNAMICLIB_ENDINGS and not building.is_wasm_dylib(input_file):
2895+
if get_file_suffix(input_file) in DYLIB_EXTENSIONS and not building.is_wasm_dylib(input_file):
28962896
if not options.ignore_dynamic_linking:
28972897
diagnostics.warning('emcc', 'ignoring dynamic library %s because not compiling to JS or HTML, remember to link it when compiling to JS or HTML at the end', os.path.basename(input_file))
28982898
return False
@@ -2908,7 +2908,7 @@ def filter_out_duplicate_dynamic_libs(inputs):
29082908
# Filter out duplicate "fake" shared libraries (intermediate object files).
29092909
# See test_core.py:test_redundant_link
29102910
def check(input_file):
2911-
if get_file_suffix(input_file) in DYNAMICLIB_ENDINGS and not building.is_wasm_dylib(input_file):
2911+
if get_file_suffix(input_file) in DYLIB_EXTENSIONS and not building.is_wasm_dylib(input_file):
29122912
abspath = os.path.abspath(input_file)
29132913
if abspath in seen:
29142914
return False

tools/shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ class OFormat(Enum):
824824
WASM_SOURCEMAP = bat_suffix(path_from_root('tools/wasm-sourcemap'))
825825
# Windows .dll suffix is not included in this list, since those are never
826826
# linked to directly on the command line.
827-
DYNAMICLIB_ENDINGS = ['.dylib', '.so']
827+
DYLIB_EXTENSIONS = ['.dylib', '.so']
828828

829829
run_via_emxx = False
830830

0 commit comments

Comments
 (0)