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.py76
1 files changed, 38 insertions, 38 deletions
diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py
index dcca227..ae4b7db 100644
--- a/mesonbuild/compilers/mixins/gnu.py
+++ b/mesonbuild/compilers/mixins/gnu.py
@@ -20,12 +20,12 @@ import os
import pathlib
import re
import subprocess
-import typing
+import typing as T
from ... import mesonlib
from ... import mlog
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ...coredata import UserOption # noqa: F401
from ...environment import Environment
@@ -34,7 +34,7 @@ if typing.TYPE_CHECKING:
clike_debug_args = {
False: [],
True: ['-g'],
-} # type: typing.Dict[bool, typing.List[str]]
+} # type: T.Dict[bool, T.List[str]]
gnulike_buildtype_args = {
'plain': [],
@@ -43,7 +43,7 @@ gnulike_buildtype_args = {
'release': [],
'minsize': [],
'custom': [],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
gnu_optimization_args = {
'0': [],
@@ -52,7 +52,7 @@ gnu_optimization_args = {
'2': ['-O2'],
'3': ['-O3'],
's': ['-Os'],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
gnulike_instruction_set_args = {
'mmx': ['-mmmx'],
@@ -65,7 +65,7 @@ gnulike_instruction_set_args = {
'avx': ['-mavx'],
'avx2': ['-mavx2'],
'neon': ['-mfpu=neon'],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
gnu_symbol_visibility_args = {
'': [],
@@ -74,17 +74,17 @@ gnu_symbol_visibility_args = {
'hidden': ['-fvisibility=hidden'],
'protected': ['-fvisibility=protected'],
'inlineshidden': ['-fvisibility=hidden', '-fvisibility-inlines-hidden'],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
gnu_color_args = {
'auto': ['-fdiagnostics-color=auto'],
'always': ['-fdiagnostics-color=always'],
'never': ['-fdiagnostics-color=never'],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
@functools.lru_cache(maxsize=None)
-def gnulike_default_include_dirs(compiler: typing.Tuple[str], lang: str) -> typing.List[str]:
+def gnulike_default_include_dirs(compiler: T.Tuple[str], lang: str) -> T.List[str]:
lang_map = {
'c': 'c',
'cpp': 'c++',
@@ -149,45 +149,45 @@ class GnuLikeCompiler(metaclass=abc.ABCMeta):
# All GCC-like backends can do assembly
self.can_compile_suffixes.add('s')
- def get_pic_args(self) -> typing.List[str]:
+ def get_pic_args(self) -> T.List[str]:
if self.info.is_windows() or self.info.is_cygwin() or self.info.is_darwin():
return [] # On Window and OS X, pic is always on.
return ['-fPIC']
- def get_pie_args(self) -> typing.List[str]:
+ def get_pie_args(self) -> T.List[str]:
return ['-fPIE']
- def get_buildtype_args(self, buildtype: str) -> typing.List[str]:
+ def get_buildtype_args(self, buildtype: str) -> T.List[str]:
return gnulike_buildtype_args[buildtype]
@abc.abstractmethod
- def get_optimization_args(self, optimization_level: str) -> typing.List[str]:
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
raise NotImplementedError("get_optimization_args not implemented")
- def get_debug_args(self, is_debug: bool) -> typing.List[str]:
+ def get_debug_args(self, is_debug: bool) -> T.List[str]:
return clike_debug_args[is_debug]
@abc.abstractmethod
def get_pch_suffix(self) -> str:
raise NotImplementedError("get_pch_suffix not implemented")
- def split_shlib_to_parts(self, fname: str) -> typing.Tuple[str, str]:
+ def split_shlib_to_parts(self, fname: str) -> T.Tuple[str, str]:
return os.path.dirname(fname), fname
- def get_instruction_set_args(self, instruction_set: str) -> typing.Optional[typing.List[str]]:
+ def get_instruction_set_args(self, instruction_set: str) -> T.Optional[T.List[str]]:
return gnulike_instruction_set_args.get(instruction_set, None)
- def get_default_include_dirs(self) -> typing.List[str]:
+ def get_default_include_dirs(self) -> T.List[str]:
return gnulike_default_include_dirs(tuple(self.exelist), self.language)
@abc.abstractmethod
- def openmp_flags(self) -> typing.List[str]:
+ def openmp_flags(self) -> T.List[str]:
raise NotImplementedError("openmp_flags not implemented")
- def gnu_symbol_visibility_args(self, vistype: str) -> typing.List[str]:
+ def gnu_symbol_visibility_args(self, vistype: str) -> T.List[str]:
return gnu_symbol_visibility_args[vistype]
- def gen_vs_module_defs_args(self, defsfile: str) -> typing.List[str]:
+ def gen_vs_module_defs_args(self, defsfile: str) -> T.List[str]:
if not isinstance(defsfile, str):
raise RuntimeError('Module definitions file should be str')
# On Windows targets, .def files may be specified on the linker command
@@ -200,18 +200,18 @@ class GnuLikeCompiler(metaclass=abc.ABCMeta):
def get_argument_syntax(self) -> str:
return 'gcc'
- def get_profile_generate_args(self) -> typing.List[str]:
+ def get_profile_generate_args(self) -> T.List[str]:
return ['-fprofile-generate']
- def get_profile_use_args(self) -> typing.List[str]:
+ def get_profile_use_args(self) -> T.List[str]:
return ['-fprofile-use', '-fprofile-correction']
- def get_gui_app_args(self, value: bool) -> typing.List[str]:
+ def get_gui_app_args(self, value: bool) -> T.List[str]:
if self.info.is_windows() or self.info.is_cygwin():
return ['-mwindows' if value else '-mconsole']
return []
- def compute_parameters_with_absolute_paths(self, parameter_list: typing.List[str], build_dir: str) -> typing.List[str]:
+ def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str], build_dir: str) -> T.List[str]:
for idx, i in enumerate(parameter_list):
if i[:2] == '-I' or i[:2] == '-L':
parameter_list[idx] = i[:2] + os.path.normpath(os.path.join(build_dir, i[2:]))
@@ -228,7 +228,7 @@ class GnuLikeCompiler(metaclass=abc.ABCMeta):
stdo = p.stdo
return stdo
- def _split_fetch_real_dirs(self, pathstr: str) -> typing.List[str]:
+ def _split_fetch_real_dirs(self, pathstr: str) -> T.List[str]:
# We need to use the path separator used by the compiler for printing
# lists of paths ("gcc --print-search-dirs"). By default
# we assume it uses the platform native separator.
@@ -265,7 +265,7 @@ class GnuLikeCompiler(metaclass=abc.ABCMeta):
pass
return result
- def get_compiler_dirs(self, env: 'Environment', name: str) -> typing.List[str]:
+ def get_compiler_dirs(self, env: 'Environment', name: str) -> T.List[str]:
'''
Get dirs from the compiler, either `libraries:` or `programs:`
'''
@@ -275,10 +275,10 @@ class GnuLikeCompiler(metaclass=abc.ABCMeta):
return self._split_fetch_real_dirs(line.split('=', 1)[1])
return []
- def get_lto_compile_args(self) -> typing.List[str]:
+ def get_lto_compile_args(self) -> T.List[str]:
return ['-flto']
- def sanitizer_compile_args(self, value: str) -> typing.List[str]:
+ def sanitizer_compile_args(self, value: str) -> T.List[str]:
if value == 'none':
return []
args = ['-fsanitize=' + value]
@@ -286,16 +286,16 @@ class GnuLikeCompiler(metaclass=abc.ABCMeta):
args.append('-fno-omit-frame-pointer')
return args
- def get_output_args(self, target: str) -> typing.List[str]:
+ def get_output_args(self, target: str) -> T.List[str]:
return ['-o', target]
def get_dependency_gen_args(self, outtarget, outfile):
return ['-MD', '-MQ', outtarget, '-MF', outfile]
- def get_compile_only_args(self) -> typing.List[str]:
+ def get_compile_only_args(self) -> T.List[str]:
return ['-c']
- def get_include_args(self, path: str, is_system: bool) -> typing.List[str]:
+ def get_include_args(self, path: str, is_system: bool) -> T.List[str]:
if not path:
path = '.'
if is_system:
@@ -303,7 +303,7 @@ class GnuLikeCompiler(metaclass=abc.ABCMeta):
return ['-I' + path]
@classmethod
- def use_linker_args(cls, linker: str) -> typing.List[str]:
+ def use_linker_args(cls, linker: str) -> T.List[str]:
return ['-fuse-ld={}'.format(linker)]
@@ -313,18 +313,18 @@ class GnuCompiler(GnuLikeCompiler):
Compilers imitating GCC (Clang/Intel) should use the GnuLikeCompiler ABC.
"""
- def __init__(self, defines: typing.Dict[str, str]):
+ def __init__(self, defines: T.Dict[str, str]):
super().__init__()
self.id = 'gcc'
self.defines = defines or {}
self.base_options.append('b_colorout')
- def get_colorout_args(self, colortype: str) -> typing.List[str]:
+ def get_colorout_args(self, colortype: str) -> T.List[str]:
if mesonlib.version_compare(self.version, '>=4.9.0'):
return gnu_color_args[colortype][:]
return []
- def get_warn_args(self, level: str) -> typing.List[str]:
+ def get_warn_args(self, level: str) -> T.List[str]:
args = super().get_warn_args(level)
if mesonlib.version_compare(self.version, '<4.8.0') and '-Wpedantic' in args:
# -Wpedantic was added in 4.8.0
@@ -335,18 +335,18 @@ class GnuCompiler(GnuLikeCompiler):
def has_builtin_define(self, define: str) -> bool:
return define in self.defines
- def get_builtin_define(self, define: str) -> typing.Optional[str]:
+ def get_builtin_define(self, define: str) -> T.Optional[str]:
if define in self.defines:
return self.defines[define]
return None
- def get_optimization_args(self, optimization_level: str) -> typing.List[str]:
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return gnu_optimization_args[optimization_level]
def get_pch_suffix(self) -> str:
return 'gch'
- def openmp_flags(self) -> typing.List[str]:
+ def openmp_flags(self) -> T.List[str]:
return ['-fopenmp']
def has_arguments(self, args, env, code, mode):