compilers/mixins/intel: make type safe

pull/7786/head
Dylan Baker 4 years ago
parent a0a8ef567e
commit 8ee1e6b768
  1. 33
      mesonbuild/compilers/mixins/intel.py
  2. 2
      run_mypy.py

@ -30,6 +30,10 @@ from .visualstudio import VisualStudioLikeCompiler
if T.TYPE_CHECKING:
import subprocess # noqa: F401
from ...arglist import CompilerArgs
from ...dependencies import Dependency
from ...environment import Environment
# XXX: avoid circular dependencies
# TODO: this belongs in a posix compiler class
# NOTE: the default Intel optimization is -O2, unlike GNU which defaults to -O0.
@ -97,12 +101,13 @@ class IntelGnuLikeCompiler(GnuLikeCompiler):
else:
return ['-openmp']
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 []
kwargs['extra_args'] = [
extra_args,
def compiles(self, code: str, env: 'Environment', *,
extra_args: T.Union[None, T.List[str], 'CompilerArgs'] = None,
dependencies: T.Optional[T.List['Dependency']] = None,
mode: str = 'compile',
disable_cache: bool = False) -> T.Tuple[bool, bool]:
extra_args = extra_args.copy() if extra_args is not None else []
extra_args += [
'-diag-error', '10006', # ignoring unknown option
'-diag-error', '10148', # Option not supported
'-diag-error', '10155', # ignoring argument required
@ -110,7 +115,8 @@ class IntelGnuLikeCompiler(GnuLikeCompiler):
'-diag-error', '10157', # Ignoring argument of the wrong type
'-diag-error', '10158', # Argument must be separate. Can be hit by trying an option like -foo-bar=foo when -foo=bar is a valid option but -foo-bar isn't
]
return super().compiles(*args, **kwargs)
ret = super().compiles(code, env, extra_args=extra_args, dependencies=dependencies, mode=mode, disable_cache=disable_cache) # type: ignore
return T.cast(T.Tuple[bool, bool], ret)
def get_profile_generate_args(self) -> T.List[str]:
return ['-prof-gen=threadsafe']
@ -150,13 +156,17 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler):
's': ['/Os'],
}
def __init__(self, target: str):
def __init__(self, target: str) -> None:
super().__init__(target)
self.id = 'intel-cl'
def compile(self, code: str, *, extra_args: T.Optional[T.List[str]] = None, **kwargs) -> T.Iterator['subprocess.Popen']:
def compiles(self, code: str, env: 'Environment', *,
extra_args: T.Union[None, T.List[str], 'CompilerArgs'] = None,
dependencies: T.Optional[T.List['Dependency']] = None,
mode: str = 'compile',
disable_cache: bool = False) -> T.Tuple[bool, bool]:
# This covers a case that .get('foo', []) doesn't, that extra_args is
if kwargs.get('mode', 'compile') != 'link':
if mode != 'link':
extra_args = extra_args.copy() if extra_args is not None else []
extra_args.extend([
'/Qdiag-error:10006', # ignoring unknown option
@ -166,7 +176,8 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler):
'/Qdiag-error:10157', # Ignoring argument of the wrong type
'/Qdiag-error:10158', # Argument must be separate. Can be hit by trying an option like -foo-bar=foo when -foo=bar is a valid option but -foo-bar isn't
])
return super().compile(code, extra_args, **kwargs)
ret = super().compiles(code, env, extra_args=extra_args, dependencies=dependencies, mode=mode, disable_cache=disable_cache) # type: ignore
return T.cast(T.Tuple[bool, bool], ret)
def get_toolset_version(self) -> T.Optional[str]:
# Avoid circular dependencies....

@ -24,7 +24,7 @@ modules = [
'mesonbuild/compilers/mixins/elbrus.py',
'mesonbuild/compilers/mixins/emscripten.py',
'mesonbuild/compilers/mixins/gnu.py',
# 'mesonbuild/compilers/mixins/intel.py',
'mesonbuild/compilers/mixins/intel.py',
# 'mesonbuild/coredata.py',
'mesonbuild/dependencies/boost.py',
'mesonbuild/dependencies/hdf5.py',

Loading…
Cancel
Save