compilers: Add Apple subclasses for ObjC and ObjC++
These are needed because in some cases we need to be able to know if we're using vanilla clang or Apple's clang.
This commit is contained in:
parent
7092efabb5
commit
b6c28d282c
|
@ -36,6 +36,8 @@ __all__ = [
|
||||||
|
|
||||||
'AppleClangCCompiler',
|
'AppleClangCCompiler',
|
||||||
'AppleClangCPPCompiler',
|
'AppleClangCPPCompiler',
|
||||||
|
'AppleClangObjCCompiler',
|
||||||
|
'AppleClangObjCPPCompiler',
|
||||||
'ArmCCompiler',
|
'ArmCCompiler',
|
||||||
'ArmCPPCompiler',
|
'ArmCPPCompiler',
|
||||||
'ArmclangCCompiler',
|
'ArmclangCCompiler',
|
||||||
|
@ -183,11 +185,13 @@ from .fortran import (
|
||||||
from .java import JavaCompiler
|
from .java import JavaCompiler
|
||||||
from .objc import (
|
from .objc import (
|
||||||
ObjCCompiler,
|
ObjCCompiler,
|
||||||
|
AppleClangObjCCompiler,
|
||||||
ClangObjCCompiler,
|
ClangObjCCompiler,
|
||||||
GnuObjCCompiler,
|
GnuObjCCompiler,
|
||||||
)
|
)
|
||||||
from .objcpp import (
|
from .objcpp import (
|
||||||
ObjCPPCompiler,
|
ObjCPPCompiler,
|
||||||
|
AppleClangObjCPPCompiler,
|
||||||
ClangObjCPPCompiler,
|
ClangObjCPPCompiler,
|
||||||
GnuObjCPPCompiler,
|
GnuObjCPPCompiler,
|
||||||
)
|
)
|
||||||
|
|
|
@ -92,3 +92,8 @@ class ClangObjCCompiler(ClangCompiler, ObjCCompiler):
|
||||||
'1': default_warn_args,
|
'1': default_warn_args,
|
||||||
'2': default_warn_args + ['-Wextra'],
|
'2': default_warn_args + ['-Wextra'],
|
||||||
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
|
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
|
||||||
|
|
||||||
|
|
||||||
|
class AppleClangObjCCompiler(ClangObjCCompiler):
|
||||||
|
|
||||||
|
"""Handle the differences between Apple's clang and vanilla clang."""
|
||||||
|
|
|
@ -90,3 +90,9 @@ class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler):
|
||||||
'1': default_warn_args,
|
'1': default_warn_args,
|
||||||
'2': default_warn_args + ['-Wextra'],
|
'2': default_warn_args + ['-Wextra'],
|
||||||
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
|
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class AppleClangObjCPPCompiler(ClangObjCPPCompiler):
|
||||||
|
|
||||||
|
"""Handle the differences between Apple's clang and vanilla clang."""
|
||||||
|
|
|
@ -74,6 +74,8 @@ from .compilers import (
|
||||||
ArmclangCPPCompiler,
|
ArmclangCPPCompiler,
|
||||||
AppleClangCCompiler,
|
AppleClangCCompiler,
|
||||||
AppleClangCPPCompiler,
|
AppleClangCPPCompiler,
|
||||||
|
AppleClangObjCCompiler,
|
||||||
|
AppleClangObjCPPCompiler,
|
||||||
ClangCCompiler,
|
ClangCCompiler,
|
||||||
ClangCPPCompiler,
|
ClangCPPCompiler,
|
||||||
ClangObjCCompiler,
|
ClangObjCCompiler,
|
||||||
|
@ -1506,7 +1508,7 @@ class Environment:
|
||||||
def detect_objcpp_compiler(self, for_machine: MachineInfo) -> 'Compiler':
|
def detect_objcpp_compiler(self, for_machine: MachineInfo) -> 'Compiler':
|
||||||
return self._detect_objc_or_objcpp_compiler(for_machine, False)
|
return self._detect_objc_or_objcpp_compiler(for_machine, False)
|
||||||
|
|
||||||
def _detect_objc_or_objcpp_compiler(self, for_machine: MachineInfo, objc: bool) -> 'Compiler':
|
def _detect_objc_or_objcpp_compiler(self, for_machine: MachineChoice, objc: bool) -> 'Compiler':
|
||||||
popen_exceptions = {}
|
popen_exceptions = {}
|
||||||
compilers, ccache, exe_wrap = self._get_compilers('objc' if objc else 'objcpp', for_machine)
|
compilers, ccache, exe_wrap = self._get_compilers('objc' if objc else 'objcpp', for_machine)
|
||||||
is_cross = self.is_cross_build(for_machine)
|
is_cross = self.is_cross_build(for_machine)
|
||||||
|
@ -1535,7 +1537,10 @@ class Environment:
|
||||||
exe_wrap, defines, linker=linker)
|
exe_wrap, defines, linker=linker)
|
||||||
if 'clang' in out:
|
if 'clang' in out:
|
||||||
linker = None
|
linker = None
|
||||||
comp = ClangObjCCompiler if objc else ClangObjCPPCompiler
|
if 'Apple' in out:
|
||||||
|
comp = AppleClangObjCCompiler if objc else AppleClangObjCPPCompiler
|
||||||
|
else:
|
||||||
|
comp = ClangObjCCompiler if objc else ClangObjCPPCompiler
|
||||||
if 'windows' in out or self.machines[for_machine].is_windows():
|
if 'windows' in out or self.machines[for_machine].is_windows():
|
||||||
# If we're in a MINGW context this actually will use a gnu style ld
|
# If we're in a MINGW context this actually will use a gnu style ld
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue