diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-08-21 13:12:30 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-10-07 12:08:20 -0700 |
commit | 0c22798b1ad4678abb205280060175678a790c4a (patch) | |
tree | e58a51d87bffe1ecd6437f85adc0adefbed469d6 /mesonbuild/compilers/c.py | |
parent | ff4a17dbef08a1d8afd075f57dbab0f5c76951ab (diff) | |
download | meson-0c22798b1ad4678abb205280060175678a790c4a.zip meson-0c22798b1ad4678abb205280060175678a790c4a.tar.gz meson-0c22798b1ad4678abb205280060175678a790c4a.tar.bz2 |
compilers: replace CompilerType with MachineInfo
Now that the linkers are split out of the compilers this enum is
only used to know what platform we're compiling for. Which is
what the MachineInfo class is for
Diffstat (limited to 'mesonbuild/compilers/c.py')
-rw-r--r-- | mesonbuild/compilers/c.py | 106 |
1 files changed, 68 insertions, 38 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 7b5d3cc..1bf03bd 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -32,9 +32,11 @@ from .compilers import ( gnu_winlibs, msvc_winlibs, Compiler, - CompilerType, ) +if typing.TYPE_CHECKING: + from ..envconfig import MachineInfo + class CCompiler(CLikeCompiler, Compiler): @@ -46,10 +48,10 @@ class CCompiler(CLikeCompiler, Compiler): raise MesonException('Unknown function attribute "{}"'.format(name)) def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool, - exe_wrapper: typing.Optional[str] = None, **kwargs): + info: 'MachineInfo', exe_wrapper: typing.Optional[str] = None, **kwargs): # If a child ObjC or CPP class has already set it, don't set it ourselves self.language = 'c' - Compiler.__init__(self, exelist, version, for_machine, **kwargs) + Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) CLikeCompiler.__init__(self, is_cross, exe_wrapper) def get_no_stdinc_args(self): @@ -79,9 +81,10 @@ class ClangCCompiler(ClangCompiler, CCompiler): _C17_VERSION = '>=10.0.0' _C18_VERSION = '>=11.0.0' - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs): - CCompiler.__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): + CCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, **kwargs) + ClangCompiler.__init__(self) default_warn_args = ['-Wall', '-Winvalid-pch'] self.warn_args = {'0': [], '1': default_warn_args, @@ -119,7 +122,7 @@ class ClangCCompiler(ClangCompiler, CCompiler): class AppleClangCCompiler(ClangCCompiler): """Handle the differences between Apple Clang and Vanilla Clang. - + Right now this just handles the differences between the versions that new C standards were added. """ @@ -129,10 +132,12 @@ class AppleClangCCompiler(ClangCCompiler): class EmscriptenCCompiler(LinkerEnvVarsMixin, BasicLinkerIsCompilerMixin, ClangCCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs): + def __init__(self, exelist, version, for_machine: MachineChoice, + info: 'MachineInfo', is_cross, exe_wrapper=None, **kwargs): if not is_cross: raise MesonException('Emscripten compiler can only be used for cross compilation.') - ClangCCompiler.__init__(self, exelist, version, compiler_type, for_machine, is_cross, exe_wrapper, **kwargs) + ClangCCompiler.__init__(self, exelist, version, for_machine, + is_cross, info, exe_wrapper, **kwargs) self.id = 'emscripten' def get_option_link_args(self, options): @@ -142,9 +147,11 @@ class EmscriptenCCompiler(LinkerEnvVarsMixin, BasicLinkerIsCompilerMixin, ClangC raise MesonException('Emscripten does not support shared libraries.') class ArmclangCCompiler(ArmclangCompiler, CCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs): - CCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrapper, **kwargs) - ArmclangCompiler.__init__(self, compiler_type) + def __init__(self, exelist, version, for_machine: MachineChoice, + info: 'MachineInfo', is_cross, exe_wrapper=None, **kwargs): + CCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrapper, **kwargs) + ArmclangCompiler.__init__(self) default_warn_args = ['-Wall', '-Winvalid-pch'] self.warn_args = {'0': [], '1': default_warn_args, @@ -171,9 +178,12 @@ class ArmclangCCompiler(ArmclangCompiler, CCompiler): class GnuCCompiler(GnuCompiler, CCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, defines=None, **kwargs): - CCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrapper, **kwargs) - GnuCompiler.__init__(self, compiler_type, defines) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, + defines=None, **kwargs): + CCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrapper, **kwargs) + GnuCompiler.__init__(self, defines) default_warn_args = ['-Wall', '-Winvalid-pch'] self.warn_args = {'0': [], '1': default_warn_args, @@ -191,7 +201,7 @@ class GnuCCompiler(GnuCompiler, CCompiler): opts.update({'c_std': coredata.UserComboOption('C language standard to use', ['none'] + c_stds + g_stds, 'none')}) - if self.compiler_type.is_windows_compiler: + if self.info.is_windows() or self.info.is_cygwin(): opts.update({ 'c_winlibs': coredata.UserArrayOption('Standard Win libraries to link against', gnu_winlibs), }) @@ -205,7 +215,7 @@ class GnuCCompiler(GnuCompiler, CCompiler): 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['c_winlibs'].value[:] return [] @@ -214,15 +224,19 @@ class GnuCCompiler(GnuCompiler, CCompiler): class PGICCompiler(PGICompiler, CCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs): - CCompiler.__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): + CCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrapper, **kwargs) + PGICompiler.__init__(self) class ElbrusCCompiler(GnuCCompiler, ElbrusCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, defines=None, **kwargs): - GnuCCompiler.__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): + GnuCCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrapper, defines, **kwargs) + ElbrusCompiler.__init__(self, defines) # It does support some various ISO standards and c/gnu 90, 9x, 1x in addition to those which GNU CC supports. def get_options(self): @@ -246,9 +260,11 @@ class ElbrusCCompiler(GnuCCompiler, ElbrusCompiler): class IntelCCompiler(IntelGnuLikeCompiler, CCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs): - CCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrapper, **kwargs) - IntelGnuLikeCompiler.__init__(self, compiler_type) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): + CCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrapper, **kwargs) + IntelGnuLikeCompiler.__init__(self) self.lang_header = 'c-header' default_warn_args = ['-Wall', '-w3', '-diag-disable:remark'] self.warn_args = {'0': [], @@ -288,16 +304,23 @@ class VisualStudioLikeCCompilerMixin: def get_option_link_args(self, options): return options['c_winlibs'].value[:] + class VisualStudioCCompiler(VisualStudioLikeCompiler, VisualStudioLikeCCompilerMixin, CCompiler): - def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, exe_wrap, target: str, **kwargs): - CCompiler.__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: str, + **kwargs): + CCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrap, **kwargs) VisualStudioLikeCompiler.__init__(self, target) self.id = 'msvc' + class ClangClCCompiler(VisualStudioLikeCompiler, VisualStudioLikeCCompilerMixin, CCompiler): - def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, exe_wrap, target, **kwargs): - CCompiler.__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): + CCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrap, **kwargs) VisualStudioLikeCompiler.__init__(self, target) self.id = 'clang-cl' @@ -308,8 +331,10 @@ class IntelClCCompiler(IntelVisualStudioLikeCompiler, VisualStudioLikeCCompilerM __have_warned = False - def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, exe_wrap, target, **kwargs): - CCompiler.__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): + CCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrap, **kwargs) IntelVisualStudioLikeCompiler.__init__(self, target) def get_options(self): @@ -333,9 +358,11 @@ class IntelClCCompiler(IntelVisualStudioLikeCompiler, VisualStudioLikeCCompilerM class ArmCCompiler(ArmCompiler, CCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs): - CCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrapper, **kwargs) - ArmCompiler.__init__(self, compiler_type) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): + CCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrapper, **kwargs) + ArmCompiler.__init__(self) def get_options(self): opts = CCompiler.get_options(self) @@ -351,10 +378,13 @@ class ArmCCompiler(ArmCompiler, CCompiler): args.append('--' + std.value) return args + class CcrxCCompiler(CcrxCompiler, CCompiler): - def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs): - CCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrapper, **kwargs) - CcrxCompiler.__init__(self, compiler_type) + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): + CCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrapper, **kwargs) + CcrxCompiler.__init__(self) # Override CCompiler.get_always_args def get_always_args(self): |