aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-04-18 11:40:50 -0700
committerDylan Baker <dylan@pnwbakers.com>2024-04-18 13:12:15 -0700
commit9e3b3db7054c7dedecd14db3e6061ff7e2227faf (patch)
tree0ee374560547dc2f80399d1f0b58b153490ed522 /mesonbuild
parent46b3c1c30df60f00c3505c802039407ebfb6f381 (diff)
downloadmeson-9e3b3db7054c7dedecd14db3e6061ff7e2227faf.zip
meson-9e3b3db7054c7dedecd14db3e6061ff7e2227faf.tar.gz
meson-9e3b3db7054c7dedecd14db3e6061ff7e2227faf.tar.bz2
backend/ninja: Fix cases where None is passed when unexpected
When getting debug file arguments we can sometimes pass None, where a None is unexpected. This becomes a particular problem in the Cuda compiler, where the output will unconditionally be concatenated with a static string, resulting in an uncaught exception. This is really easy to spot once we annotate the functions in question, where a static type checker like mypy easily spots the issue. This commit adds those annotations, and then fixes the resulting error. Fixes: #12997
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/ninjabackend.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index acd401e..bb03f01 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2012-2017 The Meson development team
-# Copyright © 2023 Intel Corporation
+# Copyright © 2023-2024 Intel Corporation
from __future__ import annotations
@@ -2767,11 +2767,17 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
else:
return compiler.get_compile_debugfile_args(objfile, pch=False)
- def get_link_debugfile_name(self, linker, target) -> T.Optional[str]:
- return linker.get_link_debugfile_name(self.get_target_debug_filename(target))
+ def get_link_debugfile_name(self, linker: T.Union[Compiler, StaticLinker], target: build.BuildTarget) -> T.Optional[str]:
+ filename = self.get_target_debug_filename(target)
+ if filename:
+ return linker.get_link_debugfile_name(filename)
+ return None
- def get_link_debugfile_args(self, linker, target):
- return linker.get_link_debugfile_args(self.get_target_debug_filename(target))
+ def get_link_debugfile_args(self, linker: T.Union[Compiler, StaticLinker], target: build.BuildTarget) -> T.List[str]:
+ filename = self.get_target_debug_filename(target)
+ if filename:
+ return linker.get_link_debugfile_args(filename)
+ return []
def generate_llvm_ir_compile(self, target, src: mesonlib.FileOrString):
base_proxy = target.get_options()