aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins/gnu.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/compilers/mixins/gnu.py')
-rw-r--r--mesonbuild/compilers/mixins/gnu.py55
1 files changed, 28 insertions, 27 deletions
diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py
index 93b367b..2b18732 100644
--- a/mesonbuild/compilers/mixins/gnu.py
+++ b/mesonbuild/compilers/mixins/gnu.py
@@ -27,6 +27,7 @@ import typing as T
from ... import mesonlib
from ... import mlog
from ...mesonlib import OptionKey
+from mesonbuild.compilers.compilers import CompileCheckMode
if T.TYPE_CHECKING:
from ..._typing import ImmutableListProtocol
@@ -41,21 +42,21 @@ else:
# XXX: prevent circular references.
# FIXME: this really is a posix interface not a c-like interface
-clike_debug_args = {
+clike_debug_args: T.Dict[bool, T.List[str]] = {
False: [],
True: ['-g'],
-} # type: T.Dict[bool, T.List[str]]
+}
-gnulike_buildtype_args = {
+gnulike_buildtype_args: T.Dict[str, T.List[str]] = {
'plain': [],
'debug': [],
'debugoptimized': [],
'release': [],
'minsize': [],
'custom': [],
-} # type: T.Dict[str, T.List[str]]
+}
-gnu_optimization_args = {
+gnu_optimization_args: T.Dict[str, T.List[str]] = {
'plain': [],
'0': ['-O0'],
'g': ['-Og'],
@@ -63,9 +64,9 @@ gnu_optimization_args = {
'2': ['-O2'],
'3': ['-O3'],
's': ['-Os'],
-} # type: T.Dict[str, T.List[str]]
+}
-gnulike_instruction_set_args = {
+gnulike_instruction_set_args: T.Dict[str, T.List[str]] = {
'mmx': ['-mmmx'],
'sse': ['-msse'],
'sse2': ['-msse2'],
@@ -76,22 +77,22 @@ gnulike_instruction_set_args = {
'avx': ['-mavx'],
'avx2': ['-mavx2'],
'neon': ['-mfpu=neon'],
-} # type: T.Dict[str, T.List[str]]
+}
-gnu_symbol_visibility_args = {
+gnu_symbol_visibility_args: T.Dict[str, T.List[str]] = {
'': [],
'default': ['-fvisibility=default'],
'internal': ['-fvisibility=internal'],
'hidden': ['-fvisibility=hidden'],
'protected': ['-fvisibility=protected'],
'inlineshidden': ['-fvisibility=hidden', '-fvisibility-inlines-hidden'],
-} # type: T.Dict[str, T.List[str]]
+}
-gnu_color_args = {
+gnu_color_args: T.Dict[str, T.List[str]] = {
'auto': ['-fdiagnostics-color=auto'],
'always': ['-fdiagnostics-color=always'],
'never': ['-fdiagnostics-color=never'],
-} # type: T.Dict[str, T.List[str]]
+}
# Warnings collected from the GCC source and documentation. This is an
# objective set of all the warnings flags that apply to general projects: the
@@ -117,7 +118,7 @@ gnu_color_args = {
#
# Omitted warnings enabled elsewhere in meson:
# -Winvalid-pch (GCC 3.4.0)
-gnu_common_warning_args = {
+gnu_common_warning_args: T.Dict[str, T.List[str]] = {
"0.0.0": [
"-Wcast-qual",
"-Wconversion",
@@ -212,7 +213,7 @@ gnu_common_warning_args = {
"-Wopenacc-parallelism",
"-Wtrivial-auto-var-init",
],
-} # type: T.Dict[str, T.List[str]]
+}
# GCC warnings for C
# Omitted non-general or legacy warnings:
@@ -222,7 +223,7 @@ gnu_common_warning_args = {
# -Wdeclaration-after-statement
# -Wtraditional
# -Wtraditional-conversion
-gnu_c_warning_args = {
+gnu_c_warning_args: T.Dict[str, T.List[str]] = {
"0.0.0": [
"-Wbad-function-cast",
"-Wmissing-prototypes",
@@ -239,7 +240,7 @@ gnu_c_warning_args = {
"4.5.0": [
"-Wunsuffixed-float-constants",
],
-} # type: T.Dict[str, T.List[str]]
+}
# GCC warnings for C++
# Omitted non-general or legacy warnings:
@@ -249,7 +250,7 @@ gnu_c_warning_args = {
# -Wctad-maybe-unsupported
# -Wnamespaces
# -Wtemplates
-gnu_cpp_warning_args = {
+gnu_cpp_warning_args: T.Dict[str, T.List[str]] = {
"0.0.0": [
"-Wctor-dtor-privacy",
"-Weffc++",
@@ -308,13 +309,13 @@ gnu_cpp_warning_args = {
"-Wdeprecated-enum-float-conversion",
"-Winvalid-imported-macros",
],
-} # type: T.Dict[str, T.List[str]]
+}
# GCC warnings for Objective C and Objective C++
# Omitted non-general or legacy warnings:
# -Wtraditional
# -Wtraditional-conversion
-gnu_objc_warning_args = {
+gnu_objc_warning_args: T.Dict[str, T.List[str]] = {
"0.0.0": [
"-Wselector",
],
@@ -325,7 +326,7 @@ gnu_objc_warning_args = {
"-Wassign-intercept",
"-Wstrict-selector-match",
],
-} # type: T.Dict[str, T.List[str]]
+}
_LANG_MAP = {
'c': 'c',
@@ -344,7 +345,7 @@ def gnulike_default_include_dirs(compiler: T.Tuple[str, ...], lang: str) -> 'Imm
cmd = list(compiler) + [f'-x{lang}', '-E', '-v', '-']
_, stdout, _ = mesonlib.Popen_safe(cmd, stderr=subprocess.STDOUT, env=env)
parse_state = 0
- paths = [] # type: T.List[str]
+ paths: T.List[str] = []
for line in stdout.split('\n'):
line = line.strip(' \n\r\t')
if parse_state == 0:
@@ -464,7 +465,7 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta):
def _get_search_dirs(self, env: 'Environment') -> str:
extra_args = ['--print-search-dirs']
with self._build_wrapper('', env, extra_args=extra_args,
- dependencies=None, mode='compile',
+ dependencies=None, mode=CompileCheckMode.COMPILE,
want_output=True) as p:
return p.stdout
@@ -482,7 +483,7 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta):
# pathlib treats empty paths as '.', so filter those out
paths = [p for p in pathstr.split(pathsep) if p]
- result = []
+ result: T.List[str] = []
for p in paths:
# GCC returns paths like this:
# /usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/lib
@@ -528,8 +529,8 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta):
args.append('-fno-omit-frame-pointer')
return args
- def get_output_args(self, target: str) -> T.List[str]:
- return ['-o', target]
+ def get_output_args(self, outputname: str) -> T.List[str]:
+ return ['-o', outputname]
def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
return ['-MD', '-MQ', outtarget, '-MF', outfile]
@@ -589,7 +590,7 @@ class GnuCompiler(GnuLikeCompiler):
return args
def supported_warn_args(self, warn_args_by_version: T.Dict[str, T.List[str]]) -> T.List[str]:
- result = []
+ result: T.List[str] = []
for version, warn_args in warn_args_by_version.items():
if mesonlib.version_compare(self.version, '>=' + version):
result += warn_args
@@ -613,7 +614,7 @@ class GnuCompiler(GnuLikeCompiler):
return ['-fopenmp']
def has_arguments(self, args: T.List[str], env: 'Environment', code: str,
- mode: str) -> T.Tuple[bool, bool]:
+ mode: CompileCheckMode) -> T.Tuple[bool, bool]:
# For some compiler command line arguments, the GNU compilers will
# emit a warning on stderr indicating that an option is valid for a
# another language, but still complete with exit_success