Fixed ObjC calls.

pull/15/head
Jussi Pakkanen 11 years ago
parent ed6baa31f6
commit 063bfed54e
  1. 52
      environment.py

@ -316,8 +316,8 @@ class CPPCompiler(CCompiler):
raise EnvironmentException('Executables created by C++ compiler %s are not runnable.' % self.name_string()) raise EnvironmentException('Executables created by C++ compiler %s are not runnable.' % self.name_string())
class ObjCCompiler(CCompiler): class ObjCCompiler(CCompiler):
def __init__(self, exelist): def __init__(self, exelist, is_cross, exe_wrap):
CCompiler.__init__(self, exelist) CCompiler.__init__(self, exelist, is_cross, exe_wrap)
self.language = 'objc' self.language = 'objc'
self.default_suffix = 'm' self.default_suffix = 'm'
@ -328,8 +328,8 @@ class ObjCCompiler(CCompiler):
return False return False
class ObjCPPCompiler(CPPCompiler): class ObjCPPCompiler(CPPCompiler):
def __init__(self, exelist): def __init__(self, exelist, is_cross, exe_wrap):
CPPCompiler.__init__(self, exelist) CPPCompiler.__init__(self, exelist, is_cross, exe_wrap)
self.language = 'objcpp' self.language = 'objcpp'
self.default_suffix = 'mm' self.default_suffix = 'mm'
@ -482,8 +482,8 @@ class GnuObjCCompiler(ObjCCompiler):
std_warn_flags = ['-Wall', '-Winvalid-pch'] std_warn_flags = ['-Wall', '-Winvalid-pch']
std_opt_flags = ['-O2'] std_opt_flags = ['-O2']
def __init__(self, exelist): def __init__(self, exelist, is_cross, exe_wrapper=None):
ObjCCompiler.__init__(self, exelist) ObjCCompiler.__init__(self, exelist, is_cross, exe_wrapper)
self.id = 'gcc' self.id = 'gcc'
def get_std_warn_flags(self): def get_std_warn_flags(self):
@ -499,8 +499,8 @@ class GnuObjCPPCompiler(ObjCPPCompiler):
std_warn_flags = ['-Wall', '-Winvalid-pch'] std_warn_flags = ['-Wall', '-Winvalid-pch']
std_opt_flags = ['-O2'] std_opt_flags = ['-O2']
def __init__(self, exelist): def __init__(self, exelist, is_cross, exe_wrapper=None):
ObjCCompiler.__init__(self, exelist) ObjCCompiler.__init__(self, exelist, is_cross, exe_wrapper)
self.id = 'gcc' self.id = 'gcc'
def get_std_warn_flags(self): def get_std_warn_flags(self):
@ -516,8 +516,8 @@ class ClangCCompiler(CCompiler):
std_warn_flags = ['-Wall', '-Winvalid-pch'] std_warn_flags = ['-Wall', '-Winvalid-pch']
std_opt_flags = ['-O2'] std_opt_flags = ['-O2']
def __init__(self, exelist): def __init__(self, exelist, is_cross, exe_wrapper=None):
CCompiler.__init__(self, exelist) CCompiler.__init__(self, exelist, is_cross, exe_wrapper)
self.id = 'clang' self.id = 'clang'
def get_std_warn_flags(self): def get_std_warn_flags(self):
@ -550,8 +550,8 @@ class ClangCPPCompiler(CPPCompiler):
std_warn_flags = ['-Wall', '-Winvalid-pch'] std_warn_flags = ['-Wall', '-Winvalid-pch']
std_opt_flags = ['-O2'] std_opt_flags = ['-O2']
def __init__(self, exelist): def __init__(self, exelist, is_cross, exe_wrapper=None):
CPPCompiler.__init__(self, exelist) CPPCompiler.__init__(self, exelist, is_cross, exe_wrapper)
self.id = 'clang' self.id = 'clang'
def get_std_warn_flags(self): def get_std_warn_flags(self):
@ -851,22 +851,36 @@ class Environment():
raise EnvironmentException('Unknown compiler(s) "' + ', '.join(compilers) + '"') raise EnvironmentException('Unknown compiler(s) "' + ', '.join(compilers) + '"')
def detect_objc_compiler(self): def detect_objc_compiler(self):
exelist = self.get_objc_compiler_exelist() if self.is_cross_build():
exelist = [self.cross_info['objc']]
is_cross = True
exe_wrap = self.cross_info.get('exe_wrapper', None)
else:
exelist = self.get_objc_compiler_exelist()
is_cross = False
exe_wrap = None
try: try:
p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE) p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE)
except OSError: except OSError:
raise EnvironmentException('Could not execute ObjC compiler "%s"' % ' '.join(exelist)) raise EnvironmentException('Could not execute ObjC compiler "%s"' % ' '.join(exelist))
out = p.communicate()[0] out = p.communicate()[0]
out = out.decode() out = out.decode()
if (out.startswith('cc ') or out.startswith('gcc')) and \ if (out.startswith('cc ') or 'gcc' in out) and \
'Free Software Foundation' in out: 'Free Software Foundation' in out:
return GnuObjCCompiler(exelist) return GnuObjCCompiler(exelist, is_cross, exe_wrap)
if 'apple' in out and 'Free Software Foundation' in out: if 'apple' in out and 'Free Software Foundation' in out:
return GnuObjCCompiler(exelist) return GnuObjCCompiler(exelist, is_cross, exe_wrap)
raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"') raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"')
def detect_objcpp_compiler(self): def detect_objcpp_compiler(self):
exelist = self.get_objcpp_compiler_exelist() if self.is_cross_build():
exelist = [self.cross_info['objc']]
is_cross = True
exe_wrap = self.cross_info.get('exe_wrapper', None)
else:
exelist = self.get_objcpp_compiler_exelist()
is_cross = False
exe_wrap = None
try: try:
p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE) p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE)
except OSError: except OSError:
@ -875,9 +889,9 @@ class Environment():
out = out.decode() out = out.decode()
if (out.startswith('c++ ') or out.startswith('g++')) and \ if (out.startswith('c++ ') or out.startswith('g++')) and \
'Free Software Foundation' in out: 'Free Software Foundation' in out:
return GnuObjCPPCompiler(exelist) return GnuObjCPPCompiler(exelist, is_cross, exe_wrap)
if 'apple' in out and 'Free Software Foundation' in out: if 'apple' in out and 'Free Software Foundation' in out:
return GnuObjCPPCompiler(exelist) return GnuObjCPPCompiler(exelist, is_cross, exe_wrap)
raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"') raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"')
def detect_static_linker(self, compiler): def detect_static_linker(self, compiler):

Loading…
Cancel
Save