diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py index 034063a31..c516aab57 100644 --- a/mesonbuild/compilers/__init__.py +++ b/mesonbuild/compilers/__init__.py @@ -52,83 +52,6 @@ __all__ = [ 'detect_rust_compiler', 'detect_d_compiler', 'detect_swift_compiler', - - 'AppleClangCCompiler', - 'AppleClangCPPCompiler', - 'AppleClangObjCCompiler', - 'AppleClangObjCPPCompiler', - 'ArmCCompiler', - 'ArmCPPCompiler', - 'ArmclangCCompiler', - 'ArmclangCPPCompiler', - 'CCompiler', - 'ClangCCompiler', - 'ClangCompiler', - 'ClangCPPCompiler', - 'ClangObjCCompiler', - 'ClangObjCPPCompiler', - 'ClangClCCompiler', - 'ClangClCPPCompiler', - 'CPPCompiler', - 'DCompiler', - 'DmdDCompiler', - 'FortranCompiler', - 'G95FortranCompiler', - 'GnuCCompiler', - 'ElbrusCCompiler', - 'EmscriptenCCompiler', - 'GnuCompiler', - 'GnuLikeCompiler', - 'GnuCPPCompiler', - 'ElbrusCPPCompiler', - 'EmscriptenCPPCompiler', - 'GnuDCompiler', - 'GnuFortranCompiler', - 'ElbrusFortranCompiler', - 'FlangFortranCompiler', - 'GnuObjCCompiler', - 'GnuObjCPPCompiler', - 'IntelGnuLikeCompiler', - 'IntelVisualStudioLikeCompiler', - 'IntelCCompiler', - 'IntelCPPCompiler', - 'IntelClCCompiler', - 'IntelClCPPCompiler', - 'IntelFortranCompiler', - 'IntelClFortranCompiler', - 'JavaCompiler', - 'LLVMDCompiler', - 'MonoCompiler', - 'CudaCompiler', - 'VisualStudioCsCompiler', - 'NAGFortranCompiler', - 'ObjCCompiler', - 'ObjCPPCompiler', - 'Open64FortranCompiler', - 'PathScaleFortranCompiler', - 'NvidiaHPC_CCompiler', - 'NvidiaHPC_CPPCompiler', - 'NvidiaHPC_FortranCompiler', - 'PGICCompiler', - 'PGICPPCompiler', - 'PGIFortranCompiler', - 'RustCompiler', - 'ClippyRustCompiler', - 'CcrxCCompiler', - 'CcrxCPPCompiler', - 'Xc16CCompiler', - 'CompCertCCompiler', - 'C2000CCompiler', - 'C2000CPPCompiler', - 'TICCompiler', - 'TICPPCompiler', - 'SunFortranCompiler', - 'SwiftCompiler', - 'ValaCompiler', - 'VisualStudioLikeCompiler', - 'VisualStudioCCompiler', - 'VisualStudioCPPCompiler', - 'CythonCompiler', ] # Bring symbols from each module into compilers sub-package namespace @@ -172,87 +95,3 @@ from .detect import ( detect_d_compiler, detect_swift_compiler, ) -from .c import ( - CCompiler, - AppleClangCCompiler, - ArmCCompiler, - ArmclangCCompiler, - ClangCCompiler, - ClangClCCompiler, - GnuCCompiler, - ElbrusCCompiler, - EmscriptenCCompiler, - IntelCCompiler, - IntelClCCompiler, - NvidiaHPC_CCompiler, - PGICCompiler, - CcrxCCompiler, - Xc16CCompiler, - CompCertCCompiler, - C2000CCompiler, - TICCompiler, - VisualStudioCCompiler, -) -from .cpp import ( - CPPCompiler, - AppleClangCPPCompiler, - ArmCPPCompiler, - ArmclangCPPCompiler, - ClangCPPCompiler, - ClangClCPPCompiler, - GnuCPPCompiler, - ElbrusCPPCompiler, - EmscriptenCPPCompiler, - IntelCPPCompiler, - IntelClCPPCompiler, - NvidiaHPC_CPPCompiler, - PGICPPCompiler, - CcrxCPPCompiler, - C2000CPPCompiler, - TICPPCompiler, - VisualStudioCPPCompiler, -) -from .cs import MonoCompiler, VisualStudioCsCompiler -from .d import ( - DCompiler, - DmdDCompiler, - GnuDCompiler, - LLVMDCompiler, -) -from .cuda import CudaCompiler -from .fortran import ( - FortranCompiler, - G95FortranCompiler, - GnuFortranCompiler, - ElbrusFortranCompiler, - FlangFortranCompiler, - IntelFortranCompiler, - IntelClFortranCompiler, - NAGFortranCompiler, - Open64FortranCompiler, - PathScaleFortranCompiler, - NvidiaHPC_FortranCompiler, - PGIFortranCompiler, - SunFortranCompiler, -) -from .java import JavaCompiler -from .objc import ( - ObjCCompiler, - AppleClangObjCCompiler, - ClangObjCCompiler, - GnuObjCCompiler, -) -from .objcpp import ( - ObjCPPCompiler, - AppleClangObjCPPCompiler, - ClangObjCPPCompiler, - GnuObjCPPCompiler, -) -from .rust import RustCompiler, ClippyRustCompiler -from .swift import SwiftCompiler -from .vala import ValaCompiler -from .mixins.visualstudio import VisualStudioLikeCompiler -from .mixins.gnu import GnuCompiler, GnuLikeCompiler -from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler -from .mixins.clang import ClangCompiler -from .cython import CythonCompiler diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 7f0dd441c..34997ce8e 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -45,9 +45,12 @@ from mesonbuild.mesonlib import ( MesonException, EnvironmentException, OptionKey ) +from mesonbuild.compilers.mixins.clang import ClangCompiler +from mesonbuild.compilers.mixins.gnu import GnuCompiler +from mesonbuild.compilers.mixins.intel import IntelGnuLikeCompiler +from mesonbuild.compilers.c import VisualStudioCCompiler, ClangClCCompiler +from mesonbuild.compilers.cpp import VisualStudioCPPCompiler, ClangClCPPCompiler from mesonbuild.compilers import ( - GnuCompiler, ClangCompiler, IntelGnuLikeCompiler, VisualStudioCCompiler, - VisualStudioCPPCompiler, ClangClCCompiler, ClangClCPPCompiler, detect_static_linker, detect_c_compiler, compiler_from_language, detect_compiler_for ) diff --git a/unittests/internaltests.py b/unittests/internaltests.py index b87aae4b9..85815121b 100644 --- a/unittests/internaltests.py +++ b/unittests/internaltests.py @@ -32,11 +32,12 @@ import mesonbuild.mlog import mesonbuild.depfile import mesonbuild.dependencies.base import mesonbuild.dependencies.factory -import mesonbuild.compilers import mesonbuild.envconfig import mesonbuild.environment import mesonbuild.modules.gnome from mesonbuild import coredata +from mesonbuild.compilers.c import ClangCCompiler, GnuCCompiler +from mesonbuild.compilers.d import DmdDCompiler from mesonbuild.interpreterbase import typed_pos_args, InvalidArguments, ObjectHolder from mesonbuild.interpreterbase import typed_pos_args, InvalidArguments, typed_kwargs, ContainerTypeInfo, KwargInfo from mesonbuild.mesonlib import ( @@ -116,7 +117,7 @@ class InternalTests(unittest.TestCase): stat.S_IRGRP | stat.S_IXGRP) def test_compiler_args_class_none_flush(self): - cc = mesonbuild.compilers.ClangCCompiler([], 'fake', MachineChoice.HOST, False, mock.Mock()) + cc = ClangCCompiler([], 'fake', MachineChoice.HOST, False, mock.Mock()) a = cc.compiler_args(['-I.']) #first we are checking if the tree construction deduplicates the correct -I argument a += ['-I..'] @@ -133,14 +134,14 @@ class InternalTests(unittest.TestCase): self.assertEqual(a, ['-I.', '-I./tests2/', '-I./tests/', '-I..']) def test_compiler_args_class_d(self): - d = mesonbuild.compilers.DmdDCompiler([], 'fake', MachineChoice.HOST, 'info', 'arch') + d = DmdDCompiler([], 'fake', MachineChoice.HOST, 'info', 'arch') # check include order is kept when deduplicating a = d.compiler_args(['-Ifirst', '-Isecond', '-Ithird']) a += ['-Ifirst'] self.assertEqual(a, ['-Ifirst', '-Isecond', '-Ithird']) def test_compiler_args_class_clike(self): - cc = mesonbuild.compilers.ClangCCompiler([], 'fake', MachineChoice.HOST, False, mock.Mock()) + cc = ClangCCompiler([], 'fake', MachineChoice.HOST, False, mock.Mock()) # Test that empty initialization works a = cc.compiler_args() self.assertEqual(a, []) @@ -222,7 +223,7 @@ class InternalTests(unittest.TestCase): def test_compiler_args_class_gnuld(self): ## Test --start/end-group linker = mesonbuild.linkers.GnuBFDDynamicLinker([], MachineChoice.HOST, '-Wl,', []) - gcc = mesonbuild.compilers.GnuCCompiler([], 'fake', False, MachineChoice.HOST, mock.Mock(), linker=linker) + gcc = GnuCCompiler([], 'fake', False, MachineChoice.HOST, mock.Mock(), linker=linker) ## Ensure that the fake compiler is never called by overriding the relevant function gcc.get_default_include_dirs = lambda: ['/usr/include', '/usr/share/include', '/usr/local/include'] ## Test that 'direct' append and extend works @@ -250,7 +251,7 @@ class InternalTests(unittest.TestCase): def test_compiler_args_remove_system(self): ## Test --start/end-group linker = mesonbuild.linkers.GnuBFDDynamicLinker([], MachineChoice.HOST, '-Wl,', []) - gcc = mesonbuild.compilers.GnuCCompiler([], 'fake', False, MachineChoice.HOST, mock.Mock(), linker=linker) + gcc = GnuCCompiler([], 'fake', False, MachineChoice.HOST, mock.Mock(), linker=linker) ## Ensure that the fake compiler is never called by overriding the relevant function gcc.get_default_include_dirs = lambda: ['/usr/include', '/usr/share/include', '/usr/local/include'] ## Test that 'direct' append and extend works diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py index d7d657d27..69e4c6f74 100644 --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -40,9 +40,11 @@ from mesonbuild.mesonlib import ( ) from mesonbuild.compilers import ( detect_c_compiler, detect_cpp_compiler, compiler_from_language, - AppleClangCCompiler, AppleClangCPPCompiler, AppleClangObjCCompiler, - AppleClangObjCPPCompiler ) +from mesonbuild.compilers.c import AppleClangCCompiler +from mesonbuild.compilers.cpp import AppleClangCPPCompiler +from mesonbuild.compilers.objc import AppleClangObjCCompiler +from mesonbuild.compilers.objcpp import AppleClangObjCPPCompiler from mesonbuild.dependencies import PkgConfigDependency import mesonbuild.modules.pkgconfig