aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-04-27 10:24:42 -0700
committerDylan Baker <dylan@pnwbakers.com>2021-06-07 09:16:19 -0700
commitcf17ef3867b585a40762808aed8e0b240d9113ed (patch)
tree5923aa786758a07d4b8ee853c16b98242c9532df /mesonbuild/environment.py
parentedf1a21722ef172d79e9ba2e9367df3d6e566b4f (diff)
downloadmeson-cf17ef3867b585a40762808aed8e0b240d9113ed.zip
meson-cf17ef3867b585a40762808aed8e0b240d9113ed.tar.gz
meson-cf17ef3867b585a40762808aed8e0b240d9113ed.tar.bz2
environment: Add detection logic for cython
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index fc9b703..ce037dd 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -87,6 +87,7 @@ from .compilers import (
ClangObjCPPCompiler,
ClangClCCompiler,
ClangClCPPCompiler,
+ CythonCompiler,
FlangFortranCompiler,
G95FortranCompiler,
GnuCCompiler,
@@ -732,6 +733,7 @@ class Environment:
self.default_rust = ['rustc']
self.default_swift = ['swiftc']
self.default_vala = ['valac']
+ self.default_cython = [['cython']]
self.default_static_linker = ['ar', 'gar']
self.default_strip = ['strip']
self.vs_static_linker = ['lib']
@@ -1757,6 +1759,30 @@ class Environment:
self._handle_exceptions(popen_exceptions, compilers)
+ def detect_cython_compiler(self, for_machine: MachineChoice) -> CythonCompiler:
+ """Search for a cython compiler."""
+ compilers = self.lookup_binary_entry(for_machine, 'cython')
+ is_cross = self.is_cross_build(for_machine)
+ info = self.machines[for_machine]
+ if compilers is None:
+ # TODO support fallback
+ compilers = [self.default_cython[0]]
+
+ popen_exceptions: T.Dict[str, Exception] = {}
+ for comp in compilers:
+ try:
+ err = Popen_safe(comp + ['-V'])[2]
+ except OSError as e:
+ popen_exceptions[' '.join(comp + ['-V'])] = e
+ continue
+
+ version = search_version(err)
+ if 'Cython' in err:
+ comp_class = CythonCompiler
+ self.coredata.add_lang_args(comp_class.language, comp_class, for_machine, self)
+ return comp_class(comp, version, for_machine, info, is_cross=is_cross)
+ self._handle_exceptions(popen_exceptions, compilers)
+
def detect_vala_compiler(self, for_machine):
exelist = self.lookup_binary_entry(for_machine, 'vala')
is_cross = self.is_cross_build(for_machine)
@@ -2023,6 +2049,8 @@ class Environment:
comp = self.detect_fortran_compiler(for_machine)
elif lang == 'swift':
comp = self.detect_swift_compiler(for_machine)
+ elif lang == 'cython':
+ comp = self.detect_cython_compiler(for_machine)
else:
comp = None
return comp