From: stevenknight Date: Tue, 17 Aug 2004 22:18:29 +0000 (+0000) Subject: Put back --implicit-cache, having it use the --debug=explain info instead of its... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ea665653334dbae82598c5893d9c03c6fa4cdd94;p=scons.git Put back --implicit-cache, having it use the --debug=explain info instead of its own dependencies. (Anthony Roach) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1033 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index aa332c2e..b10657c7 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1447,7 +1447,7 @@ class File(Base): # in one build (SConstruct file) is a source in a different build. # See test/chained-build.py for the use case. entry = self.get_stored_info() - if not SCons.Node.Save_Explain_Info: + if not SCons.Node.Save_Explain_Info and not SCons.Node.implicit_cache: # If we're not saving explanation info, wipe out any that # might be in the already-stored entry. # @@ -1489,7 +1489,11 @@ class File(Base): return BuildInfo() def get_stored_implicit(self): - return self.dir.sconsign().get_implicit(self.name) + binfo = self.get_stored_info() + try: + return binfo.bimplicit + except AttributeError: + return None def get_found_includes(self, env, scanner, target): """Return the included implicit dependencies in this file. @@ -1769,7 +1773,7 @@ class File(Base): return csig - def current(self, calc=None): + def current(self, calc=None, scan=1): self.binfo = self.gen_binfo(calc) if self.always_build: return None diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 603762ec..be5e21c8 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -419,27 +419,23 @@ class Node: build_env = self.get_build_env() - # XXX Here's where we implement --implicit-cache. This doesn't - # do anything right now, but we're probably going to re-implement - # as a way to cache #include lines from source files, so I want - # to keep this code around for now. - # - #if implicit_cache and not implicit_deps_changed: - # implicit = self.get_stored_implicit() - # if implicit is not None: - # implicit = map(self.implicit_factory, implicit) - # self._add_child(self.implicit, self.implicit_dict, implicit) - # calc = build_env.get_calculator() - # if implicit_deps_unchanged or calc.current(self, calc.bsig(self)): - # return - # else: - # # one of this node's sources has changed, so - # # we need to recalculate the implicit deps, - # # and the bsig: - # self.implicit = [] - # self.implicit_dict = {} - # self._children_reset() - # self.del_binfo() + # Here's where we implement --implicit-cache. + if implicit_cache and not implicit_deps_changed: + implicit = self.get_stored_implicit() + if implicit is not None: + implicit = map(self.implicit_factory, implicit) + self._add_child(self.implicit, self.implicit_dict, implicit) + calc = build_env.get_calculator() + if implicit_deps_unchanged or self.current(calc, scan=0): + return + else: + # one of this node's sources has changed, so + # we need to recalculate the implicit deps, + # and the bsig: + self.implicit = [] + self.implicit_dict = {} + self._children_reset() + self.del_binfo() for child in self.children(scan=0): scanner = self.get_source_scanner(child) @@ -512,7 +508,7 @@ class Node: self.binfo = self.gen_binfo(calc) return self.binfo.bsig - def gen_binfo(self, calc=None): + def gen_binfo(self, calc=None, scan=1): """ Generate a node's build signature, the digested signatures of its dependency files and build information. @@ -532,7 +528,8 @@ class Node: binfo = self.new_binfo() - self.scan() + if scan: + self.scan() sources = self.filter_ignore(self.sources) depends = self.filter_ignore(self.depends) @@ -555,7 +552,7 @@ class Node: bactsig = calc.module.signature(executor) sigs.append(bactsig) - if Save_Explain_Info: + if Save_Explain_Info or implicit_cache: binfo.bsources = map(str, sources) binfo.bdepends = map(str, depends) binfo.bimplicit = map(str, implicit) diff --git a/test/option--implicit-cache.py b/test/option--implicit-cache.py index 56c65865..dc4f5190 100644 --- a/test/option--implicit-cache.py +++ b/test/option--implicit-cache.py @@ -203,6 +203,46 @@ test.run(program = test.workpath(variant_prog), test.up_to_date(arguments = args) +# Add inc2/foo.h that should shadow include/foo.h, but +# because of implicit dependency caching, scons doesn't +# detect this: +test.write(['inc2', 'foo.h'], +r""" +#define FOO_STRING "inc2/foo.h 1\n" +#include +""") + +test.run(arguments = "--implicit-cache " + args) + +test.run(arguments = "--implicit-cache " + args) + +test.run(program = test.workpath(prog), + stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 1\n") + +test.run(program = test.workpath(subdir_prog), + stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n") + +test.run(program = test.workpath(variant_prog), + stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 1\n") + +# Now modifying include/foo.h should make scons aware of inc2/foo.h +test.write(['include', 'foo.h'], +r""" +#define FOO_STRING "include/foo.h 3\n" +#include "bar.h" +""") + +test.run(arguments = "--implicit-cache " + args) + +test.run(program = test.workpath(prog), + stdout = "subdir/prog.c\ninc2/foo.h 1\ninclude/bar.h 1\n") + +test.run(program = test.workpath(subdir_prog), + stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n") + +test.run(program = test.workpath(variant_prog), + stdout = "subdir/prog.c\ninclude/foo.h 3\ninclude/bar.h 1\n") + # test in the face of a file with no dependencies where the source file is generated: test.run(arguments = "--implicit-cache nodeps%s"%_exe) @@ -246,10 +286,10 @@ r""" """) test.run(arguments = "--implicit-deps-unchanged " + variant_prog) -#XXX#assert string.find(test.stdout(), 'is up to date') != -1, test.stdout() +assert string.find(test.stdout(), 'is up to date') != -1, test.stdout() test.run(arguments = variant_prog) -#XXX#assert string.find(test.stdout(), 'is up to date') == -1, test.stdout() +assert string.find(test.stdout(), 'is up to date') == -1, test.stdout() # Test forcing rescanning: test.write(['include', 'foo.h'], @@ -279,7 +319,7 @@ test.run(arguments = "--implicit-deps-unchanged " + variant_prog) assert string.find(test.stdout(), 'is up to date') != -1, test.stdout() test.run(arguments = "--implicit-deps-changed " + variant_prog) -#XXX#assert string.find(test.stdout(), 'is up to date') == -1, test.stdout() +assert string.find(test.stdout(), 'is up to date') == -1, test.stdout() # Test that Set/GetOption('implicit_cache') works: test.write('SConstruct', """ @@ -298,8 +338,6 @@ assert GetOption('implicit_cache') test.run(arguments='--implicit-cache') -test.pass_test() - # Test to make sure SetOption('implicit_cache', 1) actually enables implicit caching # by detecting the one case where implicit caching causes inaccurate builds: test.write('SConstruct', """ @@ -332,47 +370,5 @@ test.write('i1/foo.h', """ test.run() -# Add inc2/foo.h that should shadow include/foo.h, but -# because of implicit dependency caching, scons doesn't -# detect this: -test.write(['inc2', 'foo.h'], -r""" -#define FOO_STRING "inc2/foo.h 1\n" -#include -""") - -test.run(arguments = "--implicit-cache " + args) -print test.stdout() - -test.run(arguments = "--implicit-cache " + args) -print test.stdout() - -test.run(program = test.workpath(prog), - stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 1\n") - -test.run(program = test.workpath(subdir_prog), - stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n") - -test.run(program = test.workpath(variant_prog), - stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 1\n") - -# Now modifying include/foo.h should make scons aware of inc2/foo.h -test.write(['include', 'foo.h'], -r""" -#define FOO_STRING "include/foo.h 3\n" -#include "bar.h" -""") - -test.run(arguments = "--implicit-cache " + args) - -test.run(program = test.workpath(prog), - stdout = "subdir/prog.c\ninc2/foo.h 1\ninclude/bar.h 1\n") - -test.run(program = test.workpath(subdir_prog), - stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n") - -test.run(program = test.workpath(variant_prog), - stdout = "subdir/prog.c\ninclude/foo.h 3\ninclude/bar.h 1\n") - test.pass_test()