From 2c4d772e3d48ca711599b0028b51c4d8c50dcba6 Mon Sep 17 00:00:00 2001 From: ita Date: Fri, 4 May 2012 09:25:48 +0200 Subject: [PATCH] Issue 1162 --- demos/c/stlib/wscript_build | 6 +++++- waflib/extras/gccdeps.py | 23 +++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/demos/c/stlib/wscript_build b/demos/c/stlib/wscript_build index c591ed67..2d826213 100644 --- a/demos/c/stlib/wscript_build +++ b/demos/c/stlib/wscript_build @@ -14,5 +14,9 @@ def r1(self): import time time.sleep(1) self.outputs[0].write(' ') -bld(rule=r1, target='foo.h') # when in doubt, add before=['c', 'cxx'] +bld(rule=r1, target='foo.h', before=['c']) + +# the default scanner may enforce the build order on generated headers, but it is just +# better and faster to set before=['c', 'cxx'] explicitly +# the dependency processing for 'gccdeps' also requires it diff --git a/waflib/extras/gccdeps.py b/waflib/extras/gccdeps.py index 8b218f75..e84560ea 100644 --- a/waflib/extras/gccdeps.py +++ b/waflib/extras/gccdeps.py @@ -16,20 +16,22 @@ lock = threading.Lock() preprocessor_flag = '-MD' -@feature('cc') -@before_method('apply_core') +@feature('c') +@before_method('process_source') def add_mmd_cc(self): - if self.env.get_flat('CFLAGS').find(preprocessor_flag) < 0: + if self.env.CC_NAME in ('gcc', 'icc') and self.env.get_flat('CFLAGS').find(preprocessor_flag) < 0: self.env.append_value('CFLAGS', [preprocessor_flag]) @feature('cxx') -@before_method('apply_core') +@before_method('process_source') def add_mmd_cxx(self): - if self.env.get_flat('CXXFLAGS').find(preprocessor_flag) < 0: + if self.env.CC_NAME in ('gcc', 'icc') and self.env.get_flat('CXXFLAGS').find(preprocessor_flag) < 0: self.env.append_value('CXXFLAGS', [preprocessor_flag]) def scan(self): "the scanner does not do anything initially" + if self.env.CC_NAME not in ('gcc', 'icc'): + return self.no_gccdeps_scan() nodes = self.generator.bld.node_deps.get(self.uid(), []) names = [] return (nodes, names) @@ -38,6 +40,9 @@ re_o = re.compile("\.o$") def post_run(self): # The following code is executed by threads, it is not safe, so a lock is needed... + if self.env.CC_NAME not in ('gcc', 'icc'): + return self.no_gccdeps_post_run() + if getattr(self, 'cached', None): return Task.Task.post_run(self) @@ -106,17 +111,23 @@ def post_run(self): Task.Task.post_run(self) def sig_implicit_deps(self): + if self.env.CC_NAME not in ('gcc', 'icc'): + return self.no_gccdeps_sig_implicit_deps() try: return Task.Task.sig_implicit_deps(self) except Errors.WafError: return Utils.SIG_NIL -for name in 'cc cxx'.split(): +for name in 'c cxx'.split(): try: cls = Task.classes[name] except KeyError: pass else: + cls.no_gccdeps_post_run = cls.post_run + cls.no_gccdeps_scan = cls.scan + cls.no_gccdeps_sig_implicit_deps = cls.sig_implicit_deps + cls.post_run = post_run cls.scan = scan cls.sig_implicit_deps = sig_implicit_deps