compilers: directly import from subpackages

It turns out we don't generally need to proxy every compiler ever
through the top-level package. The number of times we directly poke at
one is negligible and direct imports are pretty clean.
pull/10810/head
Eli Schwartz 2 years ago
parent 0a9048e554
commit 5bfab845d0
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 4
      mesonbuild/dependencies/dev.py
  2. 3
      mesonbuild/dependencies/dub.py
  3. 8
      mesonbuild/linkers/linkers.py
  4. 2
      mesonbuild/modules/cuda.py
  5. 9
      run_tests.py

@ -27,7 +27,9 @@ import typing as T
from mesonbuild.interpreterbase.decorators import FeatureDeprecated from mesonbuild.interpreterbase.decorators import FeatureDeprecated
from .. import mesonlib, mlog from .. import mesonlib, mlog
from ..compilers import AppleClangCCompiler, AppleClangCPPCompiler, detect_compiler_for from ..compilers.c import AppleClangCCompiler
from ..compilers.cpp import AppleClangCPPCompiler
from ..compilers.detect import detect_compiler_for
from ..environment import get_llvm_tool_names from ..environment import get_llvm_tool_names
from ..mesonlib import version_compare, stringlistify, extract_as_list from ..mesonlib import version_compare, stringlistify, extract_as_list
from .base import DependencyException, DependencyMethods, strip_system_libdirs, SystemDependency, ExternalDependency, DependencyTypeName from .base import DependencyException, DependencyMethods, strip_system_libdirs, SystemDependency, ExternalDependency, DependencyTypeName

@ -17,8 +17,7 @@ from .pkgconfig import PkgConfigDependency
from ..mesonlib import (Popen_safe, OptionKey) from ..mesonlib import (Popen_safe, OptionKey)
from ..mesonlib.universal import join_args from ..mesonlib.universal import join_args
from ..programs import ExternalProgram from ..programs import ExternalProgram
from ..compilers import DCompiler from ..compilers.d import DCompiler, d_feature_args
from ..compilers.d import d_feature_args
from .. import mlog from .. import mlog
import re import re
import os import os

@ -137,12 +137,12 @@ class VisualStudioLikeLinker:
@classmethod @classmethod
def unix_args_to_native(cls, args: T.List[str]) -> T.List[str]: def unix_args_to_native(cls, args: T.List[str]) -> T.List[str]:
from ..compilers import VisualStudioCCompiler from ..compilers.c import VisualStudioCCompiler
return VisualStudioCCompiler.unix_args_to_native(args) return VisualStudioCCompiler.unix_args_to_native(args)
@classmethod @classmethod
def native_args_to_unix(cls, args: T.List[str]) -> T.List[str]: def native_args_to_unix(cls, args: T.List[str]) -> T.List[str]:
from ..compilers import VisualStudioCCompiler from ..compilers.c import VisualStudioCCompiler
return VisualStudioCCompiler.native_args_to_unix(args) return VisualStudioCCompiler.native_args_to_unix(args)
def rsp_file_syntax(self) -> RSPFileSyntax: def rsp_file_syntax(self) -> RSPFileSyntax:
@ -1126,7 +1126,7 @@ class NAGDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
return [] return []
def get_std_shared_lib_args(self) -> T.List[str]: def get_std_shared_lib_args(self) -> T.List[str]:
from ..compilers import NAGFortranCompiler from ..compilers.fortran import NAGFortranCompiler
return NAGFortranCompiler.get_nagfor_quiet(self.version) + ['-Wl,-shared'] return NAGFortranCompiler.get_nagfor_quiet(self.version) + ['-Wl,-shared']
@ -1495,7 +1495,7 @@ class CudaLinker(PosixDynamicLinkerMixin, DynamicLinker):
# #
# nvcc fatal : Don't know what to do with 'subprojects/foo/libbar.so.0.1.2' # nvcc fatal : Don't know what to do with 'subprojects/foo/libbar.so.0.1.2'
# #
from ..compilers import CudaCompiler from ..compilers.cuda import CudaCompiler
return CudaCompiler.LINKER_PREFIX return CudaCompiler.LINKER_PREFIX
def fatal_warnings(self) -> T.List[str]: def fatal_warnings(self) -> T.List[str]:

@ -17,7 +17,7 @@ import typing as T
import re import re
from ..mesonlib import version_compare from ..mesonlib import version_compare
from ..compilers import CudaCompiler from ..compilers.cuda import CudaCompiler
from . import NewExtensionModule, ModuleInfo from . import NewExtensionModule, ModuleInfo

@ -34,7 +34,8 @@ from pathlib import Path
from unittest import mock from unittest import mock
import typing as T import typing as T
from mesonbuild import compilers from mesonbuild.compilers.c import CCompiler
from mesonbuild.compilers.detect import detect_c_compiler
from mesonbuild import dependencies from mesonbuild import dependencies
from mesonbuild import mesonlib from mesonbuild import mesonlib
from mesonbuild import mesonmain from mesonbuild import mesonmain
@ -160,7 +161,7 @@ def get_convincing_fake_env_and_cc(bdir, prefix):
Useful for running compiler checks in the unit tests. Useful for running compiler checks in the unit tests.
''' '''
env = get_fake_env('', bdir, prefix) env = get_fake_env('', bdir, prefix)
cc = compilers.detect_c_compiler(env, mesonlib.MachineChoice.HOST) cc = detect_c_compiler(env, mesonlib.MachineChoice.HOST)
# Detect machine info # Detect machine info
env.machines.host = detect_machine_info({'c':cc}) env.machines.host = detect_machine_info({'c':cc})
return (env, cc) return (env, cc)
@ -290,8 +291,8 @@ def run_mtest_inprocess(commandlist: T.List[str]) -> T.Tuple[int, str, str]:
return returncode, stdout.getvalue() return returncode, stdout.getvalue()
def clear_meson_configure_class_caches() -> None: def clear_meson_configure_class_caches() -> None:
compilers.CCompiler.find_library_cache = {} CCompiler.find_library_cache = {}
compilers.CCompiler.find_framework_cache = {} CCompiler.find_framework_cache = {}
dependencies.PkgConfigDependency.pkgbin_cache = {} dependencies.PkgConfigDependency.pkgbin_cache = {}
dependencies.PkgConfigDependency.class_pkgbin = mesonlib.PerMachine(None, None) dependencies.PkgConfigDependency.class_pkgbin = mesonlib.PerMachine(None, None)
mesonlib.project_meson_versions = collections.defaultdict(str) mesonlib.project_meson_versions = collections.defaultdict(str)

Loading…
Cancel
Save