diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2021-01-04 23:42:50 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-04 23:42:50 +0000 |
commit | d47a5c81a9af992eca42d857477f2bb5821712b6 (patch) | |
tree | 9c9ff772c696661a1582dc81c86273e8d975a13f /mesonbuild/compilers/rust.py | |
parent | 6b515c432109cf7ab488da37cddeb1752e91fa5c (diff) | |
parent | f14bf8b2ed052f68857ed3eaec08a326d335a3a4 (diff) | |
download | meson-d47a5c81a9af992eca42d857477f2bb5821712b6.zip meson-d47a5c81a9af992eca42d857477f2bb5821712b6.tar.gz meson-d47a5c81a9af992eca42d857477f2bb5821712b6.tar.bz2 |
Merge pull request #8080 from dcbaker/submit/option-key-type
Use an object for option keys
Diffstat (limited to 'mesonbuild/compilers/rust.py')
-rw-r--r-- | mesonbuild/compilers/rust.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index 312b3b6..fd58819 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -17,11 +17,14 @@ import textwrap import typing as T from .. import coredata -from ..mesonlib import EnvironmentException, MachineChoice, MesonException, Popen_safe +from ..mesonlib import ( + EnvironmentException, MachineChoice, MesonException, Popen_safe, + OptionKey, +) from .compilers import Compiler, rust_buildtype_args, clike_debug_args if T.TYPE_CHECKING: - from ..coredata import OptionDictType + from ..coredata import KeyedOptionDictType from ..dependencies import ExternalProgram from ..envconfig import MachineInfo from ..environment import Environment # noqa: F401 @@ -52,9 +55,9 @@ class RustCompiler(Compiler): linker=linker) self.exe_wrapper = exe_wrapper self.id = 'rustc' - self.base_options.append('b_colorout') + self.base_options.add(OptionKey('b_colorout')) if 'link' in self.linker.id: - self.base_options.append('b_vscrt') + self.base_options.add(OptionKey('b_vscrt')) def needs_static_linker(self) -> bool: return False @@ -133,18 +136,20 @@ class RustCompiler(Compiler): # C compiler for dynamic linking, as such we invoke the C compiler's # use_linker_args method instead. - def get_options(self) -> 'OptionDictType': + def get_options(self) -> 'KeyedOptionDictType': + key = OptionKey('std', machine=self.for_machine, lang=self.language) return { - 'std': coredata.UserComboOption( + key: coredata.UserComboOption( 'Rust Eddition to use', ['none', '2015', '2018'], 'none', ), } - def get_option_compile_args(self, options: 'OptionDictType') -> T.List[str]: + def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: args = [] - std = options['std'] + key = OptionKey('std', machine=self.for_machine, lang=self.language) + std = options[key] if std.value != 'none': args.append('--edition=' + std.value) return args |