Made native build work again.

pull/15/head
Jussi Pakkanen 11 years ago
parent 6780050cbf
commit 4b9d873b03
  1. 3
      backends.py
  2. 37
      environment.py

@ -453,7 +453,10 @@ class NinjaBackend(Backend):
name = t.get_name() name = t.get_name()
fname = os.path.join(self.environment.get_build_dir(), self.get_target_filename(t.get_exe())) fname = os.path.join(self.environment.get_build_dir(), self.get_target_filename(t.get_exe()))
is_cross = self.environment.is_cross_build() is_cross = self.environment.is_cross_build()
if is_cross:
exe_wrapper = self.environment.cross_info.get('exe_wrapper', None) exe_wrapper = self.environment.cross_info.get('exe_wrapper', None)
else:
exe_wrapper = None
arr.append([name, fname, is_cross, exe_wrapper]) arr.append([name, fname, is_cross, exe_wrapper])
pickle.dump(arr, datafile) pickle.dump(arr, datafile)

@ -289,8 +289,8 @@ void bar() {
return self.compiles(templ % (prefix, typename, membername)) return self.compiles(templ % (prefix, typename, membername))
class CPPCompiler(CCompiler): class CPPCompiler(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 = 'cpp' self.language = 'cpp'
self.default_suffix = 'cpp' self.default_suffix = 'cpp'
@ -533,8 +533,8 @@ class GnuCPPCompiler(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_wrap):
CPPCompiler.__init__(self, exelist) CPPCompiler.__init__(self, exelist, is_cross, exe_wrap)
self.id = 'gcc' self.id = 'gcc'
def get_std_warn_flags(self): def get_std_warn_flags(self):
@ -787,15 +787,15 @@ class Environment():
continue continue
out = p.communicate()[0] out = p.communicate()[0]
out = out.decode() out = out.decode()
if 'gcc' in out and \ if (out.startswith('cc') or 'gcc' in out) and \
'Free Software Foundation' in out: 'Free Software Foundation' in out:
return GnuCCompiler(ccache + [compiler], is_cross, exe_wrap) return GnuCCompiler(ccache + [compiler], 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 GnuCCompiler(ccache + [compiler]) return GnuCCompiler(ccache + [compiler], is_cross, exe_wrap)
if (out.startswith('clang')): if (out.startswith('clang')):
return ClangCCompiler(ccache + [compiler]) return ClangCCompiler(ccache + [compiler], is_cross, exe_wrap)
if 'Microsoft' in out: if 'Microsoft' in out:
return VisualStudioCCompiler([compiler]) return VisualStudioCCompiler([compiler], is_cross, exe_wrap)
raise EnvironmentException('Unknown compiler(s): "' + ', '.join(compilers) + '"') raise EnvironmentException('Unknown compiler(s): "' + ', '.join(compilers) + '"')
def get_scratch_dir(self): def get_scratch_dir(self):
@ -807,12 +807,21 @@ class Environment():
def detect_cpp_compiler(self): def detect_cpp_compiler(self):
evar = 'CXX' evar = 'CXX'
if evar in os.environ: if self.is_cross_build():
compilers = [self.cross_info['cpp']]
ccache = []
is_cross = True
exe_wrap = self.cross_info.get('exe_wrapper', None)
elif evar in os.environ:
compilers = os.environ[evar].split() compilers = os.environ[evar].split()
ccache = [] ccache = []
is_cross = False
exe_wrap = None
else: else:
compilers = self.default_cpp compilers = self.default_cpp
ccache = self.detect_ccache() ccache = self.detect_ccache()
is_cross = False
exe_wrap = None
for compiler in compilers: for compiler in compilers:
basename = os.path.basename(compiler).lower() basename = os.path.basename(compiler).lower()
if basename == 'cl' or basename == 'cl.exe': if basename == 'cl' or basename == 'cl.exe':
@ -827,15 +836,15 @@ class Environment():
continue continue
out = p.communicate()[0] out = p.communicate()[0]
out = out.decode() out = out.decode()
if (out.startswith('c++ ') or out.startswith('g++')) and \ if (out.startswith('c++ ') or out.startswith('g++') or 'GCC' in out) and \
'Free Software Foundation' in out: 'Free Software Foundation' in out:
return GnuCPPCompiler(ccache + [compiler]) return GnuCPPCompiler(ccache + [compiler], 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 GnuCPPCompiler(ccache + [compiler]) return GnuCPPCompiler(ccache + [compiler], is_cross, exe_wrap)
if out.startswith('clang'): if out.startswith('clang'):
return ClangCPPCompiler(ccache + [compiler]) return ClangCPPCompiler(ccache + [compiler], is_cross, exe_wrap)
if 'Microsoft' in out: if 'Microsoft' in out:
return VisualStudioCPPCompiler([compiler]) return VisualStudioCPPCompiler([compiler], is_cross, exe_wrap)
raise EnvironmentException('Unknown compiler(s) "' + ', '.join(compilers) + '"') raise EnvironmentException('Unknown compiler(s) "' + ', '.join(compilers) + '"')
def detect_objc_compiler(self): def detect_objc_compiler(self):

Loading…
Cancel
Save