diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index c4861ff12..6ab2bef7e 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -39,15 +39,34 @@ if T.TYPE_CHECKING: ) from ..interpreter.type_checking import PkgConfigDefineType + _MissingCompilerBase = Compiler +else: + _MissingCompilerBase = object + class DependencyException(MesonException): '''Exceptions raised while trying to find dependencies''' -class MissingCompiler: +class MissingCompiler(_MissingCompilerBase): """Represent a None Compiler - when no tool chain is found. replacing AttributeError with DependencyException""" + # These are needed in type checking mode to avoid errors, but we don't want + # the extra overhead at runtime + if T.TYPE_CHECKING: + def __init__(self) -> None: + pass + + def get_optimization_args(self, optimization_level: str) -> T.List[str]: + return [] + + def get_output_args(self, outputname: str) -> T.List[str]: + return [] + + def sanity_check(self, work_dir: str, environment: 'Environment') -> None: + return None + def __getattr__(self, item: str) -> T.Any: if item.startswith('__'): raise AttributeError()