aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/compilers/mixins')
-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
11 files changed, 209 insertions, 209 deletions
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 []