aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-09-11 19:07:09 -0400
committerEli Schwartz <eschwartz@archlinux.org>2022-09-19 15:19:00 -0400
commit5bfab845d0bc2414e5323d2a59d6c357808c02ea (patch)
tree9941a3c2702cd542fb582d2e7426e788fbddfb6b
parent0a9048e5546c17a926fd199ded798fba0f76b036 (diff)
downloadmeson-5bfab845d0bc2414e5323d2a59d6c357808c02ea.zip
meson-5bfab845d0bc2414e5323d2a59d6c357808c02ea.tar.gz
meson-5bfab845d0bc2414e5323d2a59d6c357808c02ea.tar.bz2
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.
-rw-r--r--mesonbuild/dependencies/dev.py4
-rw-r--r--mesonbuild/dependencies/dub.py3
-rw-r--r--mesonbuild/linkers/linkers.py8
-rw-r--r--mesonbuild/modules/cuda.py2
-rwxr-xr-xrun_tests.py9
5 files changed, 14 insertions, 12 deletions
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
index 08c9280..bf9ba2b 100644
--- a/mesonbuild/dependencies/dev.py
+++ b/mesonbuild/dependencies/dev.py
@@ -27,7 +27,9 @@ import typing as T
from mesonbuild.interpreterbase.decorators import FeatureDeprecated
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 ..mesonlib import version_compare, stringlistify, extract_as_list
from .base import DependencyException, DependencyMethods, strip_system_libdirs, SystemDependency, ExternalDependency, DependencyTypeName
diff --git a/mesonbuild/dependencies/dub.py b/mesonbuild/dependencies/dub.py
index 0680141..cad4aad 100644
--- a/mesonbuild/dependencies/dub.py
+++ b/mesonbuild/dependencies/dub.py
@@ -17,8 +17,7 @@ from .pkgconfig import PkgConfigDependency
from ..mesonlib import (Popen_safe, OptionKey)
from ..mesonlib.universal import join_args
from ..programs import ExternalProgram
-from ..compilers import DCompiler
-from ..compilers.d import d_feature_args
+from ..compilers.d import DCompiler, d_feature_args
from .. import mlog
import re
import os
diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py
index 5b7f69e..30f41af 100644
--- a/mesonbuild/linkers/linkers.py
+++ b/mesonbuild/linkers/linkers.py
@@ -137,12 +137,12 @@ class VisualStudioLikeLinker:
@classmethod
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)
@classmethod
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)
def rsp_file_syntax(self) -> RSPFileSyntax:
@@ -1126,7 +1126,7 @@ class NAGDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
return []
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']
@@ -1495,7 +1495,7 @@ class CudaLinker(PosixDynamicLinkerMixin, DynamicLinker):
#
# 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
def fatal_warnings(self) -> T.List[str]:
diff --git a/mesonbuild/modules/cuda.py b/mesonbuild/modules/cuda.py
index df9dba8..0e33984 100644
--- a/mesonbuild/modules/cuda.py
+++ b/mesonbuild/modules/cuda.py
@@ -17,7 +17,7 @@ import typing as T
import re
from ..mesonlib import version_compare
-from ..compilers import CudaCompiler
+from ..compilers.cuda import CudaCompiler
from . import NewExtensionModule, ModuleInfo
diff --git a/run_tests.py b/run_tests.py
index fcd9337..ead5865 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -34,7 +34,8 @@ from pathlib import Path
from unittest import mock
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 mesonlib
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.
'''
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
env.machines.host = detect_machine_info({'c':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()
def clear_meson_configure_class_caches() -> None:
- compilers.CCompiler.find_library_cache = {}
- compilers.CCompiler.find_framework_cache = {}
+ CCompiler.find_library_cache = {}
+ CCompiler.find_framework_cache = {}
dependencies.PkgConfigDependency.pkgbin_cache = {}
dependencies.PkgConfigDependency.class_pkgbin = mesonlib.PerMachine(None, None)
mesonlib.project_meson_versions = collections.defaultdict(str)