diff options
Diffstat (limited to 'mesonbuild/compilers/cpp.py')
-rw-r--r-- | mesonbuild/compilers/cpp.py | 101 |
1 files changed, 66 insertions, 35 deletions
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index f93db3e..2b3b162 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -38,6 +38,9 @@ from .mixins.elbrus import ElbrusCompiler from .mixins.pgi import PGICompiler from .mixins.islinker import BasicLinkerIsCompilerMixin, LinkerEnvVarsMixin +if typing.TYPE_CHECKING: + from ..envconfig import MachineInfo + def non_msvc_eh_options(eh, args): if eh == 'none': @@ -56,10 +59,10 @@ class CPPCompiler(CLikeCompiler, Compiler): raise MesonException('Unknown function attribute "{}"'.format(name)) def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool, - exe_wrap: typing.Optional[str] = None, **kwargs): + info: 'MachineInfo', exe_wrap: typing.Optional[str] = None, **kwargs): # If a child ObjCPP class has already set it, don't set it ourselves self.language = 'cpp' - Compiler.__init__(self, exelist, version, for_machine, **kwargs) + Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) CLikeCompiler.__init__(self, is_cross, exe_wrap) def get_display_language(self): @@ -147,9 +150,11 @@ class CPPCompiler(CLikeCompiler, Compiler): class ClangCPPCompiler(ClangCompiler, CPPCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs): - CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrapper, **kwargs) - ClangCompiler.__init__(self, compiler_type) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): + CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrapper, **kwargs) + ClangCompiler.__init__(self) default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] self.warn_args = {'0': [], '1': default_warn_args, @@ -184,11 +189,18 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler): return ['-lstdc++'] +class AppleClangCPPCompiler(ClangCPPCompiler): + + pass + + class EmscriptenCPPCompiler(LinkerEnvVarsMixin, BasicLinkerIsCompilerMixin, ClangCPPCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs): + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): if not is_cross: raise MesonException('Emscripten compiler can only be used for cross compilation.') - ClangCPPCompiler.__init__(self, exelist, version, compiler_type, for_machine, is_cross, exe_wrapper, **kwargs) + ClangCPPCompiler.__init__(self, exelist, version, for_machine, + is_cross, info, exe_wrapper, **kwargs) self.id = 'emscripten' def get_option_compile_args(self, options): @@ -206,9 +218,10 @@ class EmscriptenCPPCompiler(LinkerEnvVarsMixin, BasicLinkerIsCompilerMixin, Clan class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs): + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrapper, **kwargs) - ArmclangCompiler.__init__(self, compiler_type) + ArmclangCompiler.__init__(self) default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] self.warn_args = {'0': [], '1': default_warn_args, @@ -241,9 +254,10 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler): class GnuCPPCompiler(GnuCompiler, CPPCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrap, defines, **kwargs): - CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrap, **kwargs) - GnuCompiler.__init__(self, compiler_type, defines) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrap, defines, **kwargs): + CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrap, **kwargs) + GnuCompiler.__init__(self, defines) default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] self.warn_args = {'0': [], '1': default_warn_args, @@ -261,7 +275,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): 'none'), 'cpp_debugstl': coredata.UserBooleanOption('STL debug mode', False)}) - if self.compiler_type.is_windows_compiler: + if self.info.is_windows() or self.info.is_cygwin(): opts.update({ 'cpp_winlibs': coredata.UserArrayOption('Standard Win libraries to link against', gnu_winlibs), }) @@ -280,7 +294,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): return args def get_option_link_args(self, options): - if self.compiler_type.is_windows_compiler: + if self.info.is_windows() or self.info.is_cygwin(): return options['cpp_winlibs'].value[:] return [] @@ -292,14 +306,20 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): class PGICPPCompiler(PGICompiler, CPPCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs): - CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrapper, **kwargs) - PGICompiler.__init__(self, compiler_type) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): + CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, **kwargs) + PGICompiler.__init__(self) + class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, defines=None, **kwargs): - GnuCPPCompiler.__init__(self, exelist, version, compiler_type, for_machine, is_cross, exe_wrapper, defines, **kwargs) - ElbrusCompiler.__init__(self, compiler_type, defines) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, + defines=None, **kwargs): + GnuCPPCompiler.__init__(self, exelist, version, for_machine, + is_cross, info, exe_wrapper, defines, + **kwargs) + ElbrusCompiler.__init__(self, defines) # It does not support c++/gnu++ 17 and 1z, but still does support 0x, 1y, and gnu++98. def get_options(self): @@ -327,9 +347,11 @@ class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler): class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrap, **kwargs): - CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrap, **kwargs) - IntelGnuLikeCompiler.__init__(self, compiler_type) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrap, **kwargs): + CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrap, **kwargs) + IntelGnuLikeCompiler.__init__(self) self.lang_header = 'c++-header' default_warn_args = ['-Wall', '-w3', '-diag-disable:remark', '-Wpch-messages', '-Wnon-virtual-dtor'] @@ -462,8 +484,9 @@ class CPP11AsCPP14Mixin: class VisualStudioCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixin, VisualStudioLikeCompiler, CPPCompiler): - def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool, exe_wrap, target, **kwargs): - CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrap, **kwargs) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross: bool, info: 'MachineInfo', exe_wrap, target, **kwargs): + CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrap, **kwargs) VisualStudioLikeCompiler.__init__(self, target) self.base_options = ['b_pch', 'b_vscrt'] # FIXME add lto, pgo and the like self.id = 'msvc' @@ -495,8 +518,10 @@ class VisualStudioCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixi return args class ClangClCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixin, VisualStudioLikeCompiler, CPPCompiler): - def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, exe_wrap, target, **kwargs): - CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrap, **kwargs) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrap, target, **kwargs): + CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrap, **kwargs) VisualStudioLikeCompiler.__init__(self, target) self.id = 'clang-cl' @@ -507,8 +532,10 @@ class ClangClCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixin, Vi class IntelClCPPCompiler(VisualStudioLikeCPPCompilerMixin, IntelVisualStudioLikeCompiler, CPPCompiler): - def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, exe_wrap, target, **kwargs): - CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrap, **kwargs) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrap, target, **kwargs): + CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrap, **kwargs) IntelVisualStudioLikeCompiler.__init__(self, target) def get_options(self): @@ -518,9 +545,11 @@ class IntelClCPPCompiler(VisualStudioLikeCPPCompilerMixin, IntelVisualStudioLike class ArmCPPCompiler(ArmCompiler, CPPCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrap=None, **kwargs): - CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrap, **kwargs) - ArmCompiler.__init__(self, compiler_type) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrap=None, **kwargs): + CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrap, **kwargs) + ArmCompiler.__init__(self) def get_options(self): opts = CPPCompiler.get_options(self) @@ -546,9 +575,11 @@ class ArmCPPCompiler(ArmCompiler, CPPCompiler): class CcrxCPPCompiler(CcrxCompiler, CPPCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrap=None, **kwargs): - CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrap, **kwargs) - CcrxCompiler.__init__(self, compiler_type) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrap=None, **kwargs): + CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrap, **kwargs) + CcrxCompiler.__init__(self) # Override CCompiler.get_always_args def get_always_args(self): |