aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-10-01 09:28:24 -0700
committerDylan Baker <dylan@pnwbakers.com>2024-10-01 10:39:23 -0700
commitcd75bbee9bd887a162f1da9eea2fe24c0b07c312 (patch)
tree8dfb34ceb8105b13c9ab02fece4791044294475b
parentd528b83ff2660518009495e02eea1d2917112082 (diff)
downloadmeson-cd75bbee9bd887a162f1da9eea2fe24c0b07c312.zip
meson-cd75bbee9bd887a162f1da9eea2fe24c0b07c312.tar.gz
meson-cd75bbee9bd887a162f1da9eea2fe24c0b07c312.tar.bz2
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.
-rw-r--r--mesonbuild/compilers/compilers.py3
-rw-r--r--mesonbuild/compilers/fortran.py4
2 files changed, 3 insertions, 4 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 35a0b2b..dbe8027 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.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]
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index a99a95c..5012fba 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -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': [],