diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py index bd30b9bbc..b46c8f60d 100644 --- a/mesonbuild/compilers/__init__.py +++ b/mesonbuild/compilers/__init__.py @@ -106,7 +106,6 @@ __all__ = [ 'VisualStudioLikeCompiler', 'VisualStudioCCompiler', 'VisualStudioCPPCompiler', - 'CLikeCompiler', 'CythonCompiler', ] @@ -213,5 +212,4 @@ from .mixins.visualstudio import VisualStudioLikeCompiler from .mixins.gnu import GnuCompiler, GnuLikeCompiler from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler from .mixins.clang import ClangCompiler -from .mixins.clike import CLikeCompiler from .cython import CythonCompiler diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index cdb9f1c70..19288ebc3 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -586,6 +586,9 @@ class Compiler(metaclass=abc.ABCMeta): def get_linker_output_args(self, outputname: str) -> T.List[str]: return self.linker.get_output_args(outputname) + def get_linker_search_args(self, dirname: str) -> T.List[str]: + return self.linker.get_search_args(dirname) + def get_builtin_define(self, define: str) -> T.Optional[str]: raise EnvironmentException('%s does not support get_builtin_define.' % self.id) @@ -1051,6 +1054,22 @@ class Compiler(metaclass=abc.ABCMeta): elf_class: T.Optional[int] = None) -> T.List[str]: return [] + def get_return_value(self, + fname: str, + rtype: str, + prefix: str, + env: 'Environment', + extra_args: T.Optional[T.List[str]], + dependencies: T.Optional[T.List['Dependency']]) -> T.Union[str, int]: + raise EnvironmentException(f'{self.id} does not support get_return_value') + + def find_framework(self, + name: str, + env: 'Environment', + extra_dirs: T.List[str], + allow_system: bool = True) -> T.Optional[T.List[str]]: + raise EnvironmentException(f'{self.id} does not support find_framework') + def find_framework_paths(self, env: 'Environment') -> T.List[str]: raise EnvironmentException(f'{self.id} does not support find_framework_paths') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 6daa77849..3210dd7f3 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -273,9 +273,6 @@ class CLikeCompiler(Compiler): 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) -> T.List[str]: - return self.linker.get_search_args(dirname) - def get_default_include_dirs(self) -> T.List[str]: return [] diff --git a/mesonbuild/dependencies/cuda.py b/mesonbuild/dependencies/cuda.py index bea479397..42fdb0929 100644 --- a/mesonbuild/dependencies/cuda.py +++ b/mesonbuild/dependencies/cuda.py @@ -285,8 +285,6 @@ class CudaDependency(ExternalDependency): def get_link_args(self, language: T.Optional[str] = None, raw: bool = False) -> T.List[str]: args = [] if self.libdir: - from ..compilers import CLikeCompiler - assert isinstance(self.clib_compiler, CLikeCompiler) args += self.clib_compiler.get_linker_search_args(self.libdir) for lib in self.requested_modules: args += self.lib_modules[lib] diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index 9c1d9325b..397ad0cda 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -31,7 +31,7 @@ from .configtool import ConfigToolDependency from .pkgconfig import PkgConfigDependency from .factory import DependencyFactory from .misc import threads_factory -from ..compilers import AppleClangCCompiler, AppleClangCPPCompiler, CLikeCompiler +from ..compilers import AppleClangCCompiler, AppleClangCPPCompiler if T.TYPE_CHECKING: from ..envconfig import MachineInfo @@ -261,7 +261,6 @@ class LLVMDependencyConfigTool(ConfigToolDependency): new_args.append(arg.lstrip('-l')) elif arg.startswith('-LIBPATH:'): cpp = self.env.coredata.compilers[self.for_machine]['cpp'] - assert isinstance(cpp, CLikeCompiler) new_args.extend(cpp.get_linker_search_args(arg.lstrip('-LIBPATH:'))) else: new_args.append(arg) diff --git a/mesonbuild/dependencies/framework.py b/mesonbuild/dependencies/framework.py index 152c14eb5..2ef33c8e9 100644 --- a/mesonbuild/dependencies/framework.py +++ b/mesonbuild/dependencies/framework.py @@ -14,7 +14,6 @@ from .base import ExternalDependency, DependencyException, DependencyMethods from ..mesonlib import MesonException, Version, stringlistify -from ..compilers import CLikeCompiler from .. import mlog from pathlib import Path import typing as T @@ -31,7 +30,7 @@ class ExtraFrameworkDependency(ExternalDependency): self.name = name # Full path to framework directory self.framework_path: T.Optional[str] = None - if not isinstance(self.clib_compiler, CLikeCompiler): + if not self.clib_compiler: raise DependencyException('No C-like compilers are available') if self.system_framework_paths is None: try: @@ -64,7 +63,6 @@ class ExtraFrameworkDependency(ExternalDependency): # Python.framework. We need to know for sure that the framework was # found in the path we expect. allow_system = p in self.system_framework_paths - assert isinstance(self.clib_compiler, CLikeCompiler) args = self.clib_compiler.find_framework(name, self.env, [p], allow_system) if args is None: continue diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 79afb411b..1dadb514c 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -23,7 +23,6 @@ import typing as T from .. import mlog from .. import mesonlib from ..environment import detect_cpu_family -from ..compilers import CLikeCompiler from .base import DependencyException, DependencyMethods, ExternalDependency from .cmake import CMakeDependency @@ -300,7 +299,6 @@ class PcapDependencyConfigTool(ConfigToolDependency): if not self.env.machines.matches_build_machine(self.for_machine): return None - assert isinstance(self.clib_compiler, CLikeCompiler) v = self.clib_compiler.get_return_value('pcap_lib_version', 'string', '#include ', self.env, [], [self]) v = re.sub(r'libpcap version ', '', str(v)) diff --git a/mesonbuild/dependencies/platform.py b/mesonbuild/dependencies/platform.py index 8c2853913..816e32f33 100644 --- a/mesonbuild/dependencies/platform.py +++ b/mesonbuild/dependencies/platform.py @@ -17,7 +17,6 @@ from .base import ExternalDependency, DependencyException from ..mesonlib import MesonException -from ..compilers import CLikeCompiler import typing as T if T.TYPE_CHECKING: @@ -37,7 +36,6 @@ class AppleFrameworks(ExternalDependency): self.is_found = True for f in self.frameworks: try: - assert isinstance(self.clib_compiler, CLikeCompiler) args = self.clib_compiler.find_framework(f, env, []) except MesonException as e: if 'non-clang' in str(e):