aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/fortran.py31
-rw-r--r--mesonbuild/compilers/mixins/clike.py10
2 files changed, 22 insertions, 19 deletions
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index c4451c1..16a93f5 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -142,14 +142,15 @@ class FortranCompiler(CLikeCompiler, Compiler):
return filename
def find_library(self, libname, env, extra_dirs, libtype: LibType = LibType.PREFER_SHARED):
- code = '''stop; end program'''
+ code = 'stop; end program'
return self.find_library_impl(libname, env, extra_dirs, code, libtype)
- def has_multi_arguments(self, args, env):
+ def has_multi_arguments(self, args: T.Sequence[str], env):
for arg in args[:]:
# some compilers, e.g. GCC, don't warn for unsupported warning-disable
# flags, so when we are testing a flag like "-Wno-forgotten-towel", also
# check the equivalent enable flag too "-Wforgotten-towel"
+ # GCC does error for "-fno-foobar"
if arg.startswith('-Wno-'):
args.append('-W' + arg[5:])
if arg.startswith('-Wl,'):
@@ -197,16 +198,16 @@ class GnuFortranCompiler(GnuCompiler, FortranCompiler):
args.append('-std=' + std.value)
return args
- def get_dependency_gen_args(self, outtarget, outfile):
+ def get_dependency_gen_args(self, outtarget, outfile) -> T.List[str]:
# Disabled until this is fixed:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62162
# return ['-cpp', '-MD', '-MQ', outtarget]
return []
- def get_module_outdir_args(self, path):
+ def get_module_outdir_args(self, path: str) -> T.List[str]:
return ['-J' + path]
- def language_stdlib_only_link_flags(self):
+ def language_stdlib_only_link_flags(self) -> T.List[str]:
return ['-lgfortran', '-lm']
class ElbrusFortranCompiler(GnuFortranCompiler, ElbrusCompiler):
@@ -233,7 +234,7 @@ class G95FortranCompiler(FortranCompiler):
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-pedantic']}
- def get_module_outdir_args(self, path):
+ def get_module_outdir_args(self, path: str) -> T.List[str]:
return ['-fmod=' + path]
def get_no_warn_args(self):
@@ -251,7 +252,7 @@ class SunFortranCompiler(FortranCompiler):
FortranCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, **kwargs)
self.id = 'sun'
- def get_dependency_gen_args(self, outtarget, outfile):
+ def get_dependency_gen_args(self, outtarget, outfile) -> T.List[str]:
return ['-fpp']
def get_always_args(self):
@@ -263,10 +264,10 @@ class SunFortranCompiler(FortranCompiler):
def get_module_incdir_args(self):
return ('-M', )
- def get_module_outdir_args(self, path):
+ def get_module_outdir_args(self, path: str) -> T.List[str]:
return ['-moddir=' + path]
- def openmp_flags(self):
+ def openmp_flags(self) -> T.List[str]:
return ['-xopenmp']
@@ -304,7 +305,7 @@ class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler):
args.append('-stand=' + stds[std.value])
return args
- def get_preprocess_only_args(self):
+ def get_preprocess_only_args(self) -> T.List[str]:
return ['-cpp', '-EP']
def get_always_args(self):
@@ -313,7 +314,7 @@ class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler):
val.remove('-pipe')
return val
- def language_stdlib_only_link_flags(self):
+ def language_stdlib_only_link_flags(self) -> T.List[str]:
return ['-lifcore', '-limf']
def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
@@ -371,7 +372,7 @@ class PathScaleFortranCompiler(FortranCompiler):
'2': default_warn_args,
'3': default_warn_args}
- def openmp_flags(self):
+ def openmp_flags(self) -> T.List[str]:
return ['-mp']
@@ -423,7 +424,7 @@ class Open64FortranCompiler(FortranCompiler):
'2': default_warn_args,
'3': default_warn_args}
- def openmp_flags(self):
+ def openmp_flags(self) -> T.List[str]:
return ['-mp']
@@ -438,8 +439,8 @@ class NAGFortranCompiler(FortranCompiler):
def get_warn_args(self, level):
return []
- def get_module_outdir_args(self, path):
+ def get_module_outdir_args(self, path) -> T.List[str]:
return ['-mdir', path]
- def openmp_flags(self):
+ def openmp_flags(self) -> T.List[str]:
return ['-openmp']
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index 6b09b97..93c1a7c 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -319,7 +319,7 @@ class CLikeCompiler:
cargs += self.get_compiler_args_for_mode(mode)
return cargs, largs
- def _get_compiler_check_args(self, env, extra_args, dependencies, mode='compile'):
+ def _get_compiler_check_args(self, env, extra_args: list, dependencies, mode: str = 'compile') -> T.List[str]:
if extra_args is None:
extra_args = []
else:
@@ -354,11 +354,13 @@ class CLikeCompiler:
args = cargs + extra_args + largs
return args
- def compiles(self, code, env, *, extra_args=None, dependencies=None, mode='compile', disable_cache=False):
+ def compiles(self, code: str, env, *,
+ extra_args: T.Sequence[T.Union[T.Sequence[str], str]] = None,
+ dependencies=None, mode: str = 'compile', disable_cache=False) -> T.Tuple[bool, bool]:
with self._build_wrapper(code, env, extra_args, dependencies, mode, disable_cache=disable_cache) as p:
return p.returncode == 0, p.cached
- def _build_wrapper(self, code, env, extra_args, dependencies=None, mode='compile', want_output=False, disable_cache=False, temp_dir=None):
+ def _build_wrapper(self, code: str, env, extra_args, dependencies=None, mode: str = 'compile', want_output: bool = False, disable_cache: bool = False, temp_dir=None) -> T.Tuple[bool, bool]:
args = self._get_compiler_check_args(env, extra_args, dependencies, mode)
if disable_cache or want_output:
return self.compile(code, extra_args=args, mode=mode, want_output=want_output, temp_dir=env.scratch_dir)
@@ -1074,7 +1076,7 @@ class CLikeCompiler:
def linker_to_compiler_args(self, args):
return args
- def has_arguments(self, args, env, code, mode):
+ def has_arguments(self, args: T.Sequence[str], env, code: str, mode: str) -> T.Tuple[bool, bool]:
return self.compiles(code, env, extra_args=args, mode=mode)
def has_multi_arguments(self, args, env):