aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-07-27 13:07:18 -0700
committerDylan Baker <dylan@pnwbakers.com>2021-08-16 16:21:51 -0700
commit6d055b1e27dc6fc0fac967fbe2f439758a4c5d07 (patch)
treeb44abcb658f1340175ad0177d1efeaf4bd3c56d0
parent272674e792fa241036c879eee22206fa5af8beef (diff)
downloadmeson-6d055b1e27dc6fc0fac967fbe2f439758a4c5d07.zip
meson-6d055b1e27dc6fc0fac967fbe2f439758a4c5d07.tar.gz
meson-6d055b1e27dc6fc0fac967fbe2f439758a4c5d07.tar.bz2
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.
-rw-r--r--mesonbuild/compilers/compilers.py6
1 files changed, 4 insertions, 2 deletions
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.