From 1624354f33bf0a33f0e715ba1ca391ae0154ad19 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 15:12:36 -0500 Subject: Use CompileCheckMode enum There were a ton of naked strings with TODOs telling us to use the enum. --- mesonbuild/compilers/cpp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mesonbuild/compilers/cpp.py') diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 2605670..f17b0d2 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -26,6 +26,7 @@ from .compilers import ( gnu_winlibs, msvc_winlibs, Compiler, + CompileCheckMode, ) from .c_function_attributes import CXX_FUNC_ATTRIBUTES, C_FUNC_ATTRIBUTES from .mixins.clike import CLikeCompiler @@ -43,7 +44,6 @@ from .mixins.metrowerks import MetrowerksCompiler from .mixins.metrowerks import mwccarm_instruction_set_args, mwcceppc_instruction_set_args if T.TYPE_CHECKING: - from .compilers import CompileCheckMode from ..coredata import MutableKeyedOptionDictType, KeyedOptionDictType from ..dependencies import Dependency from ..envconfig import MachineInfo @@ -129,7 +129,7 @@ class CPPCompiler(CLikeCompiler, Compiler): # 2. even if it did have an env object, that might contain another more # recent -std= argument, which might lead to a cascaded failure. CPP_TEST = 'int i = static_cast(0);' - with self.compile(CPP_TEST, extra_args=[cpp_std_value], mode='compile') as p: + with self.compile(CPP_TEST, extra_args=[cpp_std_value], mode=CompileCheckMode.COMPILE) as p: if p.returncode == 0: mlog.debug(f'Compiler accepts {cpp_std_value}:', 'YES') return True -- cgit v1.1 From d4bcf05c39e650d9651b5f2c60e7c12d59367e9c Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 17:47:12 -0500 Subject: Annotate naked fundamental Python types Although mypy wasn't complaining, pyright was. --- mesonbuild/compilers/cpp.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'mesonbuild/compilers/cpp.py') diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index f17b0d2..cd1ed93 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -266,7 +266,7 @@ class ClangCPPCompiler(_StdCPPLibMixin, ClangCompiler, CPPCompiler): return opts def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] + args: T.List[str] = [] key = OptionKey('std', machine=self.for_machine, lang=self.language) std = options[key] if std.value != 'none': @@ -318,7 +318,7 @@ class EmscriptenCPPCompiler(EmscriptenMixin, ClangCPPCompiler): defines=defines, full_version=full_version) def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] + args: T.List[str] = [] key = OptionKey('std', machine=self.for_machine, lang=self.language) std = options[key] if std.value != 'none': @@ -362,7 +362,7 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler): return opts def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] + args: T.List[str] = [] key = OptionKey('std', machine=self.for_machine, lang=self.language) std = options[key] if std.value != 'none': @@ -428,7 +428,7 @@ class GnuCPPCompiler(_StdCPPLibMixin, GnuCompiler, CPPCompiler): return opts def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] + args: T.List[str] = [] key = OptionKey('std', machine=self.for_machine, lang=self.language) std = options[key] if std.value != 'none': @@ -539,7 +539,7 @@ class ElbrusCPPCompiler(ElbrusCompiler, CPPCompiler): # Elbrus C++ compiler does not support RTTI, so don't check for it. def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] + args: T.List[str] = [] key = OptionKey('std', machine=self.for_machine, lang=self.language) std = options[key] if std.value != 'none': @@ -600,7 +600,7 @@ class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler): return opts def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] + args: T.List[str] = [] key = OptionKey('std', machine=self.for_machine, lang=self.language) std = options[key] if std.value != 'none': @@ -667,7 +667,7 @@ class VisualStudioLikeCPPCompilerMixin(CompilerMixinBase): return opts def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] + args: T.List[str] = [] key = OptionKey('std', machine=self.for_machine, lang=self.language) eh = options[key.evolve('eh')] @@ -832,7 +832,7 @@ class ArmCPPCompiler(ArmCompiler, CPPCompiler): return opts def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] + args: T.List[str] = [] key = OptionKey('std', machine=self.for_machine, lang=self.language) std = options[key] if std.value == 'c++11': @@ -892,7 +892,7 @@ class TICPPCompiler(TICompiler, CPPCompiler): return opts def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] + args: T.List[str] = [] key = OptionKey('std', machine=self.for_machine, lang=self.language) std = options[key] if std.value != 'none': @@ -931,7 +931,7 @@ class MetrowerksCPPCompilerARM(MetrowerksCompiler, CPPCompiler): return opts def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] + args: T.List[str] = [] std = options[OptionKey('std', machine=self.for_machine, lang=self.language)] if std.value != 'none': args.append('-lang') @@ -960,7 +960,7 @@ class MetrowerksCPPCompilerEmbeddedPowerPC(MetrowerksCompiler, CPPCompiler): return opts def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: - args = [] + args: T.List[str] = [] std = options[OptionKey('std', machine=self.for_machine, lang=self.language)] if std.value != 'none': args.append('-lang ' + std.value) -- cgit v1.1 From dc692d98fc48f8d5c6ea528adc6dce481412b02f Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 17:52:10 -0500 Subject: Make CPPCompiler.get_display_language() a classmethod This matches the parent declaration. --- mesonbuild/compilers/cpp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mesonbuild/compilers/cpp.py') diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index cd1ed93..be5c083 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -82,8 +82,8 @@ class CPPCompiler(CLikeCompiler, Compiler): full_version=full_version) CLikeCompiler.__init__(self, exe_wrapper) - @staticmethod - def get_display_language() -> str: + @classmethod + def get_display_language(cls) -> str: return 'C++' def get_no_stdinc_args(self) -> T.List[str]: -- cgit v1.1 From 33c8362a1cdd57dd60c7be8fdf3b0566ccdeb3bf Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 17:56:18 -0500 Subject: Match the method signatures of parent classes Names and types of some methods did not match their parent methods. --- mesonbuild/compilers/cpp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mesonbuild/compilers/cpp.py') diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index be5c083..bb1ebb5 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -867,8 +867,8 @@ class CcrxCPPCompiler(CcrxCompiler, CPPCompiler): def get_compile_only_args(self) -> T.List[str]: return [] - def get_output_args(self, target: str) -> T.List[str]: - return [f'-output=obj={target}'] + def get_output_args(self, outputname: str) -> T.List[str]: + return [f'-output=obj={outputname}'] def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]: return [] -- cgit v1.1