|
|
@ -370,9 +370,7 @@ class Environment: |
|
|
|
def detect_c_compiler(self, want_cross): |
|
|
|
def detect_c_compiler(self, want_cross): |
|
|
|
evar = 'CC' |
|
|
|
evar = 'CC' |
|
|
|
if self.is_cross_build() and want_cross: |
|
|
|
if self.is_cross_build() and want_cross: |
|
|
|
compilers = self.cross_info.config['binaries']['c'] |
|
|
|
compilers = mesonlib.stringintlistify(self.cross_info.config['binaries']['c']) |
|
|
|
if not isinstance(compilers, list): |
|
|
|
|
|
|
|
compilers = [compilers] |
|
|
|
|
|
|
|
ccache = [] |
|
|
|
ccache = [] |
|
|
|
is_cross = True |
|
|
|
is_cross = True |
|
|
|
if self.cross_info.need_exe_wrapper(): |
|
|
|
if self.cross_info.need_exe_wrapper(): |
|
|
@ -391,41 +389,43 @@ class Environment: |
|
|
|
exe_wrap = None |
|
|
|
exe_wrap = None |
|
|
|
popen_exceptions = {} |
|
|
|
popen_exceptions = {} |
|
|
|
for compiler in compilers: |
|
|
|
for compiler in compilers: |
|
|
|
|
|
|
|
if isinstance(compiler, str): |
|
|
|
|
|
|
|
compiler = [compiler] |
|
|
|
try: |
|
|
|
try: |
|
|
|
basename = os.path.basename(compiler).lower() |
|
|
|
basename = os.path.basename(compiler[-1]).lower() |
|
|
|
if basename == 'cl' or basename == 'cl.exe': |
|
|
|
if basename == 'cl' or basename == 'cl.exe': |
|
|
|
arg = '/?' |
|
|
|
arg = '/?' |
|
|
|
else: |
|
|
|
else: |
|
|
|
arg = '--version' |
|
|
|
arg = '--version' |
|
|
|
p, out, err = Popen_safe([compiler, arg]) |
|
|
|
p, out, err = Popen_safe(compiler + [arg]) |
|
|
|
except OSError as e: |
|
|
|
except OSError as e: |
|
|
|
popen_exceptions[' '.join([compiler, arg])] = e |
|
|
|
popen_exceptions[' '.join(compiler + [arg])] = e |
|
|
|
continue |
|
|
|
continue |
|
|
|
version = search_version(out) |
|
|
|
version = search_version(out) |
|
|
|
if 'Free Software Foundation' in out: |
|
|
|
if 'Free Software Foundation' in out: |
|
|
|
defines = self.get_gnu_compiler_defines([compiler]) |
|
|
|
defines = self.get_gnu_compiler_defines(compiler) |
|
|
|
if not defines: |
|
|
|
if not defines: |
|
|
|
popen_exceptions[compiler] = 'no pre-processor defines' |
|
|
|
popen_exceptions[compiler] = 'no pre-processor defines' |
|
|
|
continue |
|
|
|
continue |
|
|
|
gtype = self.get_gnu_compiler_type(defines) |
|
|
|
gtype = self.get_gnu_compiler_type(defines) |
|
|
|
version = self.get_gnu_version_from_defines(defines) |
|
|
|
version = self.get_gnu_version_from_defines(defines) |
|
|
|
return GnuCCompiler(ccache + compilers, version, gtype, is_cross, exe_wrap, defines) |
|
|
|
return GnuCCompiler(ccache + compiler, version, gtype, is_cross, exe_wrap, defines) |
|
|
|
if 'clang' in out: |
|
|
|
if 'clang' in out: |
|
|
|
if 'Apple' in out or for_darwin(want_cross, self): |
|
|
|
if 'Apple' in out or for_darwin(want_cross, self): |
|
|
|
cltype = CLANG_OSX |
|
|
|
cltype = CLANG_OSX |
|
|
|
else: |
|
|
|
else: |
|
|
|
cltype = CLANG_STANDARD |
|
|
|
cltype = CLANG_STANDARD |
|
|
|
return ClangCCompiler(ccache + compilers, version, cltype, is_cross, exe_wrap) |
|
|
|
return ClangCCompiler(ccache + compiler, version, cltype, is_cross, exe_wrap) |
|
|
|
if 'Microsoft' in out or 'Microsoft' in err: |
|
|
|
if 'Microsoft' in out or 'Microsoft' in err: |
|
|
|
# Visual Studio prints version number to stderr but |
|
|
|
# Visual Studio prints version number to stderr but |
|
|
|
# everything else to stdout. Why? Lord only knows. |
|
|
|
# everything else to stdout. Why? Lord only knows. |
|
|
|
version = search_version(err) |
|
|
|
version = search_version(err) |
|
|
|
return VisualStudioCCompiler([compiler], version, is_cross, exe_wrap) |
|
|
|
return VisualStudioCCompiler(compiler, version, is_cross, exe_wrap) |
|
|
|
if '(ICC)' in out: |
|
|
|
if '(ICC)' in out: |
|
|
|
# TODO: add microsoft add check OSX |
|
|
|
# TODO: add microsoft add check OSX |
|
|
|
inteltype = ICC_STANDARD |
|
|
|
inteltype = ICC_STANDARD |
|
|
|
return IntelCCompiler(ccache + compilers, version, inteltype, is_cross, exe_wrap) |
|
|
|
return IntelCCompiler(ccache + compiler, version, inteltype, is_cross, exe_wrap) |
|
|
|
errmsg = 'Unknown compiler(s): "' + ', '.join(compilers) + '"' |
|
|
|
errmsg = 'Unknown compiler(s): ' + str(compilers) |
|
|
|
if popen_exceptions: |
|
|
|
if popen_exceptions: |
|
|
|
errmsg += '\nThe follow exceptions were encountered:' |
|
|
|
errmsg += '\nThe follow exceptions were encountered:' |
|
|
|
for (c, e) in popen_exceptions.items(): |
|
|
|
for (c, e) in popen_exceptions.items(): |
|
|
@ -507,7 +507,7 @@ class Environment: |
|
|
|
def detect_cpp_compiler(self, want_cross): |
|
|
|
def detect_cpp_compiler(self, want_cross): |
|
|
|
evar = 'CXX' |
|
|
|
evar = 'CXX' |
|
|
|
if self.is_cross_build() and want_cross: |
|
|
|
if self.is_cross_build() and want_cross: |
|
|
|
compilers = [self.cross_info.config['binaries']['cpp']] |
|
|
|
compilers = mesonlib.stringlistify(self.cross_info.config['binaries']['cpp']) |
|
|
|
ccache = [] |
|
|
|
ccache = [] |
|
|
|
is_cross = True |
|
|
|
is_cross = True |
|
|
|
if self.cross_info.need_exe_wrapper(): |
|
|
|
if self.cross_info.need_exe_wrapper(): |
|
|
@ -526,38 +526,40 @@ class Environment: |
|
|
|
exe_wrap = None |
|
|
|
exe_wrap = None |
|
|
|
popen_exceptions = {} |
|
|
|
popen_exceptions = {} |
|
|
|
for compiler in compilers: |
|
|
|
for compiler in compilers: |
|
|
|
basename = os.path.basename(compiler).lower() |
|
|
|
if isinstance(compiler, str): |
|
|
|
|
|
|
|
compiler = [compiler] |
|
|
|
|
|
|
|
basename = os.path.basename(compiler[-1]).lower() |
|
|
|
if basename == 'cl' or basename == 'cl.exe': |
|
|
|
if basename == 'cl' or basename == 'cl.exe': |
|
|
|
arg = '/?' |
|
|
|
arg = '/?' |
|
|
|
else: |
|
|
|
else: |
|
|
|
arg = '--version' |
|
|
|
arg = '--version' |
|
|
|
try: |
|
|
|
try: |
|
|
|
p, out, err = Popen_safe([compiler, arg]) |
|
|
|
p, out, err = Popen_safe(compiler + [arg]) |
|
|
|
except OSError as e: |
|
|
|
except OSError as e: |
|
|
|
popen_exceptions[' '.join([compiler, arg])] = e |
|
|
|
popen_exceptions[' '.join(compiler + [arg])] = e |
|
|
|
continue |
|
|
|
continue |
|
|
|
version = search_version(out) |
|
|
|
version = search_version(out) |
|
|
|
if 'Free Software Foundation' in out: |
|
|
|
if 'Free Software Foundation' in out: |
|
|
|
defines = self.get_gnu_compiler_defines([compiler]) |
|
|
|
defines = self.get_gnu_compiler_defines(compiler) |
|
|
|
if not defines: |
|
|
|
if not defines: |
|
|
|
popen_exceptions[compiler] = 'no pre-processor defines' |
|
|
|
popen_exceptions[compiler] = 'no pre-processor defines' |
|
|
|
continue |
|
|
|
continue |
|
|
|
gtype = self.get_gnu_compiler_type(defines) |
|
|
|
gtype = self.get_gnu_compiler_type(defines) |
|
|
|
version = self.get_gnu_version_from_defines(defines) |
|
|
|
version = self.get_gnu_version_from_defines(defines) |
|
|
|
return GnuCPPCompiler(ccache + [compiler], version, gtype, is_cross, exe_wrap, defines) |
|
|
|
return GnuCPPCompiler(ccache + compiler, version, gtype, is_cross, exe_wrap, defines) |
|
|
|
if 'clang' in out: |
|
|
|
if 'clang' in out: |
|
|
|
if 'Apple' in out: |
|
|
|
if 'Apple' in out: |
|
|
|
cltype = CLANG_OSX |
|
|
|
cltype = CLANG_OSX |
|
|
|
else: |
|
|
|
else: |
|
|
|
cltype = CLANG_STANDARD |
|
|
|
cltype = CLANG_STANDARD |
|
|
|
return ClangCPPCompiler(ccache + [compiler], version, cltype, is_cross, exe_wrap) |
|
|
|
return ClangCPPCompiler(ccache + compiler, version, cltype, is_cross, exe_wrap) |
|
|
|
if 'Microsoft' in out or 'Microsoft' in err: |
|
|
|
if 'Microsoft' in out or 'Microsoft' in err: |
|
|
|
version = search_version(err) |
|
|
|
version = search_version(err) |
|
|
|
return VisualStudioCPPCompiler([compiler], version, is_cross, exe_wrap) |
|
|
|
return VisualStudioCPPCompiler(compiler, version, is_cross, exe_wrap) |
|
|
|
if '(ICC)' in out: |
|
|
|
if '(ICC)' in out: |
|
|
|
# TODO: add microsoft add check OSX |
|
|
|
# TODO: add microsoft add check OSX |
|
|
|
inteltype = ICC_STANDARD |
|
|
|
inteltype = ICC_STANDARD |
|
|
|
return IntelCPPCompiler(ccache + [compiler], version, inteltype, is_cross, exe_wrap) |
|
|
|
return IntelCPPCompiler(ccache + compiler, version, inteltype, is_cross, exe_wrap) |
|
|
|
errmsg = 'Unknown compiler(s): "' + ', '.join(compilers) + '"' |
|
|
|
errmsg = 'Unknown compiler(s): "' + ', '.join(compilers) + '"' |
|
|
|
if popen_exceptions: |
|
|
|
if popen_exceptions: |
|
|
|
errmsg += '\nThe follow exceptions were encountered:' |
|
|
|
errmsg += '\nThe follow exceptions were encountered:' |
|
|
|