diff options
Diffstat (limited to 'mesonbuild/compilers/c.py')
-rw-r--r-- | mesonbuild/compilers/c.py | 315 |
1 files changed, 136 insertions, 179 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 8fda3a5..7a2fec5 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -1,5 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright 2012-2020 The Meson development team +# Copyright © 2024-2025 Intel Corporation from __future__ import annotations @@ -7,9 +8,11 @@ import os.path import typing as T from .. import options +from ..options import OptionKey from .. import mlog from ..mesonlib import MesonException, version_compare from .c_function_attributes import C_FUNC_ATTRIBUTES +from .mixins.apple import AppleCompilerMixin, AppleCStdsMixin from .mixins.clike import CLikeCompiler from .mixins.ccrx import CcrxCompiler from .mixins.xc16 import Xc16Compiler @@ -17,15 +20,16 @@ from .mixins.compcert import CompCertCompiler from .mixins.ti import TICompiler from .mixins.arm import ArmCompiler, ArmclangCompiler from .mixins.visualstudio import MSVCCompiler, ClangClCompiler -from .mixins.gnu import GnuCompiler +from .mixins.gnu import GnuCompiler, GnuCStds from .mixins.gnu import gnu_common_warning_args, gnu_c_warning_args from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler -from .mixins.clang import ClangCompiler +from .mixins.clang import ClangCompiler, ClangCStds from .mixins.elbrus import ElbrusCompiler from .mixins.pgi import PGICompiler from .mixins.emscripten import EmscriptenMixin from .mixins.metrowerks import MetrowerksCompiler from .mixins.metrowerks import mwccarm_instruction_set_args, mwcceppc_instruction_set_args +from .mixins.tasking import TaskingCompiler from .compilers import ( gnu_winlibs, msvc_winlibs, @@ -33,21 +37,22 @@ from .compilers import ( ) if T.TYPE_CHECKING: - from ..coredata import MutableKeyedOptionDictType, KeyedOptionDictType + from ..options import MutableKeyedOptionDictType from ..dependencies import Dependency from ..envconfig import MachineInfo from ..environment import Environment from ..linkers.linkers import DynamicLinker from ..mesonlib import MachineChoice from .compilers import CompileCheckMode + from ..build import BuildTarget CompilerMixinBase = Compiler else: CompilerMixinBase = object -_ALL_STDS = ['c89', 'c9x', 'c90', 'c99', 'c1x', 'c11', 'c17', 'c18', 'c2x', 'c23'] -_ALL_STDS += [f'gnu{std[1:]}' for std in _ALL_STDS] -_ALL_STDS += ['iso9899:1990', 'iso9899:199409', 'iso9899:1999', 'iso9899:2011', 'iso9899:2017', 'iso9899:2018'] +ALL_STDS = ['c89', 'c9x', 'c90', 'c99', 'c1x', 'c11', 'c17', 'c18', 'c2x', 'c23', 'c2y'] +ALL_STDS += [f'gnu{std[1:]}' for std in ALL_STDS] +ALL_STDS += ['iso9899:1990', 'iso9899:199409', 'iso9899:1999', 'iso9899:2011', 'iso9899:2017', 'iso9899:2018'] class CCompiler(CLikeCompiler, Compiler): @@ -94,47 +99,14 @@ 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), + key: options.UserStdOption('c', ALL_STDS), }) return opts -class _ClangCStds(CompilerMixinBase): - - """Mixin class for clang based compilers for setting C standards. - - This is used by both ClangCCompiler and ClangClCompiler, as they share - the same versions - """ - - _C17_VERSION = '>=6.0.0' - _C18_VERSION = '>=8.0.0' - _C2X_VERSION = '>=9.0.0' - _C23_VERSION = '>=18.0.0' - - def get_options(self) -> 'MutableKeyedOptionDictType': - opts = super().get_options() - stds = ['c89', 'c99', 'c11'] - # https://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html - # https://en.wikipedia.org/wiki/Xcode#Latest_versions - if version_compare(self.version, self._C17_VERSION): - stds += ['c17'] - if version_compare(self.version, self._C18_VERSION): - stds += ['c18'] - if version_compare(self.version, self._C2X_VERSION): - stds += ['c2x'] - if version_compare(self.version, self._C23_VERSION): - stds += ['c23'] - key = self.form_langopt_key('std') - std_opt = opts[key] - assert isinstance(std_opt, options.UserStdOption), 'for mypy' - std_opt.set_versions(stds, gnu=True) - return opts - - -class ClangCCompiler(_ClangCStds, ClangCompiler, CCompiler): +class ClangCCompiler(ClangCStds, ClangCompiler, CCompiler): def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', @@ -153,29 +125,26 @@ class ClangCCompiler(_ClangCStds, ClangCompiler, CCompiler): def get_options(self) -> 'MutableKeyedOptionDictType': opts = super().get_options() if self.info.is_windows() or self.info.is_cygwin(): - self.update_options( - opts, - self.create_option(options.UserArrayOption, - self.form_langopt_key('winlibs'), - 'Standard Win libraries to link against', - gnu_winlibs), - ) + key = self.form_compileropt_key('winlibs') + opts[key] = options.UserStringArrayOption( + self.make_option_name(key), + 'Standard Windows libraries to link against', + gnu_winlibs) return opts - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + std = self.get_compileropt_value('std', env, target, subproject) + assert isinstance(std, str) if std != 'none': args.append('-std=' + std) return args - def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_link_args(self, target: 'BuildTarget', env: 'Environment', subproject: T.Optional[str] = None) -> 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') - libs = options.get_value(key).copy() - assert isinstance(libs, list) + retval = self.get_compileropt_value('winlibs', env, target, subproject) + assert isinstance(retval, list) + libs: T.List[str] = retval.copy() for l in libs: assert isinstance(l, str) return libs @@ -187,7 +156,7 @@ class ArmLtdClangCCompiler(ClangCCompiler): id = 'armltdclang' -class AppleClangCCompiler(ClangCCompiler): +class AppleClangCCompiler(AppleCompilerMixin, AppleCStdsMixin, ClangCCompiler): """Handle the differences between Apple Clang and Vanilla Clang. @@ -195,10 +164,6 @@ class AppleClangCCompiler(ClangCCompiler): C standards were added. """ - _C17_VERSION = '>=10.0.0' - _C18_VERSION = '>=11.0.0' - _C2X_VERSION = '>=11.0.0' - class EmscriptenCCompiler(EmscriptenMixin, ClangCCompiler): @@ -212,7 +177,7 @@ class EmscriptenCCompiler(EmscriptenMixin, ClangCCompiler): _C17_VERSION = '>=1.38.35' _C18_VERSION = '>=1.38.35' _C2X_VERSION = '>=1.38.35' # 1.38.35 used Clang 9.0.0 - _C23_VERSION = '>=3.0.0' # 3.0.0 used Clang 18.0.0 + _C23_VERSION = '>=3.1.45' # 3.1.45 used Clang 18.0.0 def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', @@ -248,30 +213,27 @@ class ArmclangCCompiler(ArmclangCompiler, CCompiler): 'everything': ['-Weverything']} def get_options(self) -> 'MutableKeyedOptionDictType': - opts = CCompiler.get_options(self) - key = self.form_langopt_key('std') + opts = super().get_options() + 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) return opts - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + std = self.get_compileropt_value('std', env, target, subproject) + assert isinstance(std, str) if std != 'none': args.append('-std=' + std) return args - def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_link_args(self, target: 'BuildTarget', env: 'Environment', subproject: T.Optional[str] = None) -> T.List[str]: return [] -class GnuCCompiler(GnuCompiler, CCompiler): +class GnuCCompiler(GnuCStds, GnuCompiler, CCompiler): - _C18_VERSION = '>=8.0.0' - _C2X_VERSION = '>=9.0.0' - _C23_VERSION = '>=14.0.0' _INVALID_PCH_VERSION = ">=3.4.0" def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, @@ -293,42 +255,31 @@ class GnuCCompiler(GnuCompiler, CCompiler): self.supported_warn_args(gnu_c_warning_args))} def get_options(self) -> 'MutableKeyedOptionDictType': - opts = CCompiler.get_options(self) - stds = ['c89', 'c99', 'c11'] - if version_compare(self.version, self._C18_VERSION): - stds += ['c17', 'c18'] - if version_compare(self.version, self._C2X_VERSION): - stds += ['c2x'] - if version_compare(self.version, self._C23_VERSION): - stds += ['c23'] - key = self.form_langopt_key('std') - std_opt = opts[key] - assert isinstance(std_opt, options.UserStdOption), 'for mypy' - std_opt.set_versions(stds, gnu=True) + opts = super().get_options() if self.info.is_windows() or self.info.is_cygwin(): - self.update_options( - opts, - self.create_option(options.UserArrayOption, - key.evolve('winlibs'), - 'Standard Win libraries to link against', - gnu_winlibs), - ) + key = self.form_compileropt_key('winlibs') + opts[key] = options.UserStringArrayOption( + self.make_option_name(key), + 'Standard Windows libraries to link against', + gnu_winlibs) return opts - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + key = OptionKey('c_std', machine=self.for_machine) + std = self.get_compileropt_value(key, env, target, subproject) + assert isinstance(std, str) if std != 'none': args.append('-std=' + std) return args - def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_link_args(self, target: 'BuildTarget', env: 'Environment', subproject: T.Optional[str] = None) -> 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') - libs: T.List[str] = options.get_value(key).copy() - assert isinstance(libs, list) + retval = self.get_compileropt_value('winlibs', env, target, subproject) + + assert isinstance(retval, list) + libs: T.List[str] = retval.copy() for l in libs: assert isinstance(l, str) return libs @@ -360,6 +311,14 @@ class NvidiaHPC_CCompiler(PGICompiler, CCompiler): info, linker=linker, full_version=full_version) PGICompiler.__init__(self) + def get_options(self) -> 'MutableKeyedOptionDictType': + opts = super().get_options() + cppstd_choices = ['c89', 'c90', 'c99', 'c11', 'c17', 'c18'] + std_opt = opts[self.form_compileropt_key('std')] + assert isinstance(std_opt, options.UserStdOption), 'for mypy' + std_opt.set_versions(cppstd_choices, 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, @@ -372,7 +331,7 @@ class ElbrusCCompiler(ElbrusCompiler, CCompiler): ElbrusCompiler.__init__(self) def get_options(self) -> 'MutableKeyedOptionDictType': - opts = CCompiler.get_options(self) + opts = super().get_options() stds = ['c89', 'c9x', 'c99', 'gnu89', 'gnu9x', 'gnu99'] stds += ['iso9899:1990', 'iso9899:199409', 'iso9899:1999'] if version_compare(self.version, '>=1.20.00'): @@ -383,7 +342,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) @@ -419,20 +378,20 @@ class IntelCCompiler(IntelGnuLikeCompiler, CCompiler): 'everything': default_warn_args + ['-Wextra']} def get_options(self) -> 'MutableKeyedOptionDictType': - opts = CCompiler.get_options(self) + opts = super().get_options() 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) return opts - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: + args: T.List[str] = [] + std = self.get_compileropt_value('std', env, target, subproject) + assert isinstance(std, str) if std != 'none': args.append('-std=' + std) return args @@ -448,21 +407,18 @@ class VisualStudioLikeCCompilerMixin(CompilerMixinBase): """Shared methods that apply to MSVC-like C compilers.""" def get_options(self) -> MutableKeyedOptionDictType: - return self.update_options( - super().get_options(), - self.create_option( - options.UserArrayOption, - self.form_langopt_key('winlibs'), - 'Windows libs to link against.', - msvc_winlibs, - ), - ) - - def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - # need a TypeDict to make this work - key = self.form_langopt_key('winlibs') - libs = options.get_value(key).copy() - assert isinstance(libs, list) + opts = super().get_options() + key = self.form_compileropt_key('winlibs') + opts[key] = options.UserStringArrayOption( + self.make_option_name(key), + 'Standard Windows libraries to link against', + msvc_winlibs) + return opts + + def get_option_link_args(self, target: 'BuildTarget', env: 'Environment', subproject: T.Optional[str] = None) -> T.List[str]: + retval = self.get_compileropt_value('winlibs', env, target, subproject) + assert isinstance(retval, list) + libs: T.List[str] = retval.copy() for l in libs: assert isinstance(l, str) return libs @@ -489,25 +445,25 @@ 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) return opts - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + std = self.get_compileropt_value('std', env, target, subproject) + # As of MVSC 16.8, /std:c11 and /std:c17 are the only valid C standard options. - if std == 'c11': + if std in {'c11'}: args.append('/std:c11') elif std in {'c17', 'c18'}: args.append('/std:c17') return args -class ClangClCCompiler(_ClangCStds, ClangClCompiler, VisualStudioLikeCCompilerMixin, CCompiler): +class ClangClCCompiler(ClangCStds, ClangClCompiler, VisualStudioLikeCCompilerMixin, CCompiler): def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', target: str, linker: T.Optional['DynamicLinker'] = None, @@ -517,9 +473,9 @@ class ClangClCCompiler(_ClangCStds, ClangClCompiler, VisualStudioLikeCCompilerMi full_version=full_version) ClangClCompiler.__init__(self, target) - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - key = self.form_langopt_key('std') - std = options.get_value(key) + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: + std = self.get_compileropt_value('std', env, target, subproject) + assert isinstance(std, str) if std != "none": return [f'/clang:-std={std}'] return [] @@ -540,19 +496,16 @@ class IntelClCCompiler(IntelVisualStudioLikeCompiler, VisualStudioLikeCCompilerM def get_options(self) -> 'MutableKeyedOptionDictType': opts = super().get_options() - key = self.form_langopt_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.') - std_opt = opts.get_value_object(key) + 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']) return opts - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: + args: T.List[str] = [] + std = self.get_compileropt_value('winlibs', env, target, subproject) + assert isinstance(std, str) if std == 'c89': mlog.log("ICL doesn't explicitly implement c89, setting the standard to 'none', which is close.", once=True) elif std != 'none': @@ -576,17 +529,17 @@ class ArmCCompiler(ArmCompiler, CCompiler): ArmCompiler.__init__(self) def get_options(self) -> 'MutableKeyedOptionDictType': - opts = CCompiler.get_options(self) - key = self.form_langopt_key('std') + opts = super().get_options() + 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']) return opts - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + std = self.get_compileropt_value('std', env, target, subproject) + assert isinstance(std, str) if std != 'none': args.append('--' + std) return args @@ -606,8 +559,8 @@ class CcrxCCompiler(CcrxCompiler, CCompiler): return ['-nologo'] def get_options(self) -> 'MutableKeyedOptionDictType': - opts = CCompiler.get_options(self) - key = self.form_langopt_key('std') + opts = super().get_options() + key = self.form_compileropt_key('std') std_opt = opts[key] assert isinstance(std_opt, options.UserStdOption), 'for mypy' std_opt.set_versions(['c89', 'c99']) @@ -616,10 +569,10 @@ class CcrxCCompiler(CcrxCompiler, CCompiler): def get_no_stdinc_args(self) -> T.List[str]: return [] - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + std = self.get_compileropt_value('std', env, target, subproject) + assert isinstance(std, str) if std == 'c89': args.append('-lang=c') elif std == 'c99': @@ -654,8 +607,8 @@ class Xc16CCompiler(Xc16Compiler, CCompiler): Xc16Compiler.__init__(self) def get_options(self) -> 'MutableKeyedOptionDictType': - opts = CCompiler.get_options(self) - key = self.form_langopt_key('std') + opts = super().get_options() + 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) @@ -664,10 +617,10 @@ class Xc16CCompiler(Xc16Compiler, CCompiler): def get_no_stdinc_args(self) -> T.List[str]: return [] - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + std = self.get_compileropt_value('std', env, target, subproject) + assert isinstance(std, str) if std != 'none': args.append('-ansi') args.append('-std=' + std) @@ -700,16 +653,13 @@ class CompCertCCompiler(CompCertCompiler, CCompiler): CompCertCompiler.__init__(self) def get_options(self) -> 'MutableKeyedOptionDictType': - opts = CCompiler.get_options(self) - key = self.form_langopt_key('std') + opts = super().get_options() + key = self.form_compileropt_key('std') std_opt = opts[key] assert isinstance(std_opt, options.UserStdOption), 'for mypy' std_opt.set_versions(['c89', 'c99']) return opts - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - return [] - def get_no_optimization_args(self) -> T.List[str]: return ['-O0'] @@ -738,8 +688,8 @@ class TICCompiler(TICompiler, CCompiler): return [] def get_options(self) -> 'MutableKeyedOptionDictType': - opts = CCompiler.get_options(self) - key = self.form_langopt_key('std') + opts = super().get_options() + 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']) @@ -748,10 +698,10 @@ class TICCompiler(TICompiler, CCompiler): def get_no_stdinc_args(self) -> T.List[str]: return [] - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + std = self.get_compileropt_value('std', env, target, subproject) + assert isinstance(std, str) if std != 'none': args.append('--' + std) return args @@ -778,16 +728,14 @@ class MetrowerksCCompilerARM(MetrowerksCompiler, CCompiler): return mwccarm_instruction_set_args.get(instruction_set, None) def get_options(self) -> 'MutableKeyedOptionDictType': - opts = CCompiler.get_options(self) - c_stds = ['c99'] - key = self.form_langopt_key('std') - opts[key].choices = ['none'] + c_stds + opts = super().get_options() + self._update_language_stds(opts, ['c99']) return opts - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + std = self.get_compileropt_value('std', env, target, subproject) + assert isinstance(std, str) if std != 'none': args.append('-lang') args.append(std) @@ -808,16 +756,25 @@ class MetrowerksCCompilerEmbeddedPowerPC(MetrowerksCompiler, CCompiler): return mwcceppc_instruction_set_args.get(instruction_set, None) def get_options(self) -> 'MutableKeyedOptionDictType': - opts = CCompiler.get_options(self) - c_stds = ['c99'] - key = self.form_langopt_key('std') - opts[key].choices = ['none'] + c_stds + opts = super().get_options() + self._update_language_stds(opts, ['c99']) return opts - def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: + def get_option_std_args(self, target: BuildTarget, env: Environment, subproject: T.Optional[str] = None) -> T.List[str]: args = [] - key = self.form_langopt_key('std') - std = options.get_value(key) + std = self.get_compileropt_value('std', env, target, subproject) + assert isinstance(std, str) if std != 'none': args.append('-lang ' + std) return args + +class TaskingCCompiler(TaskingCompiler, CCompiler): + id = 'tasking' + + def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, + is_cross: bool, info: 'MachineInfo', + linker: T.Optional['DynamicLinker'] = None, + full_version: T.Optional[str] = None): + CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross, + info, linker=linker, full_version=full_version) + TaskingCompiler.__init__(self) |