aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorThibault Saunier <thibault.saunier@osg.samsung.com>2017-08-25 15:16:17 -0300
committerJussi Pakkanen <jpakkane@gmail.com>2018-02-25 01:10:52 +0200
commitc48b9594ff1ffc9dacdcb0f4fca6f459b95989f5 (patch)
treebc57b20c3714fc7cd024cdb63fce71b3669914fa /mesonbuild/environment.py
parente2a4cff76f35b7c666a0bcaa087bcdef579ef19f (diff)
downloadmeson-c48b9594ff1ffc9dacdcb0f4fca6f459b95989f5.zip
meson-c48b9594ff1ffc9dacdcb0f4fca6f459b95989f5.tar.gz
meson-c48b9594ff1ffc9dacdcb0f4fca6f459b95989f5.tar.bz2
Add support for Visual Studio csc c# compiler
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py35
1 files changed, 24 insertions, 11 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index e553423..ccd85d5 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -54,6 +54,7 @@ from .compilers import (
IntelFortranCompiler,
JavaCompiler,
MonoCompiler,
+ VisualStudioCsCompiler,
NAGFortranCompiler,
Open64FortranCompiler,
PathScaleFortranCompiler,
@@ -275,6 +276,10 @@ class Environment:
else:
self.default_c = ['cc', 'gcc', 'clang']
self.default_cpp = ['c++', 'g++', 'clang++']
+ if mesonlib.is_windows():
+ self.default_cs = ['csc', 'mcs']
+ else:
+ self.default_cs = ['mcs', 'csc']
self.default_objc = ['cc']
self.default_objcpp = ['c++']
self.default_fortran = ['gfortran', 'g95', 'f95', 'f90', 'f77', 'ifort']
@@ -419,7 +424,7 @@ class Environment:
def _get_compilers(self, lang, evar, want_cross):
'''
The list of compilers is detected in the exact same way for
- C, C++, ObjC, ObjC++, Fortran so consolidate it here.
+ C, C++, ObjC, ObjC++, Fortran, CS so consolidate it here.
'''
if self.is_cross_build() and want_cross:
compilers = mesonlib.stringlistify(self.cross_info.config['binaries'][lang])
@@ -664,16 +669,24 @@ class Environment:
raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"')
def detect_cs_compiler(self):
- exelist = ['mcs']
- try:
- p, out, err = Popen_safe(exelist + ['--version'])
- except OSError:
- raise EnvironmentException('Could not execute C# compiler "%s"' % ' '.join(exelist))
- version = search_version(out)
- full_version = out.split('\n', 1)[0]
- if 'Mono' in out:
- return MonoCompiler(exelist, version, full_version=full_version)
- raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"')
+ compilers, ccache, is_cross, exe_wrap = self._get_compilers('cs', 'CSC', False)
+ popen_exceptions = {}
+ for comp in compilers:
+ if not isinstance(comp, list):
+ comp = [comp]
+ try:
+ p, out, err = Popen_safe(comp + ['--version'])
+ except OSError as e:
+ popen_exceptions[' '.join(comp + ['--version'])] = e
+ continue
+
+ version = search_version(out)
+ if 'Mono' in out:
+ return MonoCompiler(comp, version)
+ elif "Visual C#" in out:
+ return VisualStudioCsCompiler(comp, version)
+
+ self._handle_exceptions(popen_exceptions, compilers)
def detect_vala_compiler(self):
if 'VALAC' in os.environ: