compilers: avoid importing compilers upfront for detect

We no longer need these upfront at all, since we now import the ones we
need for the language we are detecting, at the time of actual detection.

This avoids importing 28 files, consisting of just under 9,000 lines of
code, at interpreter startup. Now, it is only imported depending on
which languages are invoked by add_languages, which may not even be
anything. And even if we do end up importing a fair chunk of it for
C/C++ projects, spreading the import cost around the interpreter runtime
helps responsiveness.
pull/10810/head
Eli Schwartz 2 years ago
parent cc5ef6478f
commit ab20eb5bbc
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 116
      mesonbuild/compilers/detect.py

@ -20,118 +20,7 @@ from ..mesonlib import (
from ..envconfig import BinaryTable from ..envconfig import BinaryTable
from .. import mlog from .. import mlog
from ..linkers import ( from ..linkers import guess_win_linker, guess_nix_linker
guess_win_linker,
guess_nix_linker,
AIXArLinker,
AppleArLinker,
ArLinker,
ArmarLinker,
ArmClangDynamicLinker,
ArmDynamicLinker,
CcrxLinker,
CcrxDynamicLinker,
CompCertLinker,
CompCertDynamicLinker,
C2000Linker,
C2000DynamicLinker,
TILinker,
TIDynamicLinker,
DLinker,
NAGDynamicLinker,
NvidiaHPC_DynamicLinker,
PGIDynamicLinker,
PGIStaticLinker,
Xc16Linker,
Xc16DynamicLinker,
XilinkDynamicLinker,
CudaLinker,
IntelVisualStudioLinker,
VisualStudioLinker,
VisualStudioLikeLinkerMixin,
WASMDynamicLinker,
)
from .c import (
AppleClangCCompiler,
ArmCCompiler,
ArmclangCCompiler,
ArmLtdClangCCompiler,
ClangCCompiler,
ClangClCCompiler,
GnuCCompiler,
ElbrusCCompiler,
EmscriptenCCompiler,
IntelCCompiler,
IntelClCCompiler,
NvidiaHPC_CCompiler,
PGICCompiler,
CcrxCCompiler,
Xc16CCompiler,
CompCertCCompiler,
C2000CCompiler,
TICCompiler,
VisualStudioCCompiler,
)
from .cpp import (
AppleClangCPPCompiler,
ArmCPPCompiler,
ArmclangCPPCompiler,
ArmLtdClangCPPCompiler,
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 (
ArmLtdFlangFortranCompiler,
G95FortranCompiler,
GnuFortranCompiler,
ElbrusFortranCompiler,
FlangFortranCompiler,
IntelFortranCompiler,
IntelClFortranCompiler,
NAGFortranCompiler,
Open64FortranCompiler,
PathScaleFortranCompiler,
NvidiaHPC_FortranCompiler,
PGIFortranCompiler,
SunFortranCompiler,
)
from .java import JavaCompiler
from .objc import (
AppleClangObjCCompiler,
ClangObjCCompiler,
GnuObjCCompiler,
)
from .objcpp import (
AppleClangObjCPPCompiler,
ClangObjCPPCompiler,
GnuObjCPPCompiler,
)
from .cython import CythonCompiler
from .rust import RustCompiler, ClippyRustCompiler
from .swift import SwiftCompiler
from .vala import ValaCompiler
from .mixins.visualstudio import VisualStudioLikeCompiler
from .mixins.gnu import GnuCompiler
from .mixins.clang import ClangCompiler
import subprocess import subprocess
import platform import platform
@ -146,8 +35,7 @@ if T.TYPE_CHECKING:
from .c import CCompiler from .c import CCompiler
from .cpp import CPPCompiler from .cpp import CPPCompiler
from .fortran import FortranCompiler from .fortran import FortranCompiler
from .objc import ObjCCompiler from .rust import RustCompiler
from .objcpp import ObjCPPCompiler
from ..linkers import StaticLinker from ..linkers import StaticLinker
from ..environment import Environment from ..environment import Environment
from ..programs import ExternalProgram from ..programs import ExternalProgram

Loading…
Cancel
Save