From 6d055b1e27dc6fc0fac967fbe2f439758a4c5d07 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 27 Jul 2021 13:07:18 -0700 Subject: compilers/compilers: Fix some potential issues spotted by pyright There are two changes here, one is to remove an `elif` that is effectively an `else`, that helps the type checker and provides a small speedup potentially. The second is a potentially unbound variable, that currently isn't hit, but very much could be. --- mesonbuild/compilers/compilers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 88ee65f..c71375b 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -773,7 +773,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): # ccache would result in a cache miss no_ccache = True contents = code - elif isinstance(code, mesonlib.File): + else: srcname = code.fname with open(code.fname, encoding='utf-8') as f: contents = f.read() @@ -781,11 +781,13 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): # Construct the compiler command-line commands = self.compiler_args() commands.append(srcname) + # Preprocess mode outputs to stdout, so no output args + output = self._get_compile_output(tmpdirname, mode) if mode != 'preprocess': - output = self._get_compile_output(tmpdirname, mode) commands += self.get_output_args(output) commands.extend(self.get_compiler_args_for_mode(CompileCheckMode(mode))) + # extra_args must be last because it could contain '/link' to # pass args to VisualStudio's linker. In that case everything # in the command line after '/link' is given to the linker. -- cgit v1.1