aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/c.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/compilers/c.py')
-rw-r--r--mesonbuild/compilers/c.py71
1 files changed, 36 insertions, 35 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 8fda3a5..819ef8b 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -10,6 +10,7 @@ from .. import options
from .. import mlog
from ..mesonlib import MesonException, version_compare
from .c_function_attributes import C_FUNC_ATTRIBUTES
+from .mixins.apple import AppleCompilerMixin
from .mixins.clike import CLikeCompiler
from .mixins.ccrx import CcrxCompiler
from .mixins.xc16 import Xc16Compiler
@@ -94,7 +95,7 @@ class CCompiler(CLikeCompiler, Compiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = super().get_options()
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
opts.update({
key: options.UserStdOption('C', _ALL_STDS),
})
@@ -127,7 +128,7 @@ class _ClangCStds(CompilerMixinBase):
stds += ['c2x']
if version_compare(self.version, self._C23_VERSION):
stds += ['c23']
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std_opt = opts[key]
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(stds, gnu=True)
@@ -156,7 +157,7 @@ class ClangCCompiler(_ClangCStds, ClangCompiler, CCompiler):
self.update_options(
opts,
self.create_option(options.UserArrayOption,
- self.form_langopt_key('winlibs'),
+ self.form_compileropt_key('winlibs'),
'Standard Win libraries to link against',
gnu_winlibs),
)
@@ -164,7 +165,7 @@ class ClangCCompiler(_ClangCStds, ClangCompiler, CCompiler):
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std != 'none':
args.append('-std=' + std)
@@ -173,7 +174,7 @@ class ClangCCompiler(_ClangCStds, ClangCompiler, CCompiler):
def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
if self.info.is_windows() or self.info.is_cygwin():
# without a typedict mypy can't understand this.
- key = self.form_langopt_key('winlibs')
+ key = self.form_compileropt_key('winlibs')
libs = options.get_value(key).copy()
assert isinstance(libs, list)
for l in libs:
@@ -187,7 +188,7 @@ class ArmLtdClangCCompiler(ClangCCompiler):
id = 'armltdclang'
-class AppleClangCCompiler(ClangCCompiler):
+class AppleClangCCompiler(AppleCompilerMixin, ClangCCompiler):
"""Handle the differences between Apple Clang and Vanilla Clang.
@@ -249,7 +250,7 @@ class ArmclangCCompiler(ArmclangCompiler, CCompiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CCompiler.get_options(self)
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std_opt = opts[key]
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(['c90', 'c99', 'c11'], gnu=True)
@@ -257,7 +258,7 @@ class ArmclangCCompiler(ArmclangCompiler, CCompiler):
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std != 'none':
args.append('-std=' + std)
@@ -301,7 +302,7 @@ class GnuCCompiler(GnuCompiler, CCompiler):
stds += ['c2x']
if version_compare(self.version, self._C23_VERSION):
stds += ['c23']
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std_opt = opts[key]
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(stds, gnu=True)
@@ -309,7 +310,7 @@ class GnuCCompiler(GnuCompiler, CCompiler):
self.update_options(
opts,
self.create_option(options.UserArrayOption,
- key.evolve('winlibs'),
+ key.evolve('c_winlibs'),
'Standard Win libraries to link against',
gnu_winlibs),
)
@@ -317,7 +318,7 @@ class GnuCCompiler(GnuCompiler, CCompiler):
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std != 'none':
args.append('-std=' + std)
@@ -326,7 +327,7 @@ class GnuCCompiler(GnuCompiler, CCompiler):
def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
if self.info.is_windows() or self.info.is_cygwin():
# without a typeddict mypy can't figure this out
- key = self.form_langopt_key('winlibs')
+ key = self.form_compileropt_key('winlibs')
libs: T.List[str] = options.get_value(key).copy()
assert isinstance(libs, list)
for l in libs:
@@ -383,7 +384,7 @@ class ElbrusCCompiler(ElbrusCompiler, CCompiler):
stds += ['c90', 'c1x', 'gnu90', 'gnu1x', 'iso9899:2011']
if version_compare(self.version, '>=1.26.00'):
stds += ['c17', 'c18', 'iso9899:2017', 'iso9899:2018', 'gnu17', 'gnu18']
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std_opt = opts[key]
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(stds)
@@ -423,7 +424,7 @@ class IntelCCompiler(IntelGnuLikeCompiler, CCompiler):
stds = ['c89', 'c99']
if version_compare(self.version, '>=16.0.0'):
stds += ['c11']
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std_opt = opts[key]
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(stds, gnu=True)
@@ -431,7 +432,7 @@ class IntelCCompiler(IntelGnuLikeCompiler, CCompiler):
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std != 'none':
args.append('-std=' + std)
@@ -452,7 +453,7 @@ class VisualStudioLikeCCompilerMixin(CompilerMixinBase):
super().get_options(),
self.create_option(
options.UserArrayOption,
- self.form_langopt_key('winlibs'),
+ self.form_compileropt_key('winlibs'),
'Windows libs to link against.',
msvc_winlibs,
),
@@ -460,7 +461,7 @@ class VisualStudioLikeCCompilerMixin(CompilerMixinBase):
def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
# need a TypeDict to make this work
- key = self.form_langopt_key('winlibs')
+ key = self.form_compileropt_key('winlibs')
libs = options.get_value(key).copy()
assert isinstance(libs, list)
for l in libs:
@@ -489,7 +490,7 @@ class VisualStudioCCompiler(MSVCCompiler, VisualStudioLikeCCompilerMixin, CCompi
stds += ['c11']
if version_compare(self.version, self._C17_VERSION):
stds += ['c17', 'c18']
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std_opt = opts[key]
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(stds, gnu=True, gnu_deprecated=True)
@@ -497,7 +498,7 @@ class VisualStudioCCompiler(MSVCCompiler, VisualStudioLikeCCompilerMixin, CCompi
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
# As of MVSC 16.8, /std:c11 and /std:c17 are the only valid C standard options.
if std == 'c11':
@@ -518,7 +519,7 @@ class ClangClCCompiler(_ClangCStds, ClangClCompiler, VisualStudioLikeCCompilerMi
ClangClCompiler.__init__(self, target)
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std != "none":
return [f'/clang:-std={std}']
@@ -540,7 +541,7 @@ class IntelClCCompiler(IntelVisualStudioLikeCompiler, VisualStudioLikeCCompilerM
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = super().get_options()
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
# To shut up mypy.
if isinstance(opts, dict):
raise RuntimeError('This is a transitory issue that should not happen. Please report with full backtrace.')
@@ -551,7 +552,7 @@ class IntelClCCompiler(IntelVisualStudioLikeCompiler, VisualStudioLikeCCompilerM
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std == 'c89':
mlog.log("ICL doesn't explicitly implement c89, setting the standard to 'none', which is close.", once=True)
@@ -577,7 +578,7 @@ class ArmCCompiler(ArmCompiler, CCompiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CCompiler.get_options(self)
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std_opt = opts[key]
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(['c89', 'c99', 'c11'])
@@ -585,7 +586,7 @@ class ArmCCompiler(ArmCompiler, CCompiler):
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std != 'none':
args.append('--' + std)
@@ -607,7 +608,7 @@ class CcrxCCompiler(CcrxCompiler, CCompiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CCompiler.get_options(self)
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std_opt = opts[key]
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(['c89', 'c99'])
@@ -618,7 +619,7 @@ class CcrxCCompiler(CcrxCompiler, CCompiler):
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std == 'c89':
args.append('-lang=c')
@@ -655,7 +656,7 @@ class Xc16CCompiler(Xc16Compiler, CCompiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CCompiler.get_options(self)
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std_opt = opts[key]
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(['c89', 'c99'], gnu=True)
@@ -666,7 +667,7 @@ class Xc16CCompiler(Xc16Compiler, CCompiler):
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std != 'none':
args.append('-ansi')
@@ -701,7 +702,7 @@ class CompCertCCompiler(CompCertCompiler, CCompiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CCompiler.get_options(self)
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std_opt = opts[key]
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(['c89', 'c99'])
@@ -739,7 +740,7 @@ class TICCompiler(TICompiler, CCompiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CCompiler.get_options(self)
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std_opt = opts[key]
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(['c89', 'c99', 'c11'])
@@ -750,7 +751,7 @@ class TICCompiler(TICompiler, CCompiler):
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std != 'none':
args.append('--' + std)
@@ -780,13 +781,13 @@ class MetrowerksCCompilerARM(MetrowerksCompiler, CCompiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CCompiler.get_options(self)
c_stds = ['c99']
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
opts[key].choices = ['none'] + c_stds
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std != 'none':
args.append('-lang')
@@ -810,13 +811,13 @@ class MetrowerksCCompilerEmbeddedPowerPC(MetrowerksCompiler, CCompiler):
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = CCompiler.get_options(self)
c_stds = ['c99']
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
opts[key].choices = ['none'] + c_stds
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = []
- key = self.form_langopt_key('std')
+ key = self.form_compileropt_key('std')
std = options.get_value(key)
if std != 'none':
args.append('-lang ' + std)