From b2b7227c6254d4bf2ffc8cd6a53aea9bddd0f1ca Mon Sep 17 00:00:00 2001 From: Kevin Meagher <11620178+kjmeagher@users.noreply.github.com> Date: Thu, 30 May 2024 23:14:29 -0500 Subject: [PATCH] Add options for standard parameter for nvc and nvc++ fixes #13271 --- mesonbuild/compilers/c.py | 8 ++++++++ mesonbuild/compilers/cpp.py | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index cbc1bea95d6e..72a8bee553bb 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -361,6 +361,14 @@ def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_ info, linker=linker, full_version=full_version) PGICompiler.__init__(self) + def get_options(self) -> 'MutableKeyedOptionDictType': + opts = CCompiler.get_options(self) + stds = ['c89', 'c90', 'c99', 'c11', 'c17', 'c18'] + std_opt = opts[OptionKey('std', machine=self.for_machine, lang=self.language)] + assert isinstance(std_opt, options.UserStdOption), 'for mypy' + std_opt.set_versions(stds, gnu=True) + return opts + class ElbrusCCompiler(ElbrusCompiler, CCompiler): def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 5e8947bcec58..b2f40bb82281 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -553,6 +553,17 @@ def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_ info, linker=linker, full_version=full_version) PGICompiler.__init__(self) + def get_options(self) -> 'MutableKeyedOptionDictType': + cppstd_choices = [ + 'c++98', 'c++03', 'c++11', 'c++14', 'c++17', 'c++20', 'c++23', + 'gnu++98', 'gnu++03', 'gnu++11', 'gnu++14', 'gnu++17', 'gnu++20' + ] + opts = CPPCompiler.get_options(self) + std_opt = opts[OptionKey('std', machine=self.for_machine, lang=self.language)] + assert isinstance(std_opt, options.UserStdOption), 'for mypy' + std_opt.set_versions(cppstd_choices) + return opts + class ElbrusCPPCompiler(ElbrusCompiler, CPPCompiler): def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,