diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 7d90ac1f4..bbaeef339 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2824,7 +2824,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) element.add_dep(pch_dep) for i in self.get_fortran_orderdeps(target, compiler): element.add_orderdep(i) - element.add_item('DEPFILE', dep_file) + if dep_file: + element.add_item('DEPFILE', dep_file) element.add_item('ARGS', commands) self.add_dependency_scanner_entries_to_element(target, compiler, element, src) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 147ca4633..d54d06df8 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1147,7 +1147,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): def get_include_args(self, path: str, is_system: bool) -> T.List[str]: return [] - def depfile_for_object(self, objfile: str) -> str: + def depfile_for_object(self, objfile: str) -> T.Optional[str]: return objfile + '.' + self.get_depfile_suffix() def get_depfile_suffix(self) -> str: diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py index 6d434ae4d..998e5dfbd 100644 --- a/mesonbuild/compilers/swift.py +++ b/mesonbuild/compilers/swift.py @@ -59,7 +59,7 @@ class SwiftCompiler(Compiler): def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]: return ['-emit-dependencies'] - def depfile_for_object(self, objfile: str) -> str: + def depfile_for_object(self, objfile: str) -> T.Optional[str]: return os.path.splitext(objfile)[0] + '.' + self.get_depfile_suffix() def get_depfile_suffix(self) -> str: