diff options
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r-- | mesonbuild/environment.py | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 13b38d5..fb7a179 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -370,9 +370,7 @@ class Environment: def detect_c_compiler(self, want_cross): evar = 'CC' if self.is_cross_build() and want_cross: - compilers = self.cross_info.config['binaries']['c'] - if not isinstance(compilers, list): - compilers = [compilers] + compilers = mesonlib.stringintlistify(self.cross_info.config['binaries']['c']) ccache = [] is_cross = True if self.cross_info.need_exe_wrapper(): @@ -391,41 +389,43 @@ class Environment: exe_wrap = None popen_exceptions = {} for compiler in compilers: + if isinstance(compiler, str): + compiler = [compiler] try: - basename = os.path.basename(compiler).lower() + basename = os.path.basename(compiler[-1]).lower() if basename == 'cl' or basename == 'cl.exe': arg = '/?' else: arg = '--version' - p, out, err = Popen_safe([compiler, arg]) + p, out, err = Popen_safe(compiler + [arg]) except OSError as e: - popen_exceptions[' '.join([compiler, arg])] = e + popen_exceptions[' '.join(compiler + [arg])] = e continue version = search_version(out) if 'Free Software Foundation' in out: - defines = self.get_gnu_compiler_defines([compiler]) + defines = self.get_gnu_compiler_defines(compiler) if not defines: popen_exceptions[compiler] = 'no pre-processor defines' continue gtype = self.get_gnu_compiler_type(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 'Apple' in out or for_darwin(want_cross, self): cltype = CLANG_OSX else: 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: # Visual Studio prints version number to stderr but # everything else to stdout. Why? Lord only knows. version = search_version(err) - return VisualStudioCCompiler([compiler], version, is_cross, exe_wrap) + return VisualStudioCCompiler(compiler, version, is_cross, exe_wrap) if '(ICC)' in out: # TODO: add microsoft add check OSX inteltype = ICC_STANDARD - return IntelCCompiler(ccache + compilers, version, inteltype, is_cross, exe_wrap) - errmsg = 'Unknown compiler(s): "' + ', '.join(compilers) + '"' + return IntelCCompiler(ccache + compiler, version, inteltype, is_cross, exe_wrap) + errmsg = 'Unknown compiler(s): ' + str(compilers) if popen_exceptions: errmsg += '\nThe follow exceptions were encountered:' for (c, e) in popen_exceptions.items(): @@ -507,7 +507,7 @@ class Environment: def detect_cpp_compiler(self, want_cross): evar = 'CXX' 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 = [] is_cross = True if self.cross_info.need_exe_wrapper(): @@ -526,38 +526,40 @@ class Environment: exe_wrap = None popen_exceptions = {} 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': arg = '/?' else: arg = '--version' try: - p, out, err = Popen_safe([compiler, arg]) + p, out, err = Popen_safe(compiler + [arg]) except OSError as e: - popen_exceptions[' '.join([compiler, arg])] = e + popen_exceptions[' '.join(compiler + [arg])] = e continue version = search_version(out) if 'Free Software Foundation' in out: - defines = self.get_gnu_compiler_defines([compiler]) + defines = self.get_gnu_compiler_defines(compiler) if not defines: popen_exceptions[compiler] = 'no pre-processor defines' continue gtype = self.get_gnu_compiler_type(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 'Apple' in out: cltype = CLANG_OSX else: 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: version = search_version(err) - return VisualStudioCPPCompiler([compiler], version, is_cross, exe_wrap) + return VisualStudioCPPCompiler(compiler, version, is_cross, exe_wrap) if '(ICC)' in out: # TODO: add microsoft add check OSX 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) + '"' if popen_exceptions: errmsg += '\nThe follow exceptions were encountered:' |