diff options
author | Tristan Partin <tristan@partin.io> | 2023-07-12 17:36:25 -0500 |
---|---|---|
committer | Tristan Partin <tristan@partin.io> | 2023-07-12 18:56:06 -0500 |
commit | 921c2370a722cbaa42bd256c699fae3185084939 (patch) | |
tree | 8884965e8f1e1413703f271ceba046e52647d723 /mesonbuild/compilers/mixins | |
parent | 1624354f33bf0a33f0e715ba1ca391ae0154ad19 (diff) | |
download | meson-921c2370a722cbaa42bd256c699fae3185084939.zip meson-921c2370a722cbaa42bd256c699fae3185084939.tar.gz meson-921c2370a722cbaa42bd256c699fae3185084939.tar.bz2 |
Replace some type comments with annotations
Diffstat (limited to 'mesonbuild/compilers/mixins')
-rw-r--r-- | mesonbuild/compilers/mixins/ccrx.py | 27 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/clang.py | 8 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 26 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/compcert.py | 31 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/gnu.py | 42 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/intel.py | 8 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/metrowerks.py | 41 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/ti.py | 25 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/visualstudio.py | 26 |
9 files changed, 119 insertions, 115 deletions
diff --git a/mesonbuild/compilers/mixins/ccrx.py b/mesonbuild/compilers/mixins/ccrx.py index 1c22214..6e503d1 100644 --- a/mesonbuild/compilers/mixins/ccrx.py +++ b/mesonbuild/compilers/mixins/ccrx.py @@ -31,35 +31,35 @@ else: # do). This gives up DRYer type checking, with no runtime impact Compiler = object -ccrx_buildtype_args = { +ccrx_buildtype_args: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': [], 'debugoptimized': [], 'release': [], 'minsize': [], 'custom': [], -} # type: T.Dict[str, T.List[str]] +} -ccrx_optimization_args = { +ccrx_optimization_args: T.Dict[str, T.List[str]] = { '0': ['-optimize=0'], 'g': ['-optimize=0'], '1': ['-optimize=1'], '2': ['-optimize=2'], '3': ['-optimize=max'], 's': ['-optimize=2', '-size'] -} # type: T.Dict[str, T.List[str]] +} -ccrx_debug_args = { +ccrx_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['-debug'] -} # type: T.Dict[bool, T.List[str]] +} class CcrxCompiler(Compiler): if T.TYPE_CHECKING: is_cross = True - can_compile_suffixes = set() # type: T.Set[str] + can_compile_suffixes: T.Set[str] = set() id = 'ccrx' @@ -68,12 +68,13 @@ class CcrxCompiler(Compiler): raise EnvironmentException('ccrx supports only cross-compilation.') # Assembly self.can_compile_suffixes.add('src') - default_warn_args = [] # type: T.List[str] - self.warn_args = {'0': [], - '1': default_warn_args, - '2': default_warn_args + [], - '3': default_warn_args + [], - 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]] + default_warn_args: T.List[str] = [] + self.warn_args: T.Dict[str, T.List[str]] = { + '0': [], + '1': default_warn_args, + '2': default_warn_args + [], + '3': default_warn_args + [], + 'everything': default_warn_args + []} def get_pic_args(self) -> T.List[str]: # PIC support is not enabled by default for CCRX, diff --git a/mesonbuild/compilers/mixins/clang.py b/mesonbuild/compilers/mixins/clang.py index b43b246..24f24a8 100644 --- a/mesonbuild/compilers/mixins/clang.py +++ b/mesonbuild/compilers/mixins/clang.py @@ -30,13 +30,13 @@ if T.TYPE_CHECKING: from ...environment import Environment from ...dependencies import Dependency # noqa: F401 -clang_color_args = { +clang_color_args: T.Dict[str, T.List[str]] = { 'auto': ['-fcolor-diagnostics'], 'always': ['-fcolor-diagnostics'], 'never': ['-fno-color-diagnostics'], -} # type: T.Dict[str, T.List[str]] +} -clang_optimization_args = { +clang_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['-O0'], 'g': ['-Og'], @@ -44,7 +44,7 @@ clang_optimization_args = { '2': ['-O2'], '3': ['-O3'], 's': ['-Oz'], -} # type: T.Dict[str, T.List[str]] +} class ClangCompiler(GnuLikeCompiler): diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index fe39ef1..d3e1008 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -103,7 +103,7 @@ class CLikeCompilerArgs(arglist.CompilerArgs): default_dirs = self.compiler.get_default_include_dirs() if default_dirs: real_default_dirs = [self._cached_realpath(i) for i in default_dirs] - bad_idx_list = [] # type: T.List[int] + bad_idx_list: T.List[int] = [] for i, each in enumerate(new): if not each.startswith('-isystem'): continue @@ -136,11 +136,11 @@ class CLikeCompiler(Compiler): """Shared bits for the C and CPP Compilers.""" if T.TYPE_CHECKING: - warn_args = {} # type: T.Dict[str, T.List[str]] + warn_args: T.Dict[str, T.List[str]] = {} # TODO: Replace this manual cache with functools.lru_cache - find_library_cache = {} # type: T.Dict[T.Tuple[T.Tuple[str, ...], str, T.Tuple[str, ...], str, LibType], T.Optional[T.List[str]]] - find_framework_cache = {} # type: T.Dict[T.Tuple[T.Tuple[str, ...], str, T.Tuple[str, ...], bool], T.Optional[T.List[str]]] + find_library_cache: T.Dict[T.Tuple[T.Tuple[str, ...], str, T.Tuple[str, ...], str, LibType], T.Optional[T.List[str]]] = {} + find_framework_cache: T.Dict[T.Tuple[T.Tuple[str, ...], str, T.Tuple[str, ...], bool], T.Optional[T.List[str]]] = {} internal_libs = arglist.UNIXY_COMPILER_INTERNAL_LIBS def __init__(self, exe_wrapper: T.Optional['ExternalProgram'] = None): @@ -389,8 +389,8 @@ class CLikeCompiler(Compiler): dependencies=dependencies) def _get_basic_compiler_args(self, env: 'Environment', mode: CompileCheckMode) -> T.Tuple[T.List[str], T.List[str]]: - cargs = [] # type: T.List[str] - largs = [] # type: T.List[str] + cargs: T.List[str] = [] + largs: T.List[str] = [] if mode is CompileCheckMode.LINK: # Sometimes we need to manually select the CRT to use with MSVC. # One example is when trying to do a compiler check that involves @@ -446,8 +446,8 @@ class CLikeCompiler(Compiler): # TODO: we want to ensure the front end does the listifing here dependencies = [dependencies] # Collect compiler arguments - cargs = self.compiler_args() # type: arglist.CompilerArgs - largs = [] # type: T.List[str] + cargs: arglist.CompilerArgs = self.compiler_args() + largs: T.List[str] = [] for d in dependencies: # Add compile flags needed by dependencies cargs += d.get_compile_args() @@ -805,7 +805,7 @@ class CLikeCompiler(Compiler): # # class StrProto(typing.Protocol): # def __str__(self) -> str: ... - fargs = {'prefix': prefix, 'func': funcname} # type: T.Dict[str, T.Union[str, bool, int]] + fargs: T.Dict[str, T.Union[str, bool, int]] = {'prefix': prefix, 'func': funcname} # glibc defines functions that are not available on Linux as stubs that # fail with ENOSYS (such as e.g. lchmod). In this case we want to fail @@ -1002,7 +1002,7 @@ class CLikeCompiler(Compiler): return self._symbols_have_underscore_prefix_searchbin(env) def _get_patterns(self, env: 'Environment', prefixes: T.List[str], suffixes: T.List[str], shared: bool = False) -> T.List[str]: - patterns = [] # type: T.List[str] + patterns: T.List[str] = [] for p in prefixes: for s in suffixes: patterns.append(p + '{}.' + s) @@ -1066,7 +1066,7 @@ class CLikeCompiler(Compiler): @staticmethod def _sort_shlibs_openbsd(libs: T.List[str]) -> T.List[str]: - filtered = [] # type: T.List[str] + filtered: T.List[str] = [] for lib in libs: # Validate file as a shared library of type libfoo.so.X.Y ret = lib.rsplit('.so.', maxsplit=1) @@ -1205,7 +1205,7 @@ class CLikeCompiler(Compiler): os_env = os.environ.copy() os_env['LC_ALL'] = 'C' _, _, stde = mesonlib.Popen_safe(commands, env=os_env, stdin=subprocess.PIPE) - paths = [] # T.List[str] + paths: T.List[str] = [] for line in stde.split('\n'): if '(framework directory)' not in line: continue @@ -1273,7 +1273,7 @@ class CLikeCompiler(Compiler): return self.compiles(code, env, extra_args=args, mode=mode) def _has_multi_arguments(self, args: T.List[str], env: 'Environment', code: str) -> T.Tuple[bool, bool]: - new_args = [] # type: T.List[str] + new_args: T.List[str] = [] for arg in args: # some compilers, e.g. GCC, don't warn for unsupported warning-disable # flags, so when we are testing a flag like "-Wno-forgotten-towel", also diff --git a/mesonbuild/compilers/mixins/compcert.py b/mesonbuild/compilers/mixins/compcert.py index d9c21a8..ac4d5aa 100644 --- a/mesonbuild/compilers/mixins/compcert.py +++ b/mesonbuild/compilers/mixins/compcert.py @@ -30,16 +30,16 @@ else: # do). This gives up DRYer type checking, with no runtime impact Compiler = object -ccomp_buildtype_args = { +ccomp_buildtype_args: T.Dict[str, T.List[str]] = { 'plain': [''], 'debug': ['-O0', '-g'], 'debugoptimized': ['-O0', '-g'], 'release': ['-O3'], 'minsize': ['-Os'], 'custom': ['-Obranchless'], -} # type: T.Dict[str, T.List[str]] +} -ccomp_optimization_args = { +ccomp_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['-O0'], 'g': ['-O0'], @@ -47,19 +47,19 @@ ccomp_optimization_args = { '2': ['-O2'], '3': ['-O3'], 's': ['-Os'] -} # type: T.Dict[str, T.List[str]] +} -ccomp_debug_args = { +ccomp_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['-g'] -} # type: T.Dict[bool, T.List[str]] +} # As of CompCert 20.04, these arguments should be passed to the underlying gcc linker (via -WUl,<arg>) # There are probably (many) more, but these are those used by picolibc -ccomp_args_to_wul = [ +ccomp_args_to_wul: T.List[str] = [ r"^-ffreestanding$", r"^-r$" -] # type: T.List[str] +] class CompCertCompiler(Compiler): @@ -69,12 +69,13 @@ class CompCertCompiler(Compiler): # Assembly self.can_compile_suffixes.add('s') self.can_compile_suffixes.add('sx') - default_warn_args = [] # type: T.List[str] - self.warn_args = {'0': [], - '1': default_warn_args, - '2': default_warn_args + [], - '3': default_warn_args + [], - 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]] + default_warn_args: T.List[str] = [] + self.warn_args: T.Dict[str, T.List[str]] = { + '0': [], + '1': default_warn_args, + '2': default_warn_args + [], + '3': default_warn_args + [], + 'everything': default_warn_args + []} def get_always_args(self) -> T.List[str]: return [] @@ -95,7 +96,7 @@ class CompCertCompiler(Compiler): @classmethod def _unix_args_to_native(cls, args: T.List[str], info: MachineInfo) -> T.List[str]: "Always returns a copy that can be independently mutated" - patched_args = [] # type: T.List[str] + patched_args: T.List[str] = [] for arg in args: added = 0 for ptrn in ccomp_args_to_wul: diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index 6517a3e..703fb1a 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -42,21 +42,21 @@ else: # XXX: prevent circular references. # FIXME: this really is a posix interface not a c-like interface -clike_debug_args = { +clike_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['-g'], -} # type: T.Dict[bool, T.List[str]] +} -gnulike_buildtype_args = { +gnulike_buildtype_args: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': [], 'debugoptimized': [], 'release': [], 'minsize': [], 'custom': [], -} # type: T.Dict[str, T.List[str]] +} -gnu_optimization_args = { +gnu_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['-O0'], 'g': ['-Og'], @@ -64,9 +64,9 @@ gnu_optimization_args = { '2': ['-O2'], '3': ['-O3'], 's': ['-Os'], -} # type: T.Dict[str, T.List[str]] +} -gnulike_instruction_set_args = { +gnulike_instruction_set_args: T.Dict[str, T.List[str]] = { 'mmx': ['-mmmx'], 'sse': ['-msse'], 'sse2': ['-msse2'], @@ -77,22 +77,22 @@ gnulike_instruction_set_args = { 'avx': ['-mavx'], 'avx2': ['-mavx2'], 'neon': ['-mfpu=neon'], -} # type: T.Dict[str, T.List[str]] +} -gnu_symbol_visibility_args = { +gnu_symbol_visibility_args: T.Dict[str, T.List[str]] = { '': [], 'default': ['-fvisibility=default'], 'internal': ['-fvisibility=internal'], 'hidden': ['-fvisibility=hidden'], 'protected': ['-fvisibility=protected'], 'inlineshidden': ['-fvisibility=hidden', '-fvisibility-inlines-hidden'], -} # type: T.Dict[str, T.List[str]] +} -gnu_color_args = { +gnu_color_args: T.Dict[str, T.List[str]] = { 'auto': ['-fdiagnostics-color=auto'], 'always': ['-fdiagnostics-color=always'], 'never': ['-fdiagnostics-color=never'], -} # type: T.Dict[str, T.List[str]] +} # Warnings collected from the GCC source and documentation. This is an # objective set of all the warnings flags that apply to general projects: the @@ -118,7 +118,7 @@ gnu_color_args = { # # Omitted warnings enabled elsewhere in meson: # -Winvalid-pch (GCC 3.4.0) -gnu_common_warning_args = { +gnu_common_warning_args: T.Dict[str, T.List[str]] = { "0.0.0": [ "-Wcast-qual", "-Wconversion", @@ -213,7 +213,7 @@ gnu_common_warning_args = { "-Wopenacc-parallelism", "-Wtrivial-auto-var-init", ], -} # type: T.Dict[str, T.List[str]] +} # GCC warnings for C # Omitted non-general or legacy warnings: @@ -223,7 +223,7 @@ gnu_common_warning_args = { # -Wdeclaration-after-statement # -Wtraditional # -Wtraditional-conversion -gnu_c_warning_args = { +gnu_c_warning_args: T.Dict[str, T.List[str]] = { "0.0.0": [ "-Wbad-function-cast", "-Wmissing-prototypes", @@ -240,7 +240,7 @@ gnu_c_warning_args = { "4.5.0": [ "-Wunsuffixed-float-constants", ], -} # type: T.Dict[str, T.List[str]] +} # GCC warnings for C++ # Omitted non-general or legacy warnings: @@ -250,7 +250,7 @@ gnu_c_warning_args = { # -Wctad-maybe-unsupported # -Wnamespaces # -Wtemplates -gnu_cpp_warning_args = { +gnu_cpp_warning_args: T.Dict[str, T.List[str]] = { "0.0.0": [ "-Wctor-dtor-privacy", "-Weffc++", @@ -309,13 +309,13 @@ gnu_cpp_warning_args = { "-Wdeprecated-enum-float-conversion", "-Winvalid-imported-macros", ], -} # type: T.Dict[str, T.List[str]] +} # GCC warnings for Objective C and Objective C++ # Omitted non-general or legacy warnings: # -Wtraditional # -Wtraditional-conversion -gnu_objc_warning_args = { +gnu_objc_warning_args: T.Dict[str, T.List[str]] = { "0.0.0": [ "-Wselector", ], @@ -326,7 +326,7 @@ gnu_objc_warning_args = { "-Wassign-intercept", "-Wstrict-selector-match", ], -} # type: T.Dict[str, T.List[str]] +} _LANG_MAP = { 'c': 'c', @@ -345,7 +345,7 @@ def gnulike_default_include_dirs(compiler: T.Tuple[str, ...], lang: str) -> 'Imm cmd = list(compiler) + [f'-x{lang}', '-E', '-v', '-'] _, stdout, _ = mesonlib.Popen_safe(cmd, stderr=subprocess.STDOUT, env=env) parse_state = 0 - paths = [] # type: T.List[str] + paths: T.List[str] = [] for line in stdout.split('\n'): line = line.strip(' \n\r\t') if parse_state == 0: diff --git a/mesonbuild/compilers/mixins/intel.py b/mesonbuild/compilers/mixins/intel.py index b793fa8..711e77c 100644 --- a/mesonbuild/compilers/mixins/intel.py +++ b/mesonbuild/compilers/mixins/intel.py @@ -50,14 +50,14 @@ class IntelGnuLikeCompiler(GnuLikeCompiler): minsize: -O2 """ - BUILD_ARGS = { + BUILD_ARGS: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': ["-g", "-traceback"], 'debugoptimized': ["-g", "-traceback"], 'release': [], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } OPTIM_ARGS: T.Dict[str, T.List[str]] = { 'plain': [], @@ -129,14 +129,14 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler): """Abstractions for ICL, the Intel compiler on Windows.""" - BUILD_ARGS = { + BUILD_ARGS: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': ["/Zi", "/traceback"], 'debugoptimized': ["/Zi", "/traceback"], 'release': [], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } OPTIM_ARGS: T.Dict[str, T.List[str]] = { 'plain': [], diff --git a/mesonbuild/compilers/mixins/metrowerks.py b/mesonbuild/compilers/mixins/metrowerks.py index 4390145..970faeb 100644 --- a/mesonbuild/compilers/mixins/metrowerks.py +++ b/mesonbuild/compilers/mixins/metrowerks.py @@ -30,16 +30,16 @@ else: # do). This gives up DRYer type checking, with no runtime impact Compiler = object -mwcc_buildtype_args = { +mwcc_buildtype_args: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': ['-g'], 'debugoptimized': ['-g', '-O4'], 'release': ['-O4,p'], 'minsize': ['-Os'], 'custom': [], -} # type: T.Dict[str, T.List[str]] +} -mwccarm_instruction_set_args = { +mwccarm_instruction_set_args: T.Dict[str, T.List[str]] = { 'generic': ['-proc', 'generic'], 'v4': ['-proc', 'v4'], 'v4t': ['-proc', 'v4t'], @@ -69,9 +69,9 @@ mwccarm_instruction_set_args = { 'pxa261': ['-proc', 'pxa261'], 'pxa262': ['-proc', 'pxa262'], 'pxa263': ['-proc', 'pxa263'] -} # type: T.Dict[str, T.List[str]] +} -mwcceppc_instruction_set_args = { +mwcceppc_instruction_set_args: T.Dict[str, T.List[str]] = { 'generic': ['-proc', 'generic'], '401': ['-proc', '401'], '403': ['-proc', '403'], @@ -97,9 +97,9 @@ mwcceppc_instruction_set_args = { '8260': ['-proc', '8260'], 'e500': ['-proc', 'e500'], 'gekko': ['-proc', 'gekko'], -} # type: T.Dict[str, T.List[str]] +} -mwasmarm_instruction_set_args = { +mwasmarm_instruction_set_args: T.Dict[str, T.List[str]] = { 'arm4': ['-proc', 'arm4'], 'arm4t': ['-proc', 'arm4t'], 'arm4xm': ['-proc', 'arm4xm'], @@ -112,9 +112,9 @@ mwasmarm_instruction_set_args = { 'arm5TExP': ['-proc', 'arm5TExP'], 'arm6': ['-proc', 'arm6'], 'xscale': ['-proc', 'xscale'] -} # type: T.Dict[str, T.List[str]] +} -mwasmeppc_instruction_set_args = { +mwasmeppc_instruction_set_args: T.Dict[str, T.List[str]] = { '401': ['-proc', '401'], '403': ['-proc', '403'], '505': ['-proc', '505'], @@ -165,9 +165,9 @@ mwasmeppc_instruction_set_args = { '5674': ['-proc', '5674'], 'gekko': ['-proc', 'gekko'], 'generic': ['-proc', 'generic'], -} # type: T.Dict[str, T.List[str]] +} -mwcc_optimization_args = { +mwcc_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['-O0'], 'g': ['-Op'], @@ -175,12 +175,12 @@ mwcc_optimization_args = { '2': ['-O2'], '3': ['-O3'], 's': ['-Os'] -} # type: T.Dict[str, T.List[str]] +} -mwcc_debug_args = { +mwcc_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['-g'] -} # type: T.Dict[bool, T.List[str]] +} class MetrowerksCompiler(Compiler): @@ -197,12 +197,13 @@ class MetrowerksCompiler(Compiler): self.base_options = { OptionKey(o) for o in ['b_pch', 'b_ndebug']} - default_warn_args = [] # type: T.List[str] - self.warn_args = {'0': ['-w', 'off'], - '1': default_warn_args, - '2': default_warn_args + ['-w', 'most'], - '3': default_warn_args + ['-w', 'all'], - 'everything': default_warn_args + ['-w', 'full']} # type: T.Dict[str, T.List[str]] + default_warn_args: T.List[str] = [] + self.warn_args: T.Dict[str, T.List[str]] = { + '0': ['-w', 'off'], + '1': default_warn_args, + '2': default_warn_args + ['-w', 'most'], + '3': default_warn_args + ['-w', 'all'], + 'everything': default_warn_args + ['-w', 'full']} def depfile_for_object(self, objfile: str) -> T.Optional[str]: # Earlier versions of these compilers do not support specifying diff --git a/mesonbuild/compilers/mixins/ti.py b/mesonbuild/compilers/mixins/ti.py index 950c97f..53688a9 100644 --- a/mesonbuild/compilers/mixins/ti.py +++ b/mesonbuild/compilers/mixins/ti.py @@ -31,16 +31,16 @@ else: # do). This gives up DRYer type checking, with no runtime impact Compiler = object -ti_buildtype_args = { +ti_buildtype_args: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': [], 'debugoptimized': [], 'release': [], 'minsize': [], 'custom': [], -} # type: T.Dict[str, T.List[str]] +} -ti_optimization_args = { +ti_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['-O0'], 'g': ['-Ooff'], @@ -48,12 +48,12 @@ ti_optimization_args = { '2': ['-O2'], '3': ['-O3'], 's': ['-O4'] -} # type: T.Dict[str, T.List[str]] +} -ti_debug_args = { +ti_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['-g'] -} # type: T.Dict[bool, T.List[str]] +} class TICompiler(Compiler): @@ -67,12 +67,13 @@ class TICompiler(Compiler): self.can_compile_suffixes.add('asm') # Assembly self.can_compile_suffixes.add('cla') # Control Law Accelerator (CLA) used in C2000 - default_warn_args = [] # type: T.List[str] - self.warn_args = {'0': [], - '1': default_warn_args, - '2': default_warn_args + [], - '3': default_warn_args + [], - 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]] + default_warn_args: T.List[str] = [] + self.warn_args: T.Dict[str, T.List[str]] = { + '0': [], + '1': default_warn_args, + '2': default_warn_args + [], + '3': default_warn_args + [], + 'everything': default_warn_args + []} def get_pic_args(self) -> T.List[str]: # PIC support is not enabled by default for TI compilers, diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index cc52538..cd71558 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -37,7 +37,7 @@ else: # do). This gives up DRYer type checking, with no runtime impact Compiler = object -vs32_instruction_set_args = { +vs32_instruction_set_args: T.Dict[str, T.Optional[T.List[str]]] = { 'mmx': ['/arch:SSE'], # There does not seem to be a flag just for MMX 'sse': ['/arch:SSE'], 'sse2': ['/arch:SSE2'], @@ -47,10 +47,10 @@ vs32_instruction_set_args = { 'avx': ['/arch:AVX'], 'avx2': ['/arch:AVX2'], 'neon': None, -} # T.Dicst[str, T.Optional[T.List[str]]] +} # The 64 bit compiler defaults to /arch:avx. -vs64_instruction_set_args = { +vs64_instruction_set_args: T.Dict[str, T.Optional[T.List[str]]] = { 'mmx': ['/arch:AVX'], 'sse': ['/arch:AVX'], 'sse2': ['/arch:AVX'], @@ -61,9 +61,9 @@ vs64_instruction_set_args = { 'avx': ['/arch:AVX'], 'avx2': ['/arch:AVX2'], 'neon': None, -} # T.Dicst[str, T.Optional[T.List[str]]] +} -msvc_optimization_args = { +msvc_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['/Od'], 'g': [], # No specific flag to optimize debugging, /Zi or /ZI will create debug information @@ -71,12 +71,12 @@ msvc_optimization_args = { '2': ['/O2'], '3': ['/O2', '/Gw'], 's': ['/O1', '/Gw'], -} # type: T.Dict[str, T.List[str]] +} -msvc_debug_args = { +msvc_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['/Zi'] -} # type: T.Dict[bool, T.List[str]] +} class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): @@ -92,15 +92,15 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): std_warn_args = ['/W3'] std_opt_args = ['/O2'] ignore_libs = arglist.UNIXY_COMPILER_INTERNAL_LIBS + ['execinfo'] - internal_libs = [] # type: T.List[str] + internal_libs: T.List[str] = [] - crt_args = { + crt_args: T.Dict[str, T.List[str]] = { 'none': [], 'md': ['/MD'], 'mdd': ['/MDd'], 'mt': ['/MT'], 'mtd': ['/MTd'], - } # 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,13 +109,13 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): # It is also dropped if Visual Studio 2013 or earlier is used, since it would # not be supported in that case. always_args = ['/nologo', '/showIncludes', '/utf-8'] - warn_args = { + warn_args: T.Dict[str, T.List[str]] = { '0': [], '1': ['/W2'], '2': ['/W3'], '3': ['/W4'], 'everything': ['/Wall'], - } # type: T.Dict[str, T.List[str]] + } INVOKES_LINKER = False |