aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2020-01-06 15:27:38 +0100
committerDaniel Mensinger <daniel@mensinger-ka.de>2020-01-08 15:28:17 +0100
commit09b53c534f74806ebc49bb2fcdfbae0e3b26fb84 (patch)
tree4466a6005333d6d1ae7d67cbaf24fb63e104df6a /mesonbuild/compilers
parentf3199edaf8802e2a59fed2f83e825e09b9d4bd0d (diff)
downloadmeson-09b53c534f74806ebc49bb2fcdfbae0e3b26fb84.zip
meson-09b53c534f74806ebc49bb2fcdfbae0e3b26fb84.tar.gz
meson-09b53c534f74806ebc49bb2fcdfbae0e3b26fb84.tar.bz2
types: import typing as T (fixes #6333)
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/c.py6
-rw-r--r--mesonbuild/compilers/compilers.py138
-rw-r--r--mesonbuild/compilers/cpp.py8
-rw-r--r--mesonbuild/compilers/cs.py4
-rw-r--r--mesonbuild/compilers/cuda.py16
-rw-r--r--mesonbuild/compilers/d.py10
-rw-r--r--mesonbuild/compilers/fortran.py18
-rw-r--r--mesonbuild/compilers/java.py4
-rw-r--r--mesonbuild/compilers/mixins/arm.py50
-rw-r--r--mesonbuild/compilers/mixins/ccrx.py32
-rw-r--r--mesonbuild/compilers/mixins/clang.py20
-rw-r--r--mesonbuild/compilers/mixins/clike.py28
-rw-r--r--mesonbuild/compilers/mixins/elbrus.py12
-rw-r--r--mesonbuild/compilers/mixins/emscripten.py6
-rw-r--r--mesonbuild/compilers/mixins/gnu.py76
-rw-r--r--mesonbuild/compilers/mixins/intel.py32
-rw-r--r--mesonbuild/compilers/mixins/islinker.py52
-rw-r--r--mesonbuild/compilers/mixins/pgi.py28
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py82
-rw-r--r--mesonbuild/compilers/objc.py6
-rw-r--r--mesonbuild/compilers/objcpp.py6
-rw-r--r--mesonbuild/compilers/rust.py4
-rw-r--r--mesonbuild/compilers/swift.py4
-rw-r--r--mesonbuild/compilers/vala.py4
24 files changed, 323 insertions, 323 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 8a15609..d9d81d6 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -13,7 +13,7 @@
# limitations under the License.
import os.path
-import typing
+import typing as T
from .. import coredata
from ..mesonlib import MachineChoice, MesonException, mlog, version_compare
@@ -35,7 +35,7 @@ from .compilers import (
Compiler,
)
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
@@ -51,7 +51,7 @@ class CCompiler(CLikeCompiler, Compiler):
language = 'c'
def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool,
- info: 'MachineInfo', exe_wrapper: typing.Optional[str] = None, **kwargs):
+ info: 'MachineInfo', exe_wrapper: T.Optional[str] = None, **kwargs):
# If a child ObjC or CPP class has already set it, don't set it ourselves
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrapper)
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index d54f7da..ec2b24b 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -14,7 +14,7 @@
import contextlib, os.path, re, tempfile
import collections.abc
-import typing
+import typing as T
from ..linkers import StaticLinker, GnuLikeDynamicLinkerMixin, SolarisDynamicLinker
from .. import coredata
@@ -28,7 +28,7 @@ from ..envconfig import (
Properties,
)
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..coredata import OptionDictType
from ..envconfig import MachineInfo
from ..environment import Environment
@@ -386,7 +386,7 @@ class RunResult:
self.stdout = stdout
self.stderr = stderr
-class CompilerArgs(typing.MutableSequence[str]):
+class CompilerArgs(T.MutableSequence[str]):
'''
List-like class that manages a list of compiler arguments. Should be used
while constructing compiler arguments from various sources. Can be
@@ -441,34 +441,34 @@ class CompilerArgs(typing.MutableSequence[str]):
# *always* de-dup these because they're special arguments to the linker
always_dedup_args = tuple('-l' + lib for lib in unixy_compiler_internal_libs)
- def __init__(self, compiler: typing.Union['Compiler', StaticLinker],
- iterable: typing.Optional[typing.Iterable[str]] = None):
+ def __init__(self, compiler: T.Union['Compiler', StaticLinker],
+ iterable: T.Optional[T.Iterable[str]] = None):
self.compiler = compiler
- self.__container = list(iterable) if iterable is not None else [] # type: typing.List[str]
+ self.__container = list(iterable) if iterable is not None else [] # type: T.List[str]
- @typing.overload
+ @T.overload
def __getitem__(self, index: int) -> str:
pass
- @typing.overload
- def __getitem__(self, index: slice) -> typing.List[str]:
+ @T.overload
+ def __getitem__(self, index: slice) -> T.List[str]:
pass
def __getitem__(self, index):
return self.__container[index]
- @typing.overload
+ @T.overload
def __setitem__(self, index: int, value: str) -> None:
pass
- @typing.overload
- def __setitem__(self, index: slice, value: typing.List[str]) -> None:
+ @T.overload
+ def __setitem__(self, index: slice, value: T.List[str]) -> None:
pass
def __setitem__(self, index, value) -> None:
self.__container[index] = value
- def __delitem__(self, index: typing.Union[int, slice]) -> None:
+ def __delitem__(self, index: T.Union[int, slice]) -> None:
del self.__container[index]
def __len__(self) -> int:
@@ -531,7 +531,7 @@ class CompilerArgs(typing.MutableSequence[str]):
return True
return False
- def to_native(self, copy: bool = False) -> typing.List[str]:
+ def to_native(self, copy: bool = False) -> T.List[str]:
# Check if we need to add --start/end-group for circular dependencies
# between static libraries, and for recursively searching for symbols
# needed by static libraries that are provided by object files or
@@ -563,7 +563,7 @@ class CompilerArgs(typing.MutableSequence[str]):
# Remove system/default include paths added with -isystem
if hasattr(self.compiler, 'get_default_include_dirs'):
default_dirs = self.compiler.get_default_include_dirs()
- bad_idx_list = [] # type: typing.List[int]
+ bad_idx_list = [] # type: T.List[int]
for i, each in enumerate(new):
# Remove the -isystem and the path if the path is a default path
if (each == '-isystem' and
@@ -589,7 +589,7 @@ class CompilerArgs(typing.MutableSequence[str]):
else:
self.__container.append(arg)
- def extend_direct(self, iterable: typing.Iterable[str]) -> None:
+ def extend_direct(self, iterable: T.Iterable[str]) -> None:
'''
Extend using the elements in the specified iterable without any
reordering or de-dup except for absolute paths where the order of
@@ -598,7 +598,7 @@ class CompilerArgs(typing.MutableSequence[str]):
for elem in iterable:
self.append_direct(elem)
- def extend_preserving_lflags(self, iterable: typing.Iterable[str]) -> None:
+ def extend_preserving_lflags(self, iterable: T.Iterable[str]) -> None:
normal_flags = []
lflags = []
for i in iterable:
@@ -609,18 +609,18 @@ class CompilerArgs(typing.MutableSequence[str]):
self.extend(normal_flags)
self.extend_direct(lflags)
- def __add__(self, args: typing.Iterable[str]) -> 'CompilerArgs':
+ def __add__(self, args: T.Iterable[str]) -> 'CompilerArgs':
new = self.copy()
new += args
return new
- def __iadd__(self, args: typing.Iterable[str]) -> 'CompilerArgs':
+ def __iadd__(self, args: T.Iterable[str]) -> 'CompilerArgs':
'''
Add two CompilerArgs while taking into account overriding of arguments
and while preserving the order of arguments as much as possible
'''
- pre = [] # type: typing.List[str]
- post = [] # type: typing.List[str]
+ pre = [] # type: T.List[str]
+ post = [] # type: T.List[str]
if not isinstance(args, collections.abc.Iterable):
raise TypeError('can only concatenate Iterable[str] (not "{}") to CompilerArgs'.format(args))
for arg in args:
@@ -650,12 +650,12 @@ class CompilerArgs(typing.MutableSequence[str]):
self.__container += post
return self
- def __radd__(self, args: typing.Iterable[str]):
+ def __radd__(self, args: T.Iterable[str]):
new = CompilerArgs(self.compiler, args)
new += self
return new
- def __eq__(self, other: typing.Any) -> typing.Union[bool, 'NotImplemented']:
+ def __eq__(self, other: T.Any) -> T.Union[bool, 'NotImplemented']:
# Only allow equality checks against other CompilerArgs and lists instances
if isinstance(other, CompilerArgs):
return self.compiler == other.compiler and self.__container == other.__container
@@ -666,7 +666,7 @@ class CompilerArgs(typing.MutableSequence[str]):
def append(self, arg: str) -> None:
self.__iadd__([arg])
- def extend(self, args: typing.Iterable[str]) -> None:
+ def extend(self, args: T.Iterable[str]) -> None:
self.__iadd__(args)
def __repr__(self) -> str:
@@ -680,11 +680,11 @@ class Compiler:
# manually searched.
internal_libs = ()
- LINKER_PREFIX = None # type: typing.Union[None, str, typing.List[str]]
+ LINKER_PREFIX = None # type: T.Union[None, str, T.List[str]]
INVOKES_LINKER = True
def __init__(self, exelist, version, for_machine: MachineChoice, info: 'MachineInfo',
- linker: typing.Optional['DynamicLinker'] = None, **kwargs):
+ linker: T.Optional['DynamicLinker'] = None, **kwargs):
if isinstance(exelist, str):
self.exelist = [exelist]
elif isinstance(exelist, list):
@@ -742,7 +742,7 @@ class Compiler:
def get_default_suffix(self) -> str:
return self.default_suffix
- def get_define(self, dname, prefix, env, extra_args, dependencies) -> typing.Tuple[str, bool]:
+ def get_define(self, dname, prefix, env, extra_args, dependencies) -> T.Tuple[str, bool]:
raise EnvironmentException('%s does not support get_define ' % self.get_id())
def compute_int(self, expression, low, high, guess, prefix, env, extra_args, dependencies) -> int:
@@ -752,11 +752,11 @@ class Compiler:
raise EnvironmentException('%s does not support compute_parameters_with_absolute_paths ' % self.get_id())
def has_members(self, typename, membernames, prefix, env, *,
- extra_args=None, dependencies=None) -> typing.Tuple[bool, bool]:
+ extra_args=None, dependencies=None) -> T.Tuple[bool, bool]:
raise EnvironmentException('%s does not support has_member(s) ' % self.get_id())
def has_type(self, typename, prefix, env, extra_args, *,
- dependencies=None) -> typing.Tuple[bool, bool]:
+ dependencies=None) -> T.Tuple[bool, bool]:
raise EnvironmentException('%s does not support has_type ' % self.get_id())
def symbols_have_underscore_prefix(self, env) -> bool:
@@ -765,10 +765,10 @@ class Compiler:
def get_exelist(self):
return self.exelist[:]
- def get_linker_exelist(self) -> typing.List[str]:
+ def get_linker_exelist(self) -> T.List[str]:
return self.linker.get_exelist()
- def get_linker_output_args(self, outputname: str) -> typing.List[str]:
+ def get_linker_output_args(self, outputname: str) -> T.List[str]:
return self.linker.get_output_args(outputname)
def get_builtin_define(self, *args, **kwargs):
@@ -799,31 +799,31 @@ class Compiler:
"""
return []
- def get_linker_args_from_envvars(self) -> typing.List[str]:
+ def get_linker_args_from_envvars(self) -> T.List[str]:
return self.linker.get_args_from_envvars()
- def get_options(self) -> typing.Dict[str, coredata.UserOption]:
+ def get_options(self) -> T.Dict[str, coredata.UserOption]:
return {}
def get_option_compile_args(self, options):
return []
- def get_option_link_args(self, options: 'OptionDictType') -> typing.List[str]:
+ def get_option_link_args(self, options: 'OptionDictType') -> T.List[str]:
return self.linker.get_option_args(options)
- def check_header(self, *args, **kwargs) -> typing.Tuple[bool, bool]:
+ def check_header(self, *args, **kwargs) -> T.Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support header checks.' % self.get_display_language())
- def has_header(self, *args, **kwargs) -> typing.Tuple[bool, bool]:
+ def has_header(self, *args, **kwargs) -> T.Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support header checks.' % self.get_display_language())
- def has_header_symbol(self, *args, **kwargs) -> typing.Tuple[bool, bool]:
+ def has_header_symbol(self, *args, **kwargs) -> T.Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support header symbol checks.' % self.get_display_language())
- def compiles(self, *args, **kwargs) -> typing.Tuple[bool, bool]:
+ def compiles(self, *args, **kwargs) -> T.Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support compile checks.' % self.get_display_language())
- def links(self, *args, **kwargs) -> typing.Tuple[bool, bool]:
+ def links(self, *args, **kwargs) -> T.Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support link checks.' % self.get_display_language())
def run(self, *args, **kwargs) -> RunResult:
@@ -835,7 +835,7 @@ class Compiler:
def alignment(self, *args, **kwargs) -> int:
raise EnvironmentException('Language %s does not support alignment checks.' % self.get_display_language())
- def has_function(self, *args, **kwargs) -> typing.Tuple[bool, bool]:
+ def has_function(self, *args, **kwargs) -> T.Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support function checks.' % self.get_display_language())
@classmethod
@@ -844,7 +844,7 @@ class Compiler:
return args[:]
@classmethod
- def native_args_to_unix(cls, args: typing.List[str]) -> typing.List[str]:
+ def native_args_to_unix(cls, args: T.List[str]) -> T.List[str]:
"Always returns a copy that can be independently mutated"
return args[:]
@@ -857,12 +857,12 @@ class Compiler:
def get_program_dirs(self, *args, **kwargs):
return []
- def has_multi_arguments(self, args, env) -> typing.Tuple[bool, bool]:
+ def has_multi_arguments(self, args, env) -> T.Tuple[bool, bool]:
raise EnvironmentException(
'Language {} does not support has_multi_arguments.'.format(
self.get_display_language()))
- def has_multi_link_arguments(self, args: typing.List[str], env: 'Environment') -> typing.Tuple[bool, bool]:
+ def has_multi_link_arguments(self, args: T.List[str], env: 'Environment') -> T.Tuple[bool, bool]:
return self.linker.has_multi_arguments(args, env)
def _get_compile_output(self, dirname, mode):
@@ -976,22 +976,22 @@ class Compiler:
def get_compile_debugfile_args(self, rel_obj, **kwargs):
return []
- def get_link_debugfile_args(self, targetfile: str) -> typing.List[str]:
+ def get_link_debugfile_args(self, targetfile: str) -> T.List[str]:
return self.linker.get_debugfile_args(targetfile)
- def get_std_shared_lib_link_args(self) -> typing.List[str]:
+ def get_std_shared_lib_link_args(self) -> T.List[str]:
return self.linker.get_std_shared_lib_args()
- def get_std_shared_module_link_args(self, options: 'OptionDictType') -> typing.List[str]:
+ def get_std_shared_module_link_args(self, options: 'OptionDictType') -> T.List[str]:
return self.linker.get_std_shared_module_args(options)
- def get_link_whole_for(self, args: typing.List[str]) -> typing.List[str]:
+ def get_link_whole_for(self, args: T.List[str]) -> T.List[str]:
return self.linker.get_link_whole_for(args)
- def get_allow_undefined_link_args(self) -> typing.List[str]:
+ def get_allow_undefined_link_args(self) -> T.List[str]:
return self.linker.get_allow_undefined_args()
- def no_undefined_link_args(self) -> typing.List[str]:
+ def no_undefined_link_args(self) -> T.List[str]:
return self.linker.no_undefined_args()
# Compiler arguments needed to enable the given instruction set.
@@ -1002,7 +1002,7 @@ class Compiler:
def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
rpath_paths: str, build_rpath: str,
- install_rpath: str) -> typing.List[str]:
+ install_rpath: str) -> T.List[str]:
return self.linker.build_rpath_args(
env, build_dir, from_dir, rpath_paths, build_rpath, install_rpath)
@@ -1033,7 +1033,7 @@ class Compiler:
m = 'Language {} does not support position-independent executable'
raise EnvironmentException(m.format(self.get_display_language()))
- def get_pie_link_args(self) -> typing.List[str]:
+ def get_pie_link_args(self) -> T.List[str]:
return self.linker.get_pie_args()
def get_argument_syntax(self):
@@ -1055,40 +1055,40 @@ class Compiler:
raise EnvironmentException(
'%s does not support get_profile_use_args ' % self.get_id())
- def get_undefined_link_args(self) -> typing.List[str]:
+ def get_undefined_link_args(self) -> T.List[str]:
return self.linker.get_undefined_link_args()
def remove_linkerlike_args(self, args):
return [x for x in args if not x.startswith('-Wl')]
- def get_lto_compile_args(self) -> typing.List[str]:
+ def get_lto_compile_args(self) -> T.List[str]:
return []
- def get_lto_link_args(self) -> typing.List[str]:
+ def get_lto_link_args(self) -> T.List[str]:
return self.linker.get_lto_args()
- def sanitizer_compile_args(self, value: str) -> typing.List[str]:
+ def sanitizer_compile_args(self, value: str) -> T.List[str]:
return []
- def sanitizer_link_args(self, value: str) -> typing.List[str]:
+ def sanitizer_link_args(self, value: str) -> T.List[str]:
return self.linker.sanitizer_args(value)
- def get_asneeded_args(self) -> typing.List[str]:
+ def get_asneeded_args(self) -> T.List[str]:
return self.linker.get_asneeded_args()
- def bitcode_args(self) -> typing.List[str]:
+ def bitcode_args(self) -> T.List[str]:
return self.linker.bitcode_args()
- def get_linker_debug_crt_args(self) -> typing.List[str]:
+ def get_linker_debug_crt_args(self) -> T.List[str]:
return self.linker.get_debug_crt_args()
- def get_buildtype_linker_args(self, buildtype: str) -> typing.List[str]:
+ def get_buildtype_linker_args(self, buildtype: str) -> T.List[str]:
return self.linker.get_buildtype_args(buildtype)
def get_soname_args(self, env: 'Environment', prefix: str, shlib_name: str,
suffix: str, soversion: str,
- darwin_versions: typing.Tuple[str, str],
- is_shared_module: bool) -> typing.List[str]:
+ darwin_versions: T.Tuple[str, str],
+ is_shared_module: bool) -> T.List[str]:
return self.linker.get_soname_args(
env, prefix, shlib_name, suffix, soversion,
darwin_versions, is_shared_module)
@@ -1103,7 +1103,7 @@ class Compiler:
return dep.get_link_args()
@classmethod
- def use_linker_args(cls, linker: str) -> typing.List[str]:
+ def use_linker_args(cls, linker: str) -> T.List[str]:
"""Get a list of arguments to pass to the compiler to set the linker.
"""
return []
@@ -1131,12 +1131,12 @@ def get_largefile_args(compiler):
return []
-def get_args_from_envvars(lang: str, use_linker_args: bool) -> typing.Tuple[typing.List[str], typing.List[str]]:
+def get_args_from_envvars(lang: str, use_linker_args: bool) -> T.Tuple[T.List[str], T.List[str]]:
"""
Returns a tuple of (compile_flags, link_flags) for the specified language
from the inherited environment
"""
- def log_var(var, val: typing.Optional[str]):
+ def log_var(var, val: T.Optional[str]):
if val:
mlog.log('Appending {} from environment: {!r}'.format(var, val))
else:
@@ -1145,8 +1145,8 @@ def get_args_from_envvars(lang: str, use_linker_args: bool) -> typing.Tuple[typi
if lang not in cflags_mapping:
return [], []
- compile_flags = [] # type: typing.List[str]
- link_flags = [] # type: typing.List[str]
+ compile_flags = [] # type: T.List[str]
+ link_flags = [] # type: T.List[str]
env_compile_flags = os.environ.get(cflags_mapping[lang])
log_var(cflags_mapping[lang], env_compile_flags)
@@ -1179,8 +1179,8 @@ def get_args_from_envvars(lang: str, use_linker_args: bool) -> typing.Tuple[typi
return compile_flags, link_flags
-def get_global_options(lang: str, comp: typing.Type[Compiler],
- properties: Properties) -> typing.Dict[str, coredata.UserOption]:
+def get_global_options(lang: str, comp: T.Type[Compiler],
+ properties: Properties) -> T.Dict[str, coredata.UserOption]:
"""Retreive options that apply to all compilers for a given language."""
description = 'Extra arguments passed to the {}'.format(lang)
opts = {
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index f8ded00..a09c611 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -15,7 +15,7 @@
import copy
import functools
import os.path
-import typing
+import typing as T
from .. import coredata
from .. import mlog
@@ -39,7 +39,7 @@ from .mixins.pgi import PGICompiler
from .mixins.islinker import BasicLinkerIsCompilerMixin, LinkerEnvVarsMixin
from .mixins.emscripten import EmscriptenMixin
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
@@ -62,7 +62,7 @@ class CPPCompiler(CLikeCompiler, Compiler):
language = 'cpp'
def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool,
- info: 'MachineInfo', exe_wrap: typing.Optional[str] = None, **kwargs):
+ info: 'MachineInfo', exe_wrap: T.Optional[str] = None, **kwargs):
# If a child ObjCPP class has already set it, don't set it ourselves
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrap)
@@ -431,7 +431,7 @@ class VisualStudioLikeCPPCompilerMixin:
def get_option_link_args(self, options):
return options['cpp_winlibs'].value[:]
- def _get_options_impl(self, opts, cpp_stds: typing.List[str]):
+ def _get_options_impl(self, opts, cpp_stds: T.List[str]):
opts.update({'cpp_eh': coredata.UserComboOption('C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default'),
diff --git a/mesonbuild/compilers/cs.py b/mesonbuild/compilers/cs.py
index d064e7c..843348e 100644
--- a/mesonbuild/compilers/cs.py
+++ b/mesonbuild/compilers/cs.py
@@ -13,14 +13,14 @@
# limitations under the License.
import os.path, subprocess
-import typing
+import typing as T
from ..mesonlib import EnvironmentException
from .compilers import Compiler, MachineChoice, mono_buildtype_args
from .mixins.islinker import BasicLinkerIsCompilerMixin
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
cs_optimization_args = {'0': [],
diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py
index 385e4cf..e839f53 100644
--- a/mesonbuild/compilers/cuda.py
+++ b/mesonbuild/compilers/cuda.py
@@ -13,7 +13,7 @@
# limitations under the License.
import os.path
-import typing
+import typing as T
from functools import partial
from .. import coredata
@@ -22,7 +22,7 @@ from ..mesonlib import EnvironmentException, MachineChoice, Popen_safe, OptionOv
from .compilers import (Compiler, cuda_buildtype_args, cuda_optimization_args,
cuda_debug_args)
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..environment import Environment # noqa: F401
from ..envconfig import MachineInfo
@@ -197,9 +197,9 @@ class CudaCompiler(Compiler):
return args + self._to_host_flags(self.host_compiler.get_option_compile_args(self._to_host_compiler_options(options)))
@classmethod
- def _cook_link_args(cls, args: typing.List[str]) -> typing.List[str]:
+ def _cook_link_args(cls, args: T.List[str]) -> T.List[str]:
# Prepare link args for nvcc
- cooked = [] # type: typing.List[str]
+ cooked = [] # type: T.List[str]
for arg in args:
if arg.startswith('-Wl,'): # strip GNU-style -Wl prefix
arg = arg.replace('-Wl,', '', 1)
@@ -263,7 +263,7 @@ class CudaCompiler(Compiler):
def get_depfile_suffix(self):
return 'd'
- def get_linker_debug_crt_args(self) -> typing.List[str]:
+ def get_linker_debug_crt_args(self) -> T.List[str]:
return self._cook_link_args(self.host_compiler.get_linker_debug_crt_args())
def get_buildtype_linker_args(self, buildtype):
@@ -271,7 +271,7 @@ class CudaCompiler(Compiler):
def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
rpath_paths: str, build_rpath: str,
- install_rpath: str) -> typing.List[str]:
+ install_rpath: str) -> T.List[str]:
return self._cook_link_args(self.host_compiler.build_rpath_args(
env, build_dir, from_dir, rpath_paths, build_rpath, install_rpath))
@@ -284,10 +284,10 @@ class CudaCompiler(Compiler):
def compute_parameters_with_absolute_paths(self, parameter_list, build_dir):
return []
- 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_std_exe_link_args(self) -> typing.List[str]:
+ def get_std_exe_link_args(self) -> T.List[str]:
return self._cook_link_args(self.host_compiler.get_std_exe_link_args())
def find_library(self, libname, env, extra_dirs, libtype: LibType = LibType.PREFER_SHARED):
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index 15770a5..b974504 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -13,7 +13,7 @@
# limitations under the License.
import os.path, subprocess
-import typing
+import typing as T
from ..mesonlib import (
EnvironmentException, MachineChoice, version_compare,
@@ -30,7 +30,7 @@ from .compilers import (
from .mixins.gnu import GnuCompiler
from .mixins.islinker import LinkerEnvVarsMixin, BasicLinkerIsCompilerMixin
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
d_feature_args = {'gcc': {'unittest': '-funittest',
@@ -388,7 +388,7 @@ class DmdLikeCompilerMixin:
assert(buildtype == 'custom')
raise EnvironmentException('Requested C runtime based on buildtype, but buildtype is "custom".')
- def get_soname_args(self, *args, **kwargs) -> typing.List[str]:
+ def get_soname_args(self, *args, **kwargs) -> T.List[str]:
# LDC and DMD actually do use a linker, but they proxy all of that with
# their own arguments
soargs = []
@@ -396,7 +396,7 @@ class DmdLikeCompilerMixin:
soargs.append('-L=' + arg)
return soargs
- def get_allow_undefined_link_args(self) -> typing.List[str]:
+ def get_allow_undefined_link_args(self) -> T.List[str]:
args = []
for arg in self.linker.get_allow_undefined_args():
args.append('-L=' + arg)
@@ -654,7 +654,7 @@ class GnuDCompiler(DCompiler, GnuCompiler):
return parameter_list
- def get_allow_undefined_link_args(self) -> typing.List[str]:
+ def get_allow_undefined_link_args(self) -> T.List[str]:
return self.linker.get_allow_undefined_args()
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index 4aff72e..73a8e24 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -13,7 +13,7 @@
# limitations under the License.
from pathlib import Path
-from typing import TYPE_CHECKING, List
+import typing as T
import subprocess, os
from .. import coredata
@@ -35,7 +35,7 @@ from mesonbuild.mesonlib import (
version_compare, EnvironmentException, MesonException, MachineChoice, LibType
)
-if TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
@@ -189,7 +189,7 @@ class GnuFortranCompiler(GnuCompiler, FortranCompiler):
'none')})
return opts
- def get_option_compile_args(self, options) -> List[str]:
+ def get_option_compile_args(self, options) -> T.List[str]:
args = []
std = options['fortran_std']
if std.value != 'none':
@@ -295,7 +295,7 @@ class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler):
'none')})
return opts
- def get_option_compile_args(self, options) -> List[str]:
+ def get_option_compile_args(self, options) -> T.List[str]:
args = []
std = options['fortran_std']
stds = {'legacy': 'none', 'f95': 'f95', 'f2003': 'f03', 'f2008': 'f08', 'f2018': 'f18'}
@@ -315,7 +315,7 @@ class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler):
def language_stdlib_only_link_flags(self):
return ['-lifcore', '-limf']
- def get_dependency_gen_args(self, outtarget: str, outfile: str) -> List[str]:
+ def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
return ['-gen-dep=' + outtarget, '-gen-depformat=make']
@@ -345,7 +345,7 @@ class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler):
'none')})
return opts
- def get_option_compile_args(self, options) -> List[str]:
+ def get_option_compile_args(self, options) -> T.List[str]:
args = []
std = options['fortran_std']
stds = {'legacy': 'none', 'f95': 'f95', 'f2003': 'f03', 'f2008': 'f08', 'f2018': 'f18'}
@@ -353,7 +353,7 @@ class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler):
args.append('/stand:' + stds[std.value])
return args
- def get_module_outdir_args(self, path) -> List[str]:
+ def get_module_outdir_args(self, path) -> T.List[str]:
return ['/module:' + path]
@@ -388,7 +388,7 @@ class PGIFortranCompiler(PGICompiler, FortranCompiler):
'2': default_warn_args,
'3': default_warn_args + ['-Mdclchk']}
- def language_stdlib_only_link_flags(self) -> List[str]:
+ def language_stdlib_only_link_flags(self) -> T.List[str]:
return ['-lpgf90rtl', '-lpgf90', '-lpgf90_rpm1', '-lpgf902',
'-lpgf90rtl', '-lpgftnrtl', '-lrt']
@@ -406,7 +406,7 @@ class FlangFortranCompiler(ClangCompiler, FortranCompiler):
'2': default_warn_args,
'3': default_warn_args}
- def language_stdlib_only_link_flags(self) -> List[str]:
+ def language_stdlib_only_link_flags(self) -> T.List[str]:
return ['-lflang', '-lpgmath']
class Open64FortranCompiler(FortranCompiler):
diff --git a/mesonbuild/compilers/java.py b/mesonbuild/compilers/java.py
index bb62fb2..5aeb250 100644
--- a/mesonbuild/compilers/java.py
+++ b/mesonbuild/compilers/java.py
@@ -15,13 +15,13 @@
import os.path
import shutil
import subprocess
-import typing
+import typing as T
from ..mesonlib import EnvironmentException, MachineChoice
from .compilers import Compiler, java_buildtype_args
from .mixins.islinker import BasicLinkerIsCompilerMixin
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
class JavaCompiler(BasicLinkerIsCompilerMixin, Compiler):
diff --git a/mesonbuild/compilers/mixins/arm.py b/mesonbuild/compilers/mixins/arm.py
index 28708d5..d15faec 100644
--- a/mesonbuild/compilers/mixins/arm.py
+++ b/mesonbuild/compilers/mixins/arm.py
@@ -16,13 +16,13 @@
import os
import re
-import typing
+import typing as T
from ... import mesonlib
from ..compilers import clike_debug_args
from .clang import clang_color_args
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ...environment import Environment
arm_buildtype_args = {
@@ -32,7 +32,7 @@ arm_buildtype_args = {
'release': ['-O3', '-Otime'],
'minsize': ['-O3', '-Ospace'],
'custom': [],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
arm_optimization_args = {
'0': ['-O0'],
@@ -41,7 +41,7 @@ arm_optimization_args = {
'2': ['-O2'],
'3': ['-O3'],
's': [],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
armclang_buildtype_args = {
'plain': [],
@@ -50,7 +50,7 @@ armclang_buildtype_args = {
'release': ['-Os'],
'minsize': ['-Oz'],
'custom': [],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
armclang_optimization_args = {
'0': ['-O0'],
@@ -59,7 +59,7 @@ armclang_optimization_args = {
'2': ['-O2'],
'3': ['-O3'],
's': ['-Os']
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
class ArmCompiler:
@@ -68,7 +68,7 @@ class ArmCompiler:
if not self.is_cross:
raise mesonlib.EnvironmentException('armcc supports only cross-compilation.')
self.id = 'arm'
- default_warn_args = [] # type: typing.List[str]
+ default_warn_args = [] # type: T.List[str]
self.warn_args = {'0': [],
'1': default_warn_args,
'2': default_warn_args + [],
@@ -76,22 +76,22 @@ class ArmCompiler:
# Assembly
self.can_compile_suffixes.add('s')
- def get_pic_args(self) -> typing.List[str]:
+ def get_pic_args(self) -> T.List[str]:
# FIXME: Add /ropi, /rwpi, /fpic etc. qualifiers to --apcs
return []
- def get_buildtype_args(self, buildtype: str) -> typing.List[str]:
+ def get_buildtype_args(self, buildtype: str) -> T.List[str]:
return arm_buildtype_args[buildtype]
# Override CCompiler.get_always_args
- def get_always_args(self) -> typing.List[str]:
+ def get_always_args(self) -> T.List[str]:
return []
# Override CCompiler.get_dependency_gen_args
- def get_dependency_gen_args(self, outtarget: str, outfile: str) -> typing.List[str]:
+ def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
return []
- def get_pch_use_args(self, pch_dir: str, header: str) -> typing.List[str]:
+ def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
# FIXME: Add required arguments
# NOTE from armcc user guide:
# "Support for Precompiled Header (PCH) files is deprecated from ARM Compiler 5.05
@@ -106,19 +106,19 @@ class ArmCompiler:
# PCH files."
return 'pch'
- def thread_flags(self, env: 'Environment') -> typing.List[str]:
+ def thread_flags(self, env: 'Environment') -> T.List[str]:
return []
- def get_coverage_args(self) -> typing.List[str]:
+ def get_coverage_args(self) -> T.List[str]:
return []
- def get_optimization_args(self, optimization_level: str) -> typing.List[str]:
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return arm_optimization_args[optimization_level]
- 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]
- 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:]))
@@ -159,37 +159,37 @@ class ArmclangCompiler:
# Assembly
self.can_compile_suffixes.update('s')
- def get_pic_args(self) -> typing.List[str]:
+ def get_pic_args(self) -> T.List[str]:
# PIC support is not enabled by default for ARM,
# if users want to use it, they need to add the required arguments explicitly
return []
- def get_colorout_args(self, colortype: str) -> typing.List[str]:
+ def get_colorout_args(self, colortype: str) -> T.List[str]:
return clang_color_args[colortype][:]
- def get_buildtype_args(self, buildtype: str) -> typing.List[str]:
+ def get_buildtype_args(self, buildtype: str) -> T.List[str]:
return armclang_buildtype_args[buildtype]
def get_pch_suffix(self) -> str:
return 'gch'
- def get_pch_use_args(self, pch_dir: str, header: str) -> typing.List[str]:
+ def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
# Workaround for Clang bug http://llvm.org/bugs/show_bug.cgi?id=15136
# This flag is internal to Clang (or at least not documented on the man page)
# so it might change semantics at any time.
return ['-include-pch', os.path.join(pch_dir, self.get_pch_name(header))]
# Override CCompiler.get_dependency_gen_args
- def get_dependency_gen_args(self, outtarget: str, outfile: str) -> typing.List[str]:
+ def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
return []
- def get_optimization_args(self, optimization_level: str) -> typing.List[str]:
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return armclang_optimization_args[optimization_level]
- 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]
- 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:]))
diff --git a/mesonbuild/compilers/mixins/ccrx.py b/mesonbuild/compilers/mixins/ccrx.py
index c6979a4..5e61805 100644
--- a/mesonbuild/compilers/mixins/ccrx.py
+++ b/mesonbuild/compilers/mixins/ccrx.py
@@ -15,11 +15,11 @@
"""Representations specific to the Renesas CC-RX compiler family."""
import os
-import typing
+import typing as T
from ...mesonlib import EnvironmentException
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ...environment import Environment
ccrx_buildtype_args = {
@@ -29,7 +29,7 @@ ccrx_buildtype_args = {
'release': [],
'minsize': [],
'custom': [],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
ccrx_optimization_args = {
'0': ['-optimize=0'],
@@ -38,12 +38,12 @@ ccrx_optimization_args = {
'2': ['-optimize=2'],
'3': ['-optimize=max'],
's': ['-optimize=2', '-size']
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
ccrx_debug_args = {
False: [],
True: ['-debug']
-} # type: typing.Dict[bool, typing.List[str]]
+} # type: T.Dict[bool, T.List[str]]
class CcrxCompiler:
@@ -53,44 +53,44 @@ class CcrxCompiler:
self.id = 'ccrx'
# Assembly
self.can_compile_suffixes.update('s')
- default_warn_args = [] # type: typing.List[str]
+ default_warn_args = [] # type: T.List[str]
self.warn_args = {'0': [],
'1': default_warn_args,
'2': default_warn_args + [],
'3': default_warn_args + []}
- def get_pic_args(self) -> typing.List[str]:
+ def get_pic_args(self) -> T.List[str]:
# PIC support is not enabled by default for CCRX,
# if users want to use it, they need to add the required arguments explicitly
return []
- def get_buildtype_args(self, buildtype: str) -> typing.List[str]:
+ def get_buildtype_args(self, buildtype: str) -> T.List[str]:
return ccrx_buildtype_args[buildtype]
def get_pch_suffix(self) -> str:
return 'pch'
- def get_pch_use_args(self, pch_dir: str, header: str) -> typing.List[str]:
+ def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
return []
# Override CCompiler.get_dependency_gen_args
- def get_dependency_gen_args(self, outtarget: str, outfile: str) -> typing.List[str]:
+ def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
return []
- def thread_flags(self, env: 'Environment') -> typing.List[str]:
+ def thread_flags(self, env: 'Environment') -> T.List[str]:
return []
- def get_coverage_args(self) -> typing.List[str]:
+ def get_coverage_args(self) -> T.List[str]:
return []
- def get_optimization_args(self, optimization_level: str) -> typing.List[str]:
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return ccrx_optimization_args[optimization_level]
- def get_debug_args(self, is_debug: bool) -> typing.List[str]:
+ def get_debug_args(self, is_debug: bool) -> T.List[str]:
return ccrx_debug_args[is_debug]
@classmethod
- def unix_args_to_native(cls, args: typing.List[str]) -> typing.List[str]:
+ def unix_args_to_native(cls, args: T.List[str]) -> T.List[str]:
result = []
for i in args:
if i.startswith('-D'):
@@ -108,7 +108,7 @@ class CcrxCompiler:
result.append(i)
return result
- 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[:9] == '-include=':
parameter_list[idx] = i[:9] + os.path.normpath(os.path.join(build_dir, i[9:]))
diff --git a/mesonbuild/compilers/mixins/clang.py b/mesonbuild/compilers/mixins/clang.py
index 16f4659..1c52af2 100644
--- a/mesonbuild/compilers/mixins/clang.py
+++ b/mesonbuild/compilers/mixins/clang.py
@@ -15,14 +15,14 @@
"""Abstractions for the LLVM/Clang compiler family."""
import os
-import typing
+import typing as T
from ... import mesonlib
from ...linkers import AppleDynamicLinker
from ..compilers import clike_optimization_args
from .gnu import GnuLikeCompiler
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ...environment import Environment
from ...dependencies import Dependency # noqa: F401
@@ -30,7 +30,7 @@ clang_color_args = {
'auto': ['-Xclang', '-fcolor-diagnostics'],
'always': ['-Xclang', '-fcolor-diagnostics'],
'never': ['-Xclang', '-fno-color-diagnostics'],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
class ClangCompiler(GnuLikeCompiler):
@@ -45,22 +45,22 @@ class ClangCompiler(GnuLikeCompiler):
# All Clang backends can also do LLVM IR
self.can_compile_suffixes.add('ll')
- def get_colorout_args(self, colortype: str) -> typing.List[str]:
+ def get_colorout_args(self, colortype: str) -> T.List[str]:
return clang_color_args[colortype][:]
- def get_optimization_args(self, optimization_level: str) -> typing.List[str]:
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return clike_optimization_args[optimization_level]
def get_pch_suffix(self) -> str:
return 'pch'
- def get_pch_use_args(self, pch_dir: str, header: str) -> typing.List[str]:
+ def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
# Workaround for Clang bug http://llvm.org/bugs/show_bug.cgi?id=15136
# This flag is internal to Clang (or at least not documented on the man page)
# so it might change semantics at any time.
return ['-include-pch', os.path.join(pch_dir, self.get_pch_name(header))]
- def has_multi_arguments(self, args: typing.List[str], env: 'Environment') -> typing.List[str]:
+ def has_multi_arguments(self, args: T.List[str], env: 'Environment') -> T.List[str]:
myargs = ['-Werror=unknown-warning-option', '-Werror=unused-command-line-argument']
if mesonlib.version_compare(self.version, '>=3.6.0'):
myargs.append('-Werror=ignored-optimization-argument')
@@ -69,8 +69,8 @@ class ClangCompiler(GnuLikeCompiler):
env)
def has_function(self, funcname: str, prefix: str, env: 'Environment', *,
- extra_args: typing.Optional[typing.List[str]] = None,
- dependencies: typing.Optional[typing.List['Dependency']] = None) -> bool:
+ extra_args: T.Optional[T.List[str]] = None,
+ dependencies: T.Optional[T.List['Dependency']] = None) -> bool:
if extra_args is None:
extra_args = []
# Starting with XCode 8, we need to pass this to force linker
@@ -83,7 +83,7 @@ class ClangCompiler(GnuLikeCompiler):
return super().has_function(funcname, prefix, env, extra_args=extra_args,
dependencies=dependencies)
- def openmp_flags(self) -> typing.List[str]:
+ def openmp_flags(self) -> T.List[str]:
if mesonlib.version_compare(self.version, '>=3.8.0'):
return ['-fopenmp']
elif mesonlib.version_compare(self.version, '>=3.7.0'):
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index b5516b0..3aca5fe 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -26,7 +26,7 @@ import itertools
import os
import re
import subprocess
-import typing
+import typing as T
from pathlib import Path
from ... import mesonlib
@@ -35,7 +35,7 @@ from ... import mlog
from .. import compilers
from .visualstudio import VisualStudioLikeCompiler
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ...environment import Environment
@@ -50,7 +50,7 @@ class CLikeCompiler:
find_framework_cache = {}
internal_libs = compilers.unixy_compiler_internal_libs
- def __init__(self, is_cross: bool, exe_wrapper: typing.Optional[str] = None):
+ def __init__(self, is_cross: bool, exe_wrapper: T.Optional[str] = None):
# If a child ObjC or CPP class has already set it, don't set it ourselves
self.is_cross = is_cross
self.can_compile_suffixes.add('h')
@@ -117,7 +117,7 @@ class CLikeCompiler:
def get_coverage_args(self):
return ['--coverage']
- def get_coverage_link_args(self) -> typing.List[str]:
+ def get_coverage_link_args(self) -> T.List[str]:
return self.linker.get_coverage_args()
def get_werror_args(self):
@@ -134,7 +134,7 @@ class CLikeCompiler:
return ['-isystem', path]
return ['-I' + path]
- 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:`
'''
@@ -177,28 +177,28 @@ class CLikeCompiler:
'''
return self.get_compiler_dirs(env, 'programs')
- def get_pic_args(self) -> typing.List[str]:
+ def get_pic_args(self) -> T.List[str]:
return ['-fPIC']
def name_string(self) -> str:
return ' '.join(self.exelist)
- def get_pch_use_args(self, pch_dir: str, header: str) -> typing.List[str]:
+ def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
return ['-include', os.path.basename(header)]
def get_pch_name(self, header_name: str) -> str:
return os.path.basename(header_name) + '.' + self.get_pch_suffix()
- def get_linker_search_args(self, dirname: str) -> typing.List[str]:
+ def get_linker_search_args(self, dirname: str) -> T.List[str]:
return self.linker.get_search_args(dirname)
def get_default_include_dirs(self):
return []
- def gen_export_dynamic_link_args(self, env: 'Environment') -> typing.List[str]:
+ def gen_export_dynamic_link_args(self, env: 'Environment') -> T.List[str]:
return self.linker.export_dynamic_args(env)
- def gen_import_library_args(self, implibname: str) -> typing.List[str]:
+ def gen_import_library_args(self, implibname: str) -> T.List[str]:
return self.linker.import_library_args(implibname)
def sanity_check_impl(self, work_dir, environment, sname, code):
@@ -901,7 +901,7 @@ class CLikeCompiler:
return [f]
@staticmethod
- def _get_file_from_list(env, files: typing.List[str]) -> Path:
+ def _get_file_from_list(env, files: T.List[str]) -> Path:
'''
We just check whether the library exists. We can't do a link check
because the library might have unresolved symbols that require other
@@ -1055,10 +1055,10 @@ class CLikeCompiler:
raise mesonlib.MesonException('Cannot find frameworks with non-clang compiler')
return self.find_framework_impl(name, env, extra_dirs, allow_system)
- def get_crt_compile_args(self, crt_val: str, buildtype: str) -> typing.List[str]:
+ def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]:
return []
- def get_crt_link_args(self, crt_val: str, buildtype: str) -> typing.List[str]:
+ def get_crt_link_args(self, crt_val: str, buildtype: str) -> T.List[str]:
return []
def thread_flags(self, env):
@@ -1067,7 +1067,7 @@ class CLikeCompiler:
return []
return ['-pthread']
- def thread_link_flags(self, env: 'Environment') -> typing.List[str]:
+ def thread_link_flags(self, env: 'Environment') -> T.List[str]:
return self.linker.thread_flags(env)
def linker_to_compiler_args(self, args):
diff --git a/mesonbuild/compilers/mixins/elbrus.py b/mesonbuild/compilers/mixins/elbrus.py
index e157d87..87bf52a 100644
--- a/mesonbuild/compilers/mixins/elbrus.py
+++ b/mesonbuild/compilers/mixins/elbrus.py
@@ -15,21 +15,21 @@
"""Abstractions for the Elbrus family of compilers."""
import os
-import typing
+import typing as T
import subprocess
import re
from .gnu import GnuLikeCompiler
from ...mesonlib import Popen_safe
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ...environment import Environment
class ElbrusCompiler(GnuLikeCompiler):
# Elbrus compiler is nearly like GCC, but does not support
# PCH, LTO, sanitizers and color output as of version 1.21.x.
- def __init__(self, defines: typing.Dict[str, str]):
+ def __init__(self, defines: T.Dict[str, str]):
super().__init__()
self.id = 'lcc'
self.base_options = ['b_pgo', 'b_coverage',
@@ -38,7 +38,7 @@ class ElbrusCompiler(GnuLikeCompiler):
# FIXME: use _build_wrapper to call this so that linker flags from the env
# get applied
- def get_library_dirs(self, env: 'Environment', elf_class: typing.Optional[int] = None) -> typing.List[str]:
+ def get_library_dirs(self, env: 'Environment', elf_class: T.Optional[int] = None) -> T.List[str]:
os_env = os.environ.copy()
os_env['LC_ALL'] = 'C'
stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=os_env)[1]
@@ -49,7 +49,7 @@ class ElbrusCompiler(GnuLikeCompiler):
return [os.path.realpath(p) for p in libstr.split(':') if os.path.exists(p)]
return []
- def get_program_dirs(self, env: 'Environment') -> typing.List[str]:
+ def get_program_dirs(self, env: 'Environment') -> T.List[str]:
os_env = os.environ.copy()
os_env['LC_ALL'] = 'C'
stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=os_env)[1]
@@ -60,7 +60,7 @@ class ElbrusCompiler(GnuLikeCompiler):
return [os.path.realpath(p) for p in libstr.split(':')]
return []
- def get_default_include_dirs(self) -> typing.List[str]:
+ def get_default_include_dirs(self) -> T.List[str]:
os_env = os.environ.copy()
os_env['LC_ALL'] = 'C'
p = subprocess.Popen(self.exelist + ['-xc', '-E', '-v', '-'], env=os_env, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
diff --git a/mesonbuild/compilers/mixins/emscripten.py b/mesonbuild/compilers/mixins/emscripten.py
index 98513e5..945a67d 100644
--- a/mesonbuild/compilers/mixins/emscripten.py
+++ b/mesonbuild/compilers/mixins/emscripten.py
@@ -15,7 +15,7 @@
"""Provides a mixin for shared code between C and C++ Emscripten compilers."""
import os.path
-import typing
+import typing as T
from ...mesonlib import MesonException
@@ -26,10 +26,10 @@ class EmscriptenMixin:
def get_soname_args(self, *args, **kwargs):
raise MesonException('Emscripten does not support shared libraries.')
- def get_allow_undefined_link_args(self) -> typing.List[str]:
+ def get_allow_undefined_link_args(self) -> T.List[str]:
return ['-s', 'ERROR_ON_UNDEFINED_SYMBOLS=0']
- def get_linker_output_args(self, output: str) -> typing.List[str]:
+ def get_linker_output_args(self, output: str) -> T.List[str]:
return ['-o', output]
def _get_compile_output(self, dirname, mode):
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):
diff --git a/mesonbuild/compilers/mixins/intel.py b/mesonbuild/compilers/mixins/intel.py
index 91edecd..fbbfdc5 100644
--- a/mesonbuild/compilers/mixins/intel.py
+++ b/mesonbuild/compilers/mixins/intel.py
@@ -21,13 +21,13 @@ is IntelVisualStudioLikeCompiler.
"""
import os
-import typing
+import typing as T
from ... import mesonlib
from .gnu import GnuLikeCompiler
from .visualstudio import VisualStudioLikeCompiler
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
import subprocess # noqa: F401
# XXX: avoid circular dependencies
@@ -58,7 +58,7 @@ class IntelGnuLikeCompiler(GnuLikeCompiler):
'release': [],
'minsize': [],
'custom': [],
- } # type: typing.Dict[str, typing.List[str]]
+ } # type: T.Dict[str, T.List[str]]
OPTIM_ARGS = {
'0': ['-O0'],
@@ -84,20 +84,20 @@ class IntelGnuLikeCompiler(GnuLikeCompiler):
def get_pch_suffix(self) -> str:
return 'pchi'
- def get_pch_use_args(self, pch_dir: str, header: str) -> typing.List[str]:
+ def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
return ['-pch', '-pch_dir', os.path.join(pch_dir), '-x',
self.lang_header, '-include', header, '-x', 'none']
def get_pch_name(self, header_name: str) -> str:
return os.path.basename(header_name) + '.' + self.get_pch_suffix()
- def openmp_flags(self) -> typing.List[str]:
+ def openmp_flags(self) -> T.List[str]:
if mesonlib.version_compare(self.version, '>=15.0.0'):
return ['-qopenmp']
else:
return ['-openmp']
- def compiles(self, *args, **kwargs) -> typing.Tuple[bool, bool]:
+ def compiles(self, *args, **kwargs) -> T.Tuple[bool, bool]:
# This covers a case that .get('foo', []) doesn't, that extra_args is
# defined and is None
extra_args = kwargs.get('extra_args') or []
@@ -113,16 +113,16 @@ class IntelGnuLikeCompiler(GnuLikeCompiler):
]
return super().compiles(*args, **kwargs)
- def get_profile_generate_args(self) -> typing.List[str]:
+ def get_profile_generate_args(self) -> T.List[str]:
return ['-prof-gen=threadsafe']
- def get_profile_use_args(self) -> typing.List[str]:
+ def get_profile_use_args(self) -> T.List[str]:
return ['-prof-use']
- def get_buildtype_args(self, buildtype: str) -> typing.List[str]:
+ def get_buildtype_args(self, buildtype: str) -> T.List[str]:
return self.BUILD_ARGS[buildtype]
- def get_optimization_args(self, optimization_level: str) -> typing.List[str]:
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return self.OPTIM_ARGS[optimization_level]
@@ -137,7 +137,7 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler):
'release': [],
'minsize': [],
'custom': [],
- } # type: typing.Dict[str, typing.List[str]]
+ } # type: T.Dict[str, T.List[str]]
OPTIM_ARGS = {
'0': ['/O0'],
@@ -152,7 +152,7 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler):
super().__init__(target)
self.id = 'intel-cl'
- def compile(self, code, *, extra_args: typing.Optional[typing.List[str]] = None, **kwargs) -> typing.Iterator['subprocess.Popen']:
+ def compile(self, code, *, extra_args: T.Optional[T.List[str]] = None, **kwargs) -> T.Iterator['subprocess.Popen']:
# This covers a case that .get('foo', []) doesn't, that extra_args is
if kwargs.get('mode', 'compile') != 'link':
extra_args = extra_args.copy() if extra_args is not None else []
@@ -166,7 +166,7 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler):
])
return super().compile(code, extra_args, **kwargs)
- def get_toolset_version(self) -> typing.Optional[str]:
+ def get_toolset_version(self) -> T.Optional[str]:
# Avoid circular dependencies....
from ...environment import search_version
@@ -178,11 +178,11 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler):
version = int(v1 + v2)
return self._calculate_toolset_version(version)
- def openmp_flags(self) -> typing.List[str]:
+ def openmp_flags(self) -> T.List[str]:
return ['/Qopenmp']
- def get_buildtype_args(self, buildtype: str) -> typing.List[str]:
+ def get_buildtype_args(self, buildtype: str) -> T.List[str]:
return self.BUILD_ARGS[buildtype]
- def get_optimization_args(self, optimization_level: str) -> typing.List[str]:
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return self.OPTIM_ARGS[optimization_level]
diff --git a/mesonbuild/compilers/mixins/islinker.py b/mesonbuild/compilers/mixins/islinker.py
index d38f718..4e0af88 100644
--- a/mesonbuild/compilers/mixins/islinker.py
+++ b/mesonbuild/compilers/mixins/islinker.py
@@ -21,11 +21,11 @@ classes for those cases.
"""
import os
-import typing
+import typing as T
from ... import mesonlib
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ...coredata import OptionDictType
from ...environment import Environment
@@ -34,7 +34,7 @@ class LinkerEnvVarsMixin:
"""Mixin reading LDFLAGS from the environment."""
- def get_linker_args_from_envvars(self) -> typing.List[str]:
+ def get_linker_args_from_envvars(self) -> T.List[str]:
flags = os.environ.get('LDFLAGS')
if not flags:
return []
@@ -50,83 +50,83 @@ class BasicLinkerIsCompilerMixin:
functionality itself.
"""
- def sanitizer_link_args(self, value: str) -> typing.List[str]:
+ def sanitizer_link_args(self, value: str) -> T.List[str]:
return []
- def get_lto_link_args(self) -> typing.List[str]:
+ def get_lto_link_args(self) -> T.List[str]:
return []
def can_linker_accept_rsp(self) -> bool:
return mesonlib.is_windows()
- def get_linker_exelist(self) -> typing.List[str]:
+ def get_linker_exelist(self) -> T.List[str]:
return self.exelist.copy()
- def get_linker_output_args(self, output: str) -> typing.List[str]:
+ def get_linker_output_args(self, output: str) -> T.List[str]:
return []
- def get_linker_always_args(self) -> typing.List[str]:
+ def get_linker_always_args(self) -> T.List[str]:
return []
def get_linker_lib_prefix(self) -> str:
return ''
- def get_option_link_args(self, options: 'OptionDictType') -> typing.List[str]:
+ def get_option_link_args(self, options: 'OptionDictType') -> T.List[str]:
return []
- def has_multi_link_args(self, args: typing.List[str], env: 'Environment') -> typing.Tuple[bool, bool]:
+ def has_multi_link_args(self, args: T.List[str], env: 'Environment') -> T.Tuple[bool, bool]:
return False, False
- def get_link_debugfile_args(self, targetfile: str) -> typing.List[str]:
+ def get_link_debugfile_args(self, targetfile: str) -> T.List[str]:
return []
- def get_std_shared_lib_link_args(self) -> typing.List[str]:
+ def get_std_shared_lib_link_args(self) -> T.List[str]:
return []
- def get_std_shared_module_args(self, options: 'OptionDictType') -> typing.List[str]:
+ def get_std_shared_module_args(self, options: 'OptionDictType') -> T.List[str]:
return self.get_std_shared_lib_link_args()
- def get_link_whole_for(self, args: typing.List[str]) -> typing.List[str]:
+ def get_link_whole_for(self, args: T.List[str]) -> T.List[str]:
raise mesonlib.EnvironmentException(
'Linker {} does not support link_whole'.format(self.id))
- def get_allow_undefined_link_args(self) -> typing.List[str]:
+ def get_allow_undefined_link_args(self) -> T.List[str]:
raise mesonlib.EnvironmentException(
'Linker {} does not support allow undefined'.format(self.id))
- def get_pie_link_args(self) -> typing.List[str]:
+ def get_pie_link_args(self) -> T.List[str]:
m = 'Linker {} does not support position-independent executable'
raise mesonlib.EnvironmentException(m.format(self.id))
- def get_undefined_link_args(self) -> typing.List[str]:
+ def get_undefined_link_args(self) -> T.List[str]:
return []
- def get_coverage_link_args(self) -> typing.List[str]:
+ def get_coverage_link_args(self) -> T.List[str]:
m = "Linker {} doesn't implement coverage data generation.".format(self.id)
raise mesonlib.EnvironmentException(m)
- def no_undefined_link_args(self) -> typing.List[str]:
+ def no_undefined_link_args(self) -> T.List[str]:
return []
- def bitcode_args(self) -> typing.List[str]:
+ def bitcode_args(self) -> T.List[str]:
raise mesonlib.MesonException("This linker doesn't support bitcode bundles")
def get_soname_args(self, for_machine: 'mesonlib.MachineChoice',
prefix: str, shlib_name: str, suffix: str, soversion: str,
- darwin_versions: typing.Tuple[str, str],
- is_shared_module: bool) -> typing.List[str]:
+ darwin_versions: T.Tuple[str, str],
+ is_shared_module: bool) -> T.List[str]:
raise mesonlib.MesonException("This linker doesn't support soname args")
def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
rpath_paths: str, build_rpath: str,
- install_rpath: str) -> typing.List[str]:
+ install_rpath: str) -> T.List[str]:
return []
- def get_linker_debug_crt_args(self) -> typing.List[str]:
+ def get_linker_debug_crt_args(self) -> T.List[str]:
return []
- def get_asneeded_args(self) -> typing.List[str]:
+ def get_asneeded_args(self) -> T.List[str]:
return []
- def get_buildtype_linker_args(self, buildtype: str) -> typing.List[str]:
+ def get_buildtype_linker_args(self, buildtype: str) -> T.List[str]:
return []
diff --git a/mesonbuild/compilers/mixins/pgi.py b/mesonbuild/compilers/mixins/pgi.py
index 065c716..77a7a28 100644
--- a/mesonbuild/compilers/mixins/pgi.py
+++ b/mesonbuild/compilers/mixins/pgi.py
@@ -14,7 +14,7 @@
"""Abstractions for the PGI family of compilers."""
-import typing
+import typing as T
import os
from pathlib import Path
@@ -27,7 +27,7 @@ pgi_buildtype_args = {
'release': [],
'minsize': [],
'custom': [],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
class PGICompiler:
@@ -41,50 +41,50 @@ class PGICompiler:
'2': default_warn_args,
'3': default_warn_args}
- def get_module_incdir_args(self) -> typing.Tuple[str]:
+ def get_module_incdir_args(self) -> T.Tuple[str]:
return ('-module', )
- def get_no_warn_args(self) -> typing.List[str]:
+ def get_no_warn_args(self) -> T.List[str]:
return ['-silent']
- def gen_import_library_args(self, implibname: str) -> typing.List[str]:
+ def gen_import_library_args(self, implibname: str) -> T.List[str]:
return []
- def get_pic_args(self) -> typing.List[str]:
+ def get_pic_args(self) -> T.List[str]:
# PGI -fPIC is Linux only.
if self.info.is_linux():
return ['-fPIC']
return []
- def openmp_flags(self) -> typing.List[str]:
+ def openmp_flags(self) -> T.List[str]:
return ['-mp']
- def get_buildtype_args(self, buildtype: str) -> typing.List[str]:
+ def get_buildtype_args(self, buildtype: str) -> T.List[str]:
return pgi_buildtype_args[buildtype]
- def get_optimization_args(self, optimization_level: str) -> typing.List[str]:
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return clike_optimization_args[optimization_level]
- 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]
- 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:]))
return parameter_list
- def get_dependency_gen_args(self, outtarget: str, outfile: str) -> typing.List[str]:
+ def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
return []
- def get_always_args(self) -> typing.List[str]:
+ def get_always_args(self) -> T.List[str]:
return []
def get_pch_suffix(self) -> str:
# PGI defaults to .pch suffix for PCH on Linux and Windows with --pch option
return 'pch'
- def get_pch_use_args(self, pch_dir: str, header: str) -> typing.List[str]:
+ def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
# PGI supports PCH for C++ only.
hdr = Path(pch_dir).resolve().parent / header
if self.language == 'cpp':
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index 8e18144..735dae6 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -18,12 +18,12 @@ interface.
import abc
import os
-import typing
+import typing as T
from ... import mesonlib
from ... import mlog
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ...environment import Environment
vs32_instruction_set_args = {
@@ -36,7 +36,7 @@ vs32_instruction_set_args = {
'avx': ['/arch:AVX'],
'avx2': ['/arch:AVX2'],
'neon': None,
-} # typing.Dicst[str, typing.Optional[typing.List[str]]]
+} # T.Dicst[str, T.Optional[T.List[str]]]
# The 64 bit compiler defaults to /arch:avx.
vs64_instruction_set_args = {
@@ -50,7 +50,7 @@ vs64_instruction_set_args = {
'avx': ['/arch:AVX'],
'avx2': ['/arch:AVX2'],
'neon': None,
-} # typing.Dicst[str, typing.Optional[typing.List[str]]]
+} # T.Dicst[str, T.Optional[T.List[str]]]
msvc_buildtype_args = {
'plain': [],
@@ -59,7 +59,7 @@ msvc_buildtype_args = {
'release': ["/Ob2", "/Gw"],
'minsize': ["/Zi", "/Gw"],
'custom': [],
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
msvc_optimization_args = {
'0': [],
@@ -68,12 +68,12 @@ msvc_optimization_args = {
'2': ['/O2'],
'3': ['/O2'],
's': ['/O1'], # Implies /Os.
-} # type: typing.Dict[str, typing.List[str]]
+} # type: T.Dict[str, T.List[str]]
msvc_debug_args = {
False: [],
True: [] # Fixme!
-} # type: typing.Dict[bool, typing.List[str]]
+} # type: T.Dict[bool, T.List[str]]
class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
@@ -99,7 +99,7 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
'mdd': ['/MDd'],
'mt': ['/MT'],
'mtd': ['/MTd'],
- } # type: typing.Dict[str, typing.List[str]]
+ } # type: T.Dict[str, T.List[str]]
# /showIncludes is needed for build dependency tracking in Ninja
# See: https://ninja-build.org/manual.html#_deps
@@ -109,7 +109,7 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
'1': ['/W2'],
'2': ['/W3'],
'3': ['/W4'],
- } # type: typing.Dict[str, typing.List[str]]
+ } # type: T.Dict[str, T.List[str]]
INVOKES_LINKER = False
@@ -127,10 +127,10 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
self.linker.machine = self.machine
# Override CCompiler.get_always_args
- def get_always_args(self) -> typing.List[str]:
+ def get_always_args(self) -> T.List[str]:
return self.always_args
- def get_buildtype_args(self, buildtype: str) -> typing.List[str]:
+ def get_buildtype_args(self, buildtype: str) -> T.List[str]:
args = msvc_buildtype_args[buildtype]
if self.id == 'msvc' and mesonlib.version_compare(self.version, '<18.0'):
args = [arg for arg in args if arg != '/Gw']
@@ -145,40 +145,40 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
pchname = '.'.join(chopped)
return pchname
- def get_pch_use_args(self, pch_dir: str, header: str) -> typing.List[str]:
+ def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
base = os.path.basename(header)
if self.id == 'clang-cl':
base = header
pchname = self.get_pch_name(header)
return ['/FI' + base, '/Yu' + base, '/Fp' + os.path.join(pch_dir, pchname)]
- def get_preprocess_only_args(self) -> typing.List[str]:
+ def get_preprocess_only_args(self) -> T.List[str]:
return ['/EP']
- def get_compile_only_args(self) -> typing.List[str]:
+ def get_compile_only_args(self) -> T.List[str]:
return ['/c']
- def get_no_optimization_args(self) -> typing.List[str]:
+ def get_no_optimization_args(self) -> T.List[str]:
return ['/Od']
- def get_output_args(self, target: str) -> typing.List[str]:
+ def get_output_args(self, target: str) -> T.List[str]:
if target.endswith('.exe'):
return ['/Fe' + target]
return ['/Fo' + target]
- def get_optimization_args(self, optimization_level: str) -> typing.List[str]:
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return msvc_optimization_args[optimization_level]
- def get_debug_args(self, is_debug: bool) -> typing.List[str]:
+ def get_debug_args(self, is_debug: bool) -> T.List[str]:
return msvc_debug_args[is_debug]
- def get_dependency_gen_args(self, outtarget: str, outfile: str) -> typing.List[str]:
+ def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
return []
- def linker_to_compiler_args(self, args: typing.List[str]) -> typing.List[str]:
+ def linker_to_compiler_args(self, args: T.List[str]) -> T.List[str]:
return ['/link'] + args
- def get_gui_app_args(self, value: bool) -> typing.List[str]:
+ def get_gui_app_args(self, value: bool) -> T.List[str]:
# the default is for the linker to guess the subsystem based on presence
# of main or WinMain symbols, so always be explicit
if value:
@@ -186,33 +186,33 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
else:
return ['/SUBSYSTEM:CONSOLE']
- def get_pic_args(self) -> typing.List[str]:
+ def get_pic_args(self) -> T.List[str]:
return [] # PIC is handled by the loader on Windows
- 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')
# With MSVC, DLLs only export symbols that are explicitly exported,
# so if a module defs file is specified, we use that to export symbols
return ['/DEF:' + defsfile]
- def gen_pch_args(self, header: str, source: str, pchname: str) -> typing.Tuple[str, typing.List[str]]:
+ def gen_pch_args(self, header: str, source: str, pchname: str) -> T.Tuple[str, T.List[str]]:
objname = os.path.splitext(pchname)[0] + '.obj'
return objname, ['/Yc' + header, '/Fp' + pchname, '/Fo' + objname]
- def gen_import_library_args(self, implibname: str) -> typing.List[str]:
+ def gen_import_library_args(self, implibname: str) -> T.List[str]:
"The name of the outputted import library"
return ['/IMPLIB:' + implibname]
- def openmp_flags(self) -> typing.List[str]:
+ def openmp_flags(self) -> T.List[str]:
return ['/openmp']
# FIXME, no idea what these should be.
- def thread_flags(self, env: 'Environment') -> typing.List[str]:
+ def thread_flags(self, env: 'Environment') -> T.List[str]:
return []
@classmethod
- def unix_args_to_native(cls, args: typing.List[str]) -> typing.List[str]:
+ def unix_args_to_native(cls, args: T.List[str]) -> T.List[str]:
result = []
for i in args:
# -mms-bitfields is specific to MinGW-GCC
@@ -251,7 +251,7 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
return result
@classmethod
- def native_args_to_unix(cls, args: typing.List[str]) -> typing.List[str]:
+ def native_args_to_unix(cls, args: T.List[str]) -> T.List[str]:
result = []
for arg in args:
if arg.startswith(('/LIBPATH:', '-LIBPATH:')):
@@ -262,16 +262,16 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
result.append(arg)
return result
- def get_werror_args(self) -> typing.List[str]:
+ def get_werror_args(self) -> T.List[str]:
return ['/WX']
- 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 path == '':
path = '.'
# msvc does not have a concept of system header dirs.
return ['-I' + path]
- 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] == '/I':
parameter_list[idx] = i[:2] + os.path.normpath(os.path.join(build_dir, i[2:]))
@@ -283,7 +283,7 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
# Visual Studio is special. It ignores some arguments it does not
# understand and you can't tell it to error out on those.
# http://stackoverflow.com/questions/15259720/how-can-i-make-the-microsoft-c-compiler-treat-unknown-flags-as-errors-rather-t
- def has_arguments(self, args: typing.List[str], env: 'Environment', code, mode: str) -> typing.Tuple[bool, bool]:
+ def has_arguments(self, args: T.List[str], env: 'Environment', code, mode: str) -> T.Tuple[bool, bool]:
warning_text = '4044' if mode == 'link' else '9002'
if self.id == 'clang-cl' and mode != 'link':
args = args + ['-Werror=unknown-argument']
@@ -292,7 +292,7 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
return False, p.cached
return not(warning_text in p.stde or warning_text in p.stdo), p.cached
- def get_compile_debugfile_args(self, rel_obj: str, pch: bool = False) -> typing.List[str]:
+ def get_compile_debugfile_args(self, rel_obj: str, pch: bool = False) -> T.List[str]:
pdbarr = rel_obj.split('.')[:-1]
pdbarr += ['pdb']
args = ['/Fd' + '.'.join(pdbarr)]
@@ -306,7 +306,7 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
args = ['/FS'] + args
return args
- 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]]:
if self.is_64:
return vs64_instruction_set_args.get(instruction_set, None)
if self.id == 'msvc' and self.version.split('.')[0] == '16' and instruction_set == 'avx':
@@ -316,7 +316,7 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
return None
return vs32_instruction_set_args.get(instruction_set, None)
- def _calculate_toolset_version(self, version: int) -> typing.Optional[str]:
+ def _calculate_toolset_version(self, version: int) -> T.Optional[str]:
if version < 1310:
return '7.0'
elif version < 1400:
@@ -340,7 +340,7 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
mlog.warning('Could not find toolset for version {!r}'.format(self.version))
return None
- def get_toolset_version(self) -> typing.Optional[str]:
+ def get_toolset_version(self) -> T.Optional[str]:
if self.id == 'clang-cl':
# I have no idea
return '14.1'
@@ -352,12 +352,12 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
return None
return self._calculate_toolset_version(version)
- def get_default_include_dirs(self) -> typing.List[str]:
+ def get_default_include_dirs(self) -> T.List[str]:
if 'INCLUDE' not in os.environ:
return []
return os.environ['INCLUDE'].split(os.pathsep)
- def get_crt_compile_args(self, crt_val: str, buildtype: str) -> typing.List[str]:
+ def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]:
if crt_val in self.crt_args:
return self.crt_args[crt_val]
assert(crt_val == 'from_buildtype')
@@ -376,7 +376,7 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
assert(buildtype == 'custom')
raise mesonlib.EnvironmentException('Requested C runtime based on buildtype, but buildtype is "custom".')
- def has_func_attribute(self, name: str, env: 'Environment') -> typing.Tuple[bool, bool]:
+ def has_func_attribute(self, name: str, env: 'Environment') -> T.Tuple[bool, bool]:
# MSVC doesn't have __attribute__ like Clang and GCC do, so just return
# false without compiling anything
return name in ['dllimport', 'dllexport'], False
@@ -385,5 +385,5 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
return 'msvc'
@classmethod
- def use_linker_args(cls, linker: str) -> typing.List[str]:
+ def use_linker_args(cls, linker: str) -> T.List[str]:
return []
diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py
index a4aa5dc..cc3fba9 100644
--- a/mesonbuild/compilers/objc.py
+++ b/mesonbuild/compilers/objc.py
@@ -13,7 +13,7 @@
# limitations under the License.
import os.path, subprocess
-import typing
+import typing as T
from ..mesonlib import EnvironmentException, MachineChoice
@@ -22,7 +22,7 @@ from .mixins.clike import CLikeCompiler
from .mixins.gnu import GnuCompiler
from .mixins.clang import ClangCompiler
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
@@ -32,7 +32,7 @@ class ObjCCompiler(CLikeCompiler, Compiler):
def __init__(self, exelist, version, for_machine: MachineChoice,
is_cross: bool, info: 'MachineInfo',
- exe_wrap: typing.Optional[str], **kwargs):
+ exe_wrap: T.Optional[str], **kwargs):
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrap)
diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py
index b42cef6..9d58b45 100644
--- a/mesonbuild/compilers/objcpp.py
+++ b/mesonbuild/compilers/objcpp.py
@@ -13,7 +13,7 @@
# limitations under the License.
import os.path, subprocess
-import typing
+import typing as T
from ..mesonlib import EnvironmentException, MachineChoice
@@ -22,7 +22,7 @@ from .compilers import Compiler
from .mixins.gnu import GnuCompiler
from .mixins.clang import ClangCompiler
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
class ObjCPPCompiler(CLikeCompiler, Compiler):
@@ -31,7 +31,7 @@ class ObjCPPCompiler(CLikeCompiler, Compiler):
def __init__(self, exelist, version, for_machine: MachineChoice,
is_cross: bool, info: 'MachineInfo',
- exe_wrap: typing.Optional[str], **kwargs):
+ exe_wrap: T.Optional[str], **kwargs):
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrap)
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py
index 613414d..c2e21c4 100644
--- a/mesonbuild/compilers/rust.py
+++ b/mesonbuild/compilers/rust.py
@@ -13,12 +13,12 @@
# limitations under the License.
import subprocess, os.path
-import typing
+import typing as T
from ..mesonlib import EnvironmentException, MachineChoice, Popen_safe
from .compilers import Compiler, rust_buildtype_args, clike_debug_args
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
from ..environment import Environment # noqa: F401
diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py
index 0909d20..2d2c4e1 100644
--- a/mesonbuild/compilers/swift.py
+++ b/mesonbuild/compilers/swift.py
@@ -13,13 +13,13 @@
# limitations under the License.
import subprocess, os.path
-import typing
+import typing as T
from ..mesonlib import EnvironmentException, MachineChoice
from .compilers import Compiler, swift_buildtype_args, clike_debug_args
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
swift_optimization_args = {'0': [],
diff --git a/mesonbuild/compilers/vala.py b/mesonbuild/compilers/vala.py
index 3f4e5fa..012f16a 100644
--- a/mesonbuild/compilers/vala.py
+++ b/mesonbuild/compilers/vala.py
@@ -13,14 +13,14 @@
# limitations under the License.
import os.path
-import typing
+import typing as T
from .. import mlog
from ..mesonlib import EnvironmentException, MachineChoice, version_compare
from .compilers import Compiler
-if typing.TYPE_CHECKING:
+if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
class ValaCompiler(Compiler):