aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/cpp.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-10-12 21:45:24 -0400
committerXavier Claessens <xclaesse@gmail.com>2022-03-22 17:20:48 -0400
commit06d12064d0ccb1477fadf1d62492a493fb2fb947 (patch)
treea405725996ecfcad94fdd242ebc6da7b246497ae /mesonbuild/compilers/cpp.py
parent86aaac8e4229608b25508027267f49624a9a8cb5 (diff)
downloadmeson-06d12064d0ccb1477fadf1d62492a493fb2fb947.zip
meson-06d12064d0ccb1477fadf1d62492a493fb2fb947.tar.gz
meson-06d12064d0ccb1477fadf1d62492a493fb2fb947.tar.bz2
OptionOverrideProxy: Make it immutable to avoid copies
It is always used as an immutable view so there is no point in doing copies. However, mypy insist it must implement the same APIs as Dict[OptionKey, UserOption[Any]] so keep faking it.
Diffstat (limited to 'mesonbuild/compilers/cpp.py')
-rw-r--r--mesonbuild/compilers/cpp.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index e6410c8..fe09b6b 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -41,7 +41,7 @@ from .mixins.pgi import PGICompiler
from .mixins.emscripten import EmscriptenMixin
if T.TYPE_CHECKING:
- from ..coredata import KeyedOptionDictType
+ from ..coredata import MutableKeyedOptionDictType, KeyedOptionDictType
from ..dependencies import Dependency
from ..envconfig import MachineInfo
from ..environment import Environment
@@ -168,7 +168,7 @@ class CPPCompiler(CLikeCompiler, Compiler):
raise MesonException(f'C++ Compiler does not support -std={cpp_std}')
- def get_options(self) -> 'KeyedOptionDictType':
+ def get_options(self) -> 'MutableKeyedOptionDictType':
opts = super().get_options()
key = OptionKey('std', machine=self.for_machine, lang=self.language)
opts.update({
@@ -196,7 +196,7 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler):
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
- def get_options(self) -> 'KeyedOptionDictType':
+ def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CPPCompiler.get_options(self)
key = OptionKey('key', machine=self.for_machine, lang=self.language)
opts.update({
@@ -316,7 +316,7 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler):
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
- def get_options(self) -> 'KeyedOptionDictType':
+ def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CPPCompiler.get_options(self)
key = OptionKey('std', machine=self.for_machine, lang=self.language)
opts.update({
@@ -362,7 +362,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
- def get_options(self) -> 'KeyedOptionDictType':
+ def get_options(self) -> 'MutableKeyedOptionDictType':
key = OptionKey('std', machine=self.for_machine, lang=self.language)
opts = CPPCompiler.get_options(self)
opts.update({
@@ -465,7 +465,7 @@ class ElbrusCPPCompiler(ElbrusCompiler, CPPCompiler):
info, exe_wrapper, linker=linker, full_version=full_version)
ElbrusCompiler.__init__(self)
- def get_options(self) -> 'KeyedOptionDictType':
+ def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CPPCompiler.get_options(self)
cpp_stds = ['none', 'c++98', 'gnu++98']
@@ -542,7 +542,7 @@ class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler):
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra']}
- def get_options(self) -> 'KeyedOptionDictType':
+ def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CPPCompiler.get_options(self)
# Every Unix compiler under the sun seems to accept -std=c++03,
# with the exception of ICC. Instead of preventing the user from
@@ -618,7 +618,7 @@ class VisualStudioLikeCPPCompilerMixin(CompilerMixinBase):
key = OptionKey('winlibs', machine=self.for_machine, lang=self.language)
return T.cast('T.List[str]', options[key].value[:])
- def _get_options_impl(self, opts: 'KeyedOptionDictType', cpp_stds: T.List[str]) -> 'KeyedOptionDictType':
+ def _get_options_impl(self, opts: 'MutableKeyedOptionDictType', cpp_stds: T.List[str]) -> 'MutableKeyedOptionDictType':
key = OptionKey('std', machine=self.for_machine, lang=self.language)
opts.update({
key.evolve('eh'): coredata.UserComboOption(
@@ -705,7 +705,7 @@ class VisualStudioCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixi
info, exe_wrapper, linker=linker, full_version=full_version)
MSVCCompiler.__init__(self, target)
- def get_options(self) -> 'KeyedOptionDictType':
+ def get_options(self) -> 'MutableKeyedOptionDictType':
cpp_stds = ['none', 'c++11', 'vc++11']
# Visual Studio 2015 and later
if version_compare(self.version, '>=19'):
@@ -747,7 +747,7 @@ class ClangClCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixin, Cl
info, exe_wrapper, linker=linker, full_version=full_version)
ClangClCompiler.__init__(self, target)
- def get_options(self) -> 'KeyedOptionDictType':
+ def get_options(self) -> 'MutableKeyedOptionDictType':
cpp_stds = ['none', 'c++11', 'vc++11', 'c++14', 'vc++14', 'c++17', 'vc++17', 'c++latest']
return self._get_options_impl(super().get_options(), cpp_stds)
@@ -763,7 +763,7 @@ class IntelClCPPCompiler(VisualStudioLikeCPPCompilerMixin, IntelVisualStudioLike
info, exe_wrapper, linker=linker, full_version=full_version)
IntelVisualStudioLikeCompiler.__init__(self, target)
- def get_options(self) -> 'KeyedOptionDictType':
+ def get_options(self) -> 'MutableKeyedOptionDictType':
# This has only been tested with version 19.0,
cpp_stds = ['none', 'c++11', 'vc++11', 'c++14', 'vc++14', 'c++17', 'vc++17', 'c++latest']
return self._get_options_impl(super().get_options(), cpp_stds)
@@ -782,7 +782,7 @@ class ArmCPPCompiler(ArmCompiler, CPPCompiler):
info, exe_wrapper, linker=linker, full_version=full_version)
ArmCompiler.__init__(self)
- def get_options(self) -> 'KeyedOptionDictType':
+ def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CPPCompiler.get_options(self)
key = OptionKey('std', machine=self.for_machine, lang=self.language)
opts[key].choices = ['none', 'c++03', 'c++11']
@@ -842,7 +842,7 @@ class TICPPCompiler(TICompiler, CPPCompiler):
info, exe_wrapper, linker=linker, full_version=full_version)
TICompiler.__init__(self)
- def get_options(self) -> 'KeyedOptionDictType':
+ def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CPPCompiler.get_options(self)
key = OptionKey('std', machine=self.for_machine, lang=self.language)
opts[key].choices = ['none', 'c++03']