Skip to content

Commit cd75bbe

Browse files
committed
compilers: remove hasattr for file_suffixes
This is used in exactly two cases, and it's just not worth it. Those two cases can override the default set of extensions, and in the process allow a nice bit of code cleanup, especially toward type checking.
1 parent d528b83 commit cd75bbe

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

mesonbuild/compilers/compilers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,7 @@ def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str,
452452
self.exelist = ccache + exelist
453453
self.exelist_no_ccache = exelist
454454
# In case it's been overridden by a child class already
455-
if not hasattr(self, 'file_suffixes'):
456-
self.file_suffixes = lang_suffixes[self.language]
455+
self.file_suffixes = lang_suffixes[self.language]
457456
if not hasattr(self, 'can_compile_suffixes'):
458457
self.can_compile_suffixes: T.Set[str] = set(self.file_suffixes)
459458
self.default_suffix = self.file_suffixes[0]

mesonbuild/compilers/fortran.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ def openmp_flags(self, env: Environment) -> T.List[str]:
262262

263263
class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler):
264264

265-
file_suffixes = ('f90', 'f', 'for', 'ftn', 'fpp', )
266265
id = 'intel'
267266

268267
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
@@ -275,6 +274,7 @@ def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoic
275274
# FIXME: Add support for OS X and Windows in detect_fortran_compiler so
276275
# we are sent the type of compiler
277276
IntelGnuLikeCompiler.__init__(self)
277+
self.file_suffixes = ('f90', 'f', 'for', 'ftn', 'fpp', )
278278
default_warn_args = ['-warn', 'general', '-warn', 'truncated_source']
279279
self.warn_args = {'0': [],
280280
'1': default_warn_args,
@@ -318,7 +318,6 @@ class IntelLLVMFortranCompiler(IntelFortranCompiler):
318318

319319
class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler):
320320

321-
file_suffixes = ('f90', 'f', 'for', 'ftn', 'fpp', )
322321
always_args = ['/nologo']
323322

324323
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice,
@@ -329,6 +328,7 @@ def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoic
329328
is_cross, info, linker=linker,
330329
full_version=full_version)
331330
IntelVisualStudioLikeCompiler.__init__(self, target)
331+
self.file_suffixes = ('f90', 'f', 'for', 'ftn', 'fpp', )
332332

333333
default_warn_args = ['/warn:general', '/warn:truncated_source']
334334
self.warn_args = {'0': [],

0 commit comments

Comments
 (0)