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.
pull/13728/head
Dylan Baker 1 month ago
parent d528b83ff2
commit cd75bbee9b
  1. 3
      mesonbuild/compilers/compilers.py
  2. 4
      mesonbuild/compilers/fortran.py

@ -452,8 +452,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
self.exelist = ccache + exelist
self.exelist_no_ccache = exelist
# In case it's been overridden by a child class already
if not hasattr(self, 'file_suffixes'):
self.file_suffixes = lang_suffixes[self.language]
self.file_suffixes = lang_suffixes[self.language]
if not hasattr(self, 'can_compile_suffixes'):
self.can_compile_suffixes: T.Set[str] = set(self.file_suffixes)
self.default_suffix = self.file_suffixes[0]

@ -262,7 +262,6 @@ class SunFortranCompiler(FortranCompiler):
class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler):
file_suffixes = ('f90', 'f', 'for', 'ftn', 'fpp', )
id = 'intel'
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
@ -275,6 +274,7 @@ class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler):
# FIXME: Add support for OS X and Windows in detect_fortran_compiler so
# we are sent the type of compiler
IntelGnuLikeCompiler.__init__(self)
self.file_suffixes = ('f90', 'f', 'for', 'ftn', 'fpp', )
default_warn_args = ['-warn', 'general', '-warn', 'truncated_source']
self.warn_args = {'0': [],
'1': default_warn_args,
@ -318,7 +318,6 @@ class IntelLLVMFortranCompiler(IntelFortranCompiler):
class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler):
file_suffixes = ('f90', 'f', 'for', 'ftn', 'fpp', )
always_args = ['/nologo']
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice,
@ -329,6 +328,7 @@ class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler):
is_cross, info, linker=linker,
full_version=full_version)
IntelVisualStudioLikeCompiler.__init__(self, target)
self.file_suffixes = ('f90', 'f', 'for', 'ftn', 'fpp', )
default_warn_args = ['/warn:general', '/warn:truncated_source']
self.warn_args = {'0': [],

Loading…
Cancel
Save