diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index fb7a179a1..cbfa3ec47 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -435,7 +435,7 @@ class Environment: def detect_fortran_compiler(self, want_cross): evar = 'FC' if self.is_cross_build() and want_cross: - compilers = [self.cross_info['fortran']] + compilers = meson.stringlistify(self.cross_info['fortran']) is_cross = True if self.cross_info.need_exe_wrapper(): exe_wrap = self.cross_info.get('exe_wrapper', None) @@ -451,46 +451,48 @@ class Environment: exe_wrap = None popen_exceptions = {} for compiler in compilers: + if not isinstance(compiler, list): + compiler = [compiler] for arg in ['--version', '-V']: 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 'GNU Fortran' 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 GnuFortranCompiler([compiler], version, gtype, is_cross, exe_wrap, defines) + return GnuFortranCompiler(compiler, version, gtype, is_cross, exe_wrap, defines) if 'G95' in out: - return G95FortranCompiler([compiler], version, is_cross, exe_wrap) + return G95FortranCompiler(compiler, version, is_cross, exe_wrap) if 'Sun Fortran' in err: version = search_version(err) - return SunFortranCompiler([compiler], version, is_cross, exe_wrap) + return SunFortranCompiler(compiler, version, is_cross, exe_wrap) if 'ifort (IFORT)' in out: - return IntelFortranCompiler([compiler], version, is_cross, exe_wrap) + return IntelFortranCompiler(compiler, version, is_cross, exe_wrap) if 'PathScale EKOPath(tm)' in err: - return PathScaleFortranCompiler([compiler], version, is_cross, exe_wrap) + return PathScaleFortranCompiler(compiler, version, is_cross, exe_wrap) if 'PGI Compilers' in out: - return PGIFortranCompiler([compiler], version, is_cross, exe_wrap) + return PGIFortranCompiler(compiler, version, is_cross, exe_wrap) if 'Open64 Compiler Suite' in err: - return Open64FortranCompiler([compiler], version, is_cross, exe_wrap) + return Open64FortranCompiler(compiler, version, is_cross, exe_wrap) if 'NAG Fortran' in err: - return NAGFortranCompiler([compiler], version, is_cross, exe_wrap) - errmsg = 'Unknown compiler(s): "' + ', '.join(compilers) + '"' + return NAGFortranCompiler(compiler, version, 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(): @@ -515,7 +517,7 @@ class Environment: else: exe_wrap = [] elif evar in os.environ: - compilers = os.environ[evar].split() + compilers = shlex.split(os.environ[evar]) ccache = [] is_cross = False exe_wrap = None @@ -569,7 +571,7 @@ class Environment: def detect_objc_compiler(self, want_cross): if self.is_cross_build() and want_cross: - exelist = [self.cross_info['objc']] + exelist = mesonlib.stringlistify(self.cross_info['objc']) is_cross = True if self.cross_info.need_exe_wrapper(): exe_wrap = self.cross_info.get('exe_wrapper', None) @@ -594,7 +596,7 @@ class Environment: def detect_objcpp_compiler(self, want_cross): if self.is_cross_build() and want_cross: - exelist = [self.cross_info['objcpp']] + exelist = mesonlib.stringlistify(self.cross_info['objcpp']) is_cross = True if self.cross_info.need_exe_wrapper(): exe_wrap = self.cross_info.get('exe_wrapper', None) @@ -667,9 +669,9 @@ class Environment: # environment variable because LDC has a much more # up to date language version at time (2016). if 'DC' in os.environ: - exelist = os.environ['DC'].split() + exelist = shlex.split(os.environ['DC']) elif self.is_cross_build() and want_cross: - exelist = [self.cross_info.config['binaries']['d']] + exelist = mesonlib.stringlistify(self.cross_info.config['binaries']['d']) is_cross = True elif shutil.which("ldc2"): exelist = ['ldc2']