diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-09-21 10:38:17 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-09-24 12:14:13 -0700 |
commit | 2c0fbe161d61d2d15d29892456544442ab1c4ff6 (patch) | |
tree | 18eea4af185465640f29727a3761e3b1af5c36fc | |
parent | 1592b7a800c3b109a1b502bfb03f4e21827da334 (diff) | |
download | meson-2c0fbe161d61d2d15d29892456544442ab1c4ff6.zip meson-2c0fbe161d61d2d15d29892456544442ab1c4ff6.tar.gz meson-2c0fbe161d61d2d15d29892456544442ab1c4ff6.tar.bz2 |
compilers: make is_cross part of the base Compiler class
Every class needs to set this, so it should be part of the base. For
classes that require is_cross, the positional argument remains in their
signature. For those that don't, they just allow the base class to set
their value to it's default of False.
-rw-r--r-- | mesonbuild/compilers/c.py | 4 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 3 | ||||
-rw-r--r-- | mesonbuild/compilers/cpp.py | 4 | ||||
-rw-r--r-- | mesonbuild/compilers/cs.py | 1 | ||||
-rw-r--r-- | mesonbuild/compilers/d.py | 26 | ||||
-rw-r--r-- | mesonbuild/compilers/fortran.py | 6 | ||||
-rw-r--r-- | mesonbuild/compilers/java.py | 1 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 3 | ||||
-rw-r--r-- | mesonbuild/compilers/objc.py | 4 | ||||
-rw-r--r-- | mesonbuild/compilers/objcpp.py | 4 | ||||
-rw-r--r-- | mesonbuild/compilers/rust.py | 5 | ||||
-rw-r--r-- | mesonbuild/compilers/swift.py | 5 | ||||
-rw-r--r-- | mesonbuild/compilers/vala.py | 5 | ||||
-rw-r--r-- | mesonbuild/environment.py | 3 |
14 files changed, 36 insertions, 38 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 3c58f3fd..091a000 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -56,8 +56,8 @@ class CCompiler(CLikeCompiler, Compiler): def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', exe_wrapper: T.Optional[str] = None, **kwargs): # If a child ObjC or CPP class has already set it, don't set it ourselves - Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) - CLikeCompiler.__init__(self, is_cross, exe_wrapper) + Compiler.__init__(self, exelist, version, for_machine, info, is_cross=is_cross, **kwargs) + CLikeCompiler.__init__(self, exe_wrapper) def get_no_stdinc_args(self): return ['-nostdinc'] diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 44922eb..b1a572f 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -456,7 +456,7 @@ class Compiler(metaclass=abc.ABCMeta): def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, info: 'MachineInfo', linker: T.Optional['DynamicLinker'] = None, - full_version: T.Optional[str] = None): + full_version: T.Optional[str] = None, is_cross: bool = False): self.exelist = exelist # In case it's been overridden by a child class already if not hasattr(self, 'file_suffixes'): @@ -470,6 +470,7 @@ class Compiler(metaclass=abc.ABCMeta): self.base_options = [] # type: T.List[str] self.linker = linker self.info = info + self.is_cross = is_cross def __repr__(self) -> str: repr_str = "<{0}: v{1} `{2}`>" diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 3a27e7a..b5dbdda 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -65,8 +65,8 @@ class CPPCompiler(CLikeCompiler, Compiler): def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', exe_wrap: T.Optional[str] = None, **kwargs): # If a child ObjCPP class has already set it, don't set it ourselves - Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) - CLikeCompiler.__init__(self, is_cross, exe_wrap) + Compiler.__init__(self, exelist, version, for_machine, info, is_cross=is_cross, **kwargs) + CLikeCompiler.__init__(self, exe_wrap) @staticmethod def get_display_language(): diff --git a/mesonbuild/compilers/cs.py b/mesonbuild/compilers/cs.py index cc5d6ad..b269aec 100644 --- a/mesonbuild/compilers/cs.py +++ b/mesonbuild/compilers/cs.py @@ -40,7 +40,6 @@ class CsCompiler(BasicLinkerIsCompilerMixin, Compiler): info: 'MachineInfo', comp_id, runner=None): super().__init__(exelist, version, for_machine, info) self.id = comp_id - self.is_cross = False self.runner = runner @classmethod diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index dd6129e..ca7f80d 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -30,6 +30,7 @@ from .compilers import ( from .mixins.gnu import GnuCompiler if T.TYPE_CHECKING: + from ..dependencies import ExternalProgram from ..envconfig import MachineInfo d_feature_args = {'gcc': {'unittest': '-funittest', @@ -442,13 +443,13 @@ class DCompiler(Compiler): language = 'd' - def __init__(self, exelist, version, for_machine: MachineChoice, - info: 'MachineInfo', arch, is_cross, exe_wrapper, **kwargs): + def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, + info: 'MachineInfo', arch: str, exe_wrapper: T.Optional['ExternalProgram'] = None, + **kwargs): super().__init__(exelist, version, for_machine, info, **kwargs) self.id = 'unknown' self.arch = arch self.exe_wrapper = exe_wrapper - self.is_cross = is_cross def sanity_check(self, work_dir, environment): source_name = os.path.join(work_dir, 'sanity.d') @@ -639,9 +640,10 @@ class GnuDCompiler(GnuCompiler, DCompiler): # we mostly want DCompiler, but that gives us the Compiler.LINKER_PREFIX instead LINKER_PREFIX = GnuCompiler.LINKER_PREFIX - def __init__(self, exelist, version, for_machine: MachineChoice, - info: 'MachineInfo', is_cross, exe_wrapper, arch, **kwargs): - DCompiler.__init__(self, exelist, version, for_machine, info, is_cross, exe_wrapper, arch, **kwargs) + def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, + info: 'MachineInfo', arch: str, *, exe_wrapper: T.Optional['ExternalProgram'] = None, + **kwargs): + DCompiler.__init__(self, exelist, version, for_machine, info, arch, exe_wrapper=exe_wrapper, **kwargs) GnuCompiler.__init__(self, {}) self.id = 'gcc' default_warn_args = ['-Wall', '-Wdeprecated'] @@ -695,9 +697,9 @@ class GnuDCompiler(GnuCompiler, DCompiler): class LLVMDCompiler(DmdLikeCompilerMixin, DCompiler): - def __init__(self, exelist, version, for_machine: MachineChoice, - info: 'MachineInfo', arch, **kwargs): - DCompiler.__init__(self, exelist, version, for_machine, info, arch, False, None, **kwargs) + def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, + info: 'MachineInfo', arch: str, **kwargs): + DCompiler.__init__(self, exelist, version, for_machine, info, arch, **kwargs) self.id = 'llvm' self.base_options = ['b_coverage', 'b_colorout', 'b_vscrt', 'b_ndebug'] @@ -747,9 +749,9 @@ class LLVMDCompiler(DmdLikeCompilerMixin, DCompiler): class DmdDCompiler(DmdLikeCompilerMixin, DCompiler): - def __init__(self, exelist, version, for_machine: MachineChoice, - info: 'MachineInfo', arch, **kwargs): - DCompiler.__init__(self, exelist, version, for_machine, info, arch, False, None, **kwargs) + def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, + info: 'MachineInfo', arch: str, **kwargs): + DCompiler.__init__(self, exelist, version, for_machine, info, arch, **kwargs) self.id = 'dmd' self.base_options = ['b_coverage', 'b_colorout', 'b_vscrt', 'b_ndebug'] diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index e928a04..9c2f5bf 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -44,9 +44,9 @@ class FortranCompiler(CLikeCompiler, Compiler): language = 'fortran' def __init__(self, exelist, version, for_machine: MachineChoice, - is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): - Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) - CLikeCompiler.__init__(self, is_cross, exe_wrapper) + is_cross: bool, info: 'MachineInfo', exe_wrapper=None, **kwargs): + Compiler.__init__(self, exelist, version, for_machine, info, is_cross=is_cross, **kwargs) + CLikeCompiler.__init__(self, exe_wrapper) self.id = 'unknown' def has_function(self, funcname, prefix, env, *, extra_args=None, dependencies=None): diff --git a/mesonbuild/compilers/java.py b/mesonbuild/compilers/java.py index 2c0b340..8405b43 100644 --- a/mesonbuild/compilers/java.py +++ b/mesonbuild/compilers/java.py @@ -32,7 +32,6 @@ class JavaCompiler(BasicLinkerIsCompilerMixin, Compiler): info: 'MachineInfo'): super().__init__(exelist, version, for_machine, info) self.id = 'unknown' - self.is_cross = False self.javarunner = 'java' def get_werror_args(self): diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index c92aac8..3baef50 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -160,9 +160,8 @@ class CLikeCompiler: find_framework_cache = {} # type: T.Dict[T.Tuple[T.Tuple[str, ...], str, T.Tuple[str, ...], bool], T.Optional[T.List[str]]] internal_libs = arglist.UNIXY_COMPILER_INTERNAL_LIBS - def __init__(self, is_cross: bool, exe_wrapper: T.Optional['ExternalProgram'] = None): + def __init__(self, exe_wrapper: T.Optional['ExternalProgram'] = None): # If a child ObjC or CPP class has already set it, don't set it ourselves - self.is_cross = is_cross self.can_compile_suffixes.add('h') # If the exe wrapper was not found, pretend it wasn't set so that the # sanity check is skipped and compiler checks use fallbacks. diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py index 254a609..142084e 100644 --- a/mesonbuild/compilers/objc.py +++ b/mesonbuild/compilers/objc.py @@ -33,8 +33,8 @@ class ObjCCompiler(CLikeCompiler, Compiler): def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', exe_wrap: T.Optional[str], **kwargs): - Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) - CLikeCompiler.__init__(self, is_cross, exe_wrap) + Compiler.__init__(self, exelist, version, for_machine, info, is_cross=is_cross, **kwargs) + CLikeCompiler.__init__(self, exe_wrap) @staticmethod def get_display_language(): diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index 3197abc..033c73a 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -32,8 +32,8 @@ class ObjCPPCompiler(CLikeCompiler, Compiler): def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', exe_wrap: T.Optional[str], **kwargs): - Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) - CLikeCompiler.__init__(self, is_cross, exe_wrap) + Compiler.__init__(self, exelist, version, for_machine, info, is_cross=is_cross, **kwargs) + CLikeCompiler.__init__(self, exe_wrap) @staticmethod def get_display_language(): diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index dd036a3..baa7272 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -36,11 +36,10 @@ class RustCompiler(Compiler): language = 'rust' def __init__(self, exelist, version, for_machine: MachineChoice, - is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): - super().__init__(exelist, version, for_machine, info, **kwargs) + is_cross: bool, info: 'MachineInfo', exe_wrapper=None, **kwargs): + super().__init__(exelist, version, for_machine, info, is_cross=is_cross, **kwargs) self.exe_wrapper = exe_wrapper self.id = 'rustc' - self.is_cross = is_cross def needs_static_linker(self): return False diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py index f753133..55f2761 100644 --- a/mesonbuild/compilers/swift.py +++ b/mesonbuild/compilers/swift.py @@ -36,11 +36,10 @@ class SwiftCompiler(Compiler): language = 'swift' def __init__(self, exelist, version, for_machine: MachineChoice, - is_cross, info: 'MachineInfo', **kwargs): - super().__init__(exelist, version, for_machine, info, **kwargs) + is_cross: bool, info: 'MachineInfo', **kwargs): + super().__init__(exelist, version, for_machine, info, is_cross=is_cross, **kwargs) self.version = version self.id = 'llvm' - self.is_cross = is_cross def needs_static_linker(self): return True diff --git a/mesonbuild/compilers/vala.py b/mesonbuild/compilers/vala.py index dc28c31..f31a294 100644 --- a/mesonbuild/compilers/vala.py +++ b/mesonbuild/compilers/vala.py @@ -28,10 +28,9 @@ class ValaCompiler(Compiler): language = 'vala' def __init__(self, exelist, version, for_machine: MachineChoice, - is_cross, info: 'MachineInfo'): - super().__init__(exelist, version, for_machine, info) + is_cross: bool, info: 'MachineInfo'): + super().__init__(exelist, version, for_machine, info, is_cross=is_cross) self.version = version - self.is_cross = is_cross self.id = 'valac' self.base_options = ['b_colorout'] diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 4623049..5a4b2ac 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -1821,7 +1821,8 @@ class Environment: elif 'gdc' in out: linker = self._guess_nix_linker(exelist, compilers.GnuDCompiler, for_machine) return compilers.GnuDCompiler( - exelist, version, for_machine, info, arch, is_cross, exe_wrap, + exelist, version, for_machine, info, arch, + exe_wrapper=exe_wrap, is_cross=is_cross, full_version=full_version, linker=linker) elif 'The D Language Foundation' in out or 'Digital Mars' in out: # DMD seems to require a file |