aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/cython.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-08-24 09:20:03 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2021-09-24 22:56:46 +0300
commit68c23a61203fc35dd11c7a0b1cc13f7cc2c5cf8c (patch)
tree5afe315e41b55e8b12f3b1b56d75bfd766620cae /mesonbuild/compilers/cython.py
parent524a95fa62a6e0cb77e53d7b38d5c2d59a75e449 (diff)
downloadmeson-68c23a61203fc35dd11c7a0b1cc13f7cc2c5cf8c.zip
meson-68c23a61203fc35dd11c7a0b1cc13f7cc2c5cf8c.tar.gz
meson-68c23a61203fc35dd11c7a0b1cc13f7cc2c5cf8c.tar.bz2
Add option to to transpile Cython to C++
This patch adds a new meson built-in option for cython, allowing it to target C++ instead of C as the intermediate language. This can, of course, be done on a per-target basis using the `override_options` keyword argument, or for the entire project in the project function. There are some things in this patch that are less than ideal. One of them is that we have to add compilers in the build layer, but there isn't a better place to do it because of per target override_options. There's also some design differences between Meson and setuptools, in that Meson only allows options on a per-target rather than a per-file granularity. Fixes #9015
Diffstat (limited to 'mesonbuild/compilers/cython.py')
-rw-r--r--mesonbuild/compilers/cython.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/mesonbuild/compilers/cython.py b/mesonbuild/compilers/cython.py
index 513f079..34ddff1 100644
--- a/mesonbuild/compilers/cython.py
+++ b/mesonbuild/compilers/cython.py
@@ -68,6 +68,11 @@ class CythonCompiler(Compiler):
'Python version to target',
['2', '3'],
'3',
+ ),
+ OptionKey('language', machine=self.for_machine, lang=self.language): coredata.UserComboOption(
+ 'Output C or C++ files',
+ ['c', 'cpp'],
+ 'c',
)
})
return opts
@@ -76,4 +81,7 @@ class CythonCompiler(Compiler):
args: T.List[str] = []
key = options[OptionKey('version', machine=self.for_machine, lang=self.language)]
args.append(f'-{key.value}')
+ lang = options[OptionKey('language', machine=self.for_machine, lang=self.language)]
+ if lang.value == 'cpp':
+ args.append('--cplus')
return args