Skip to content

Commit 4980472

Browse files
authored
Consolidate separate extension lists. NFC (emscripten-core#23473)
1 parent e06f93b commit 4980472

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

emcc.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,17 @@
5858
import bootstrap
5959
bootstrap.check()
6060

61-
# endings = dot + a suffix, compare against result of shared.suffix()
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']
67-
SPECIAL_ENDINGLESS_FILENAMES = [os.devnull]
68-
C_EXTENSIONS += SPECIAL_ENDINGLESS_FILENAMES # consider the special endingless filenames like /dev/null to be C
69-
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']
61+
PREPROCESSED_EXTENSIONS = {'.i', '.ii'}
62+
ASSEMBLY_EXTENSIONS = {'.s'}
63+
HEADER_EXTENSIONS = {'.h', '.hxx', '.hpp', '.hh', '.H', '.HXX', '.HPP', '.HH'}
64+
SOURCE_EXTENSIONS = {
65+
'.c', '.i', # C
66+
'.cppm', '.pcm', '.cpp', '.cxx', '.cc', '.c++', '.CPP', '.CXX', '.C', '.CC', '.C++', '.ii', # C++
67+
'.m', '.mi', '.mm', '.mii', # ObjC/ObjC++
68+
'.bc', '.ll', # LLVM IR
69+
'.S', # asm with preprocessor
70+
os.devnull # consider the special endingless filenames like /dev/null to be C
71+
} | PREPROCESSED_EXTENSIONS
7372

7473
# These symbol names are allowed in INCOMING_MODULE_JS_API but are not part of the
7574
# default set.
@@ -1018,7 +1017,7 @@ def compile_source_file(i, input_file):
10181017
# First, generate LLVM bitcode. For each input file, we get base.o with bitcode
10191018
for i, input_file in input_files:
10201019
file_suffix = get_file_suffix(input_file)
1021-
if file_suffix in SOURCE_EXTENSIONS + ASSEMBLY_EXTENSIONS or (options.dash_c and file_suffix == '.bc'):
1020+
if file_suffix in SOURCE_EXTENSIONS | ASSEMBLY_EXTENSIONS or (options.dash_c and file_suffix == '.bc'):
10221021
compile_source_file(i, input_file)
10231022
elif file_suffix in DYLIB_EXTENSIONS:
10241023
logger.debug(f'using shared library: {input_file}')

0 commit comments

Comments
 (0)