diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2024-06-08 18:37:17 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2024-06-08 18:45:40 +0300 |
commit | 601a70518c7c7b9ea1df76071a38dd4a9bb1eb54 (patch) | |
tree | bd19d0ad342e7846fe8d53f678e7d48851efca91 | |
parent | f14424d1a62ae0edf05c89c070874a4fab1d8897 (diff) | |
download | meson-opthelper.zip meson-opthelper.tar.gz meson-opthelper.tar.bz2 |
Use helper method in remaining compiler classes.opthelper
-rw-r--r-- | mesonbuild/compilers/cuda.py | 12 | ||||
-rw-r--r-- | mesonbuild/compilers/cython.py | 12 |
2 files changed, 13 insertions, 11 deletions
diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index 8680cf0..f5ee030 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -13,7 +13,7 @@ from .. import options from .. import mlog from ..mesonlib import ( EnvironmentException, Popen_safe, - is_windows, LibType, OptionKey, version_compare, + is_windows, LibType, version_compare, ) from .compilers import Compiler @@ -645,12 +645,12 @@ class CudaCompiler(Compiler): return self.update_options( super().get_options(), self.create_option(options.UserComboOption, - OptionKey('std', machine=self.for_machine, lang=self.language), + self.form_langopt_key('std'), 'C++ language standard to use with CUDA', cpp_stds, 'none'), self.create_option(options.UserStringOption, - OptionKey('ccbindir', machine=self.for_machine, lang=self.language), + self.form_langopt_key('std'), 'CUDA non-default toolchain directory to use (-ccbin)', ''), ) @@ -663,7 +663,7 @@ class CudaCompiler(Compiler): # We must strip the -std option from the host compiler option set, as NVCC has # its own -std flag that may not agree with the host compiler's. host_options = {key: options.get(key, opt) for key, opt in self.host_compiler.get_options().items()} - std_key = OptionKey('std', machine=self.for_machine, lang=self.host_compiler.language) + std_key = self.form_langopt_key('std') overrides = {std_key: 'none'} return coredata.OptionsView(host_options, overrides=overrides) @@ -673,7 +673,7 @@ class CudaCompiler(Compiler): # the combination of CUDA version and MSVC version; the --std= is thus ignored # and attempting to use it will result in a warning: https://stackoverflow.com/a/51272091/741027 if not is_windows(): - key = OptionKey('std', machine=self.for_machine, lang=self.language) + key = self.form_langopt_key('std') std = options[key] if std.value != 'none': args.append('--std=' + std.value) @@ -793,7 +793,7 @@ class CudaCompiler(Compiler): return self._to_host_flags(super().get_dependency_link_args(dep), _Phase.LINKER) def get_ccbin_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - key = OptionKey('ccbindir', machine=self.for_machine, lang=self.language) + key = self.form_langopt_key('std') ccbindir = options[key].value if isinstance(ccbindir, str) and ccbindir != '': return [self._shield_nvcc_list_arg('-ccbin='+ccbindir, False)] diff --git a/mesonbuild/compilers/cython.py b/mesonbuild/compilers/cython.py index 61e339b..7b62327 100644 --- a/mesonbuild/compilers/cython.py +++ b/mesonbuild/compilers/cython.py @@ -7,7 +7,7 @@ from __future__ import annotations import typing as T from .. import options -from ..mesonlib import EnvironmentException, OptionKey, version_compare +from ..mesonlib import EnvironmentException, version_compare from .compilers import Compiler if T.TYPE_CHECKING: @@ -70,12 +70,12 @@ class CythonCompiler(Compiler): return self.update_options( super().get_options(), self.create_option(options.UserComboOption, - OptionKey('version', machine=self.for_machine, lang=self.language), + self.form_langopt_key('bersion'), 'Python version to target', ['2', '3'], '3'), self.create_option(options.UserComboOption, - OptionKey('language', machine=self.for_machine, lang=self.language), + self.form_langopt_key('language'), 'Output C or C++ files', ['c', 'cpp'], 'c'), @@ -83,9 +83,11 @@ class CythonCompiler(Compiler): 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)] + key = self.form_langopt_key('version') + key = options[key] args.append(f'-{key.value}') - lang = options[OptionKey('language', machine=self.for_machine, lang=self.language)] + key = self.form_langopt_key('language') + lang = options[key] if lang.value == 'cpp': args.append('--cplus') return args |