From e21aead3b383511461097fb662913877f92f25d2 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Thu, 25 Jun 2020 00:55:46 +0200 Subject: [PATCH] Conceal gccdeps/msvcdeps errors on inaccessible/unreadable files --- waflib/extras/gccdeps.py | 27 +++++++++++++++++++-------- waflib/extras/msvcdeps.py | 26 ++++++++++++++++++-------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/waflib/extras/gccdeps.py b/waflib/extras/gccdeps.py index f7b3be88..1fc93734 100644 --- a/waflib/extras/gccdeps.py +++ b/waflib/extras/gccdeps.py @@ -15,7 +15,7 @@ Usage:: conf.load('compiler_cxx gccdeps') """ -import errno, os, re, threading +import os, re, threading from waflib import Task, Logs, Utils, Errors from waflib.Tools import c_preproc from waflib.TaskGen import before_method, feature @@ -163,14 +163,25 @@ def post_run(self): def sig_implicit_deps(self): if not self.__class__.__name__ in self.env.ENABLE_GCCDEPS: return super(self.derived_gccdeps, self).sig_implicit_deps() + bld = self.generator.bld + try: - return Task.Task.sig_implicit_deps(self) - except Errors.WafError: - return Utils.SIG_NIL - except EnvironmentError as e: - if e.errno == errno.ENOENT: - return Utils.SIG_NIL - raise + return self.compute_sig_implicit_deps() + except Errors.TaskNotReady: + raise ValueError("Please specify the build order precisely with gccdeps (asm/c/c++ tasks)") + except EnvironmentError: + # If a file is renamed, assume the dependencies are stale and must be recalculated + for x in bld.node_deps.get(self.uid(), []): + if not x.is_bld() and not x.exists(): + try: + del x.parent.children[x.name] + except KeyError: + pass + + key = self.uid() + bld.node_deps[key] = [] + bld.raw_deps[key] = [] + return Utils.SIG_NIL def wrap_compiled_task(classname): derived_class = type(classname, (Task.classes[classname],), {}) diff --git a/waflib/extras/msvcdeps.py b/waflib/extras/msvcdeps.py index c85c6949..52985dce 100644 --- a/waflib/extras/msvcdeps.py +++ b/waflib/extras/msvcdeps.py @@ -25,7 +25,7 @@ Usage:: conf.load('compiler_cxx msvcdeps') ''' -import errno, os, sys, tempfile, threading +import os, sys, tempfile, threading from waflib import Context, Errors, Logs, Task, Utils from waflib.Tools import c_preproc, c, cxx, msvc @@ -150,15 +150,25 @@ def scan(self): def sig_implicit_deps(self): if self.env.CC_NAME not in supported_compilers: return super(self.derived_msvcdeps, self).sig_implicit_deps() + bld = self.generator.bld try: - return Task.Task.sig_implicit_deps(self) - except Errors.WafError: - return Utils.SIG_NIL - except EnvironmentError as e: - if e.errno == errno.ENOENT: - return Utils.SIG_NIL - raise + return self.compute_sig_implicit_deps() + except Errors.TaskNotReady: + raise ValueError("Please specify the build order precisely with msvcdeps (c/c++ tasks)") + except EnvironmentError: + # If a file is renamed, assume the dependencies are stale and must be recalculated + for x in bld.node_deps.get(self.uid(), []): + if not x.is_bld() and not x.exists(): + try: + del x.parent.children[x.name] + except KeyError: + pass + + key = self.uid() + bld.node_deps[key] = [] + bld.raw_deps[key] = [] + return Utils.SIG_NIL def exec_command(self, cmd, **kw): if self.env.CC_NAME not in supported_compilers: