From 11b17085f862e0e9598a7f1509daa4f5abf2ee87 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 13 Nov 2025 11:26:35 -0800 Subject: compilers: Remove Environment parameter from CLikeCompiler.has_arguments --- mesonbuild/compilers/mixins/clike.py | 6 +++--- mesonbuild/compilers/mixins/gnu.py | 2 +- mesonbuild/compilers/mixins/visualstudio.py | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 85ff469ad..e031e38b6 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -1281,7 +1281,7 @@ class CLikeCompiler(Compiler): def linker_to_compiler_args(self, args: T.List[str]) -> T.List[str]: return args.copy() - def has_arguments(self, args: T.List[str], env: 'Environment', code: str, + def has_arguments(self, args: T.List[str], code: str, mode: CompileCheckMode) -> T.Tuple[bool, bool]: return self.compiles(code, extra_args=args, mode=mode) @@ -1317,7 +1317,7 @@ class CLikeCompiler(Compiler): 'the compiler you are using. has_link_argument or ' 'other similar method can be used instead.') new_args.append(arg) - return self.has_arguments(new_args, self.environment, code, mode=CompileCheckMode.COMPILE) + return self.has_arguments(new_args, code, mode=CompileCheckMode.COMPILE) def has_multi_arguments(self, args: T.List[str]) -> T.Tuple[bool, bool]: return self._has_multi_arguments(args, 'extern int i;\nint i;\n') @@ -1325,7 +1325,7 @@ class CLikeCompiler(Compiler): def _has_multi_link_arguments(self, args: T.List[str], code: str) -> T.Tuple[bool, bool]: args = self.linker.fatal_warnings() + args args = self.linker_to_compiler_args(args) - return self.has_arguments(args, self.environment, code, mode=CompileCheckMode.LINK) + return self.has_arguments(args, code, mode=CompileCheckMode.LINK) def has_multi_link_arguments(self, args: T.List[str]) -> T.Tuple[bool, bool]: return self._has_multi_link_arguments(args, 'int main(void) { return 0; }\n') diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index e76ee7dc5..c08bce0d5 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -602,7 +602,7 @@ class GnuCompiler(GnuLikeCompiler): def openmp_flags(self) -> T.List[str]: return ['-fopenmp'] - def has_arguments(self, args: T.List[str], env: 'Environment', code: str, + def has_arguments(self, args: T.List[str], code: str, mode: CompileCheckMode) -> T.Tuple[bool, bool]: # For some compiler command line arguments, the GNU compilers will # emit a warning on stderr indicating that an option is valid for a diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index bd70ec1ab..ac2468956 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -21,7 +21,6 @@ from mesonbuild.linkers.linkers import ClangClDynamicLinker if T.TYPE_CHECKING: from ...build import BuildTarget - from ...environment import Environment from ...dependencies import Dependency from .clike import CLikeCompiler as Compiler else: @@ -295,7 +294,7 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): # Visual Studio is special. It ignores some arguments it does not # understand and you can't tell it to error out on those. # http://stackoverflow.com/questions/15259720/how-can-i-make-the-microsoft-c-compiler-treat-unknown-flags-as-errors-rather-t - def has_arguments(self, args: T.List[str], env: 'Environment', code: str, mode: CompileCheckMode) -> T.Tuple[bool, bool]: + def has_arguments(self, args: T.List[str], code: str, mode: CompileCheckMode) -> T.Tuple[bool, bool]: warning_text = '4044' if mode == CompileCheckMode.LINK else '9002' with self._build_wrapper(code, extra_args=args, mode=mode) as p: if p.returncode != 0: @@ -452,10 +451,10 @@ class ClangClCompiler(VisualStudioLikeCompiler): self.can_compile_suffixes.add('s') self.can_compile_suffixes.add('sx') - def has_arguments(self, args: T.List[str], env: 'Environment', code: str, mode: CompileCheckMode) -> T.Tuple[bool, bool]: + def has_arguments(self, args: T.List[str], code: str, mode: CompileCheckMode) -> T.Tuple[bool, bool]: if mode != CompileCheckMode.LINK: args = args + ['-Werror=unknown-argument', '-Werror=unknown-warning-option'] - return super().has_arguments(args, env, code, mode) + return super().has_arguments(args, code, mode) def get_toolset_version(self) -> T.Optional[str]: # XXX: what is the right thing to do here? -- cgit v1.2.3