diff options
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 15 | ||||
-rw-r--r-- | mesonbuild/compilers/cython.py | 24 |
2 files changed, 34 insertions, 5 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 25fa051..8efb01b 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1559,10 +1559,21 @@ int dummy; cython = target.compilers['cython'] + opt_proxy = self.get_compiler_options_for_target(target) + + args: T.List[str] = [] + args += cython.get_always_args() + args += cython.get_buildtype_args(self.get_option_for_target(OptionKey('buildtype'), target)) + args += cython.get_debug_args(self.get_option_for_target(OptionKey('debug'), target)) + args += cython.get_optimization_args(self.get_option_for_target(OptionKey('optimization'), target)) + args += cython.get_option_compile_args(opt_proxy) + args += self.build.get_global_args(cython, target.for_machine) + args += self.build.get_project_args(cython, target.subproject, target.for_machine) + for src in target.get_sources(): if src.endswith('.pyx'): output = os.path.join(self.get_target_private_dir(target), f'{src}.c') - args = cython.get_always_args() + args = args.copy() args += cython.get_output_args(output) element = NinjaBuildElement( self.all_outputs, [output], @@ -1580,8 +1591,8 @@ int dummy; if isinstance(gen, GeneratedList): ssrc = os.path.join(self.get_target_private_dir(target) , ssrc) if ssrc.endswith('.pyx'): + args = args.copy() output = os.path.join(self.get_target_private_dir(target), f'{ssrc}.c') - args = cython.get_always_args() args += cython.get_output_args(output) element = NinjaBuildElement( self.all_outputs, [output], 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 |