diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-05-19 15:22:55 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-06-07 09:25:32 -0700 |
commit | 0bc18f26a21ea0c1ad06e131e872cec2cc6022a4 (patch) | |
tree | 405ce4b67ecf46187766ea405437062a2890d4fc /mesonbuild/compilers/cython.py | |
parent | 0cb05004ca9cb6e17cd64b6d0b4ef8e759ed4136 (diff) | |
download | meson-0bc18f26a21ea0c1ad06e131e872cec2cc6022a4.zip meson-0bc18f26a21ea0c1ad06e131e872cec2cc6022a4.tar.gz meson-0bc18f26a21ea0c1ad06e131e872cec2cc6022a4.tar.bz2 |
cython: Add an option for selecting python 3 vs python 2 output
Diffstat (limited to 'mesonbuild/compilers/cython.py')
-rw-r--r-- | mesonbuild/compilers/cython.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/mesonbuild/compilers/cython.py b/mesonbuild/compilers/cython.py index ab8a96b..513f079 100644 --- a/mesonbuild/compilers/cython.py +++ b/mesonbuild/compilers/cython.py @@ -5,10 +5,12 @@ import typing as T -from ..mesonlib import EnvironmentException +from .. import coredata +from ..mesonlib import EnvironmentException, OptionKey from .compilers import Compiler if T.TYPE_CHECKING: + from ..coredata import KeyedOptionDictType from ..environment import Environment @@ -24,8 +26,7 @@ class CythonCompiler(Compiler): return False def get_always_args(self) -> T.List[str]: - # XXX: we need an option to control this? - return ['--fast-fail', '-3'] + return ['--fast-fail'] def get_werror_args(self) -> T.List[str]: return ['-Werror'] @@ -59,3 +60,20 @@ class CythonCompiler(Compiler): new.append(i) return new + + def get_options(self) -> 'KeyedOptionDictType': + opts = super().get_options() + opts.update({ + OptionKey('version', machine=self.for_machine, lang=self.language): coredata.UserComboOption( + 'Python version to target', + ['2', '3'], + '3', + ) + }) + return opts + + def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + args: T.List[str] = [] + key = options[OptionKey('version', machine=self.for_machine, lang=self.language)] + args.append(f'-{key.value}') + return args |