Put back --implicit-cache, having it use the --debug=explain info instead of its...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 17 Aug 2004 22:18:29 +0000 (22:18 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 17 Aug 2004 22:18:29 +0000 (22:18 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1033 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/FS.py
src/engine/SCons/Node/__init__.py
test/option--implicit-cache.py

index aa332c2e93d1b4d5241ffa4edecc4de9c0992507..b10657c72384e79a36cbff7b728b6453c97201c8 100644 (file)
@@ -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
index 603762ec1fed6cfab6424a5f5ac0617c853471d3..be5e21c87fbe7c5b1980ab2386427788be07d3d4 100644 (file)
@@ -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)
index 56c6586576cdf8bddee5cc612eb313d2ef9de0b3..dc4f51901020fc9758ad8ad123c2db13809d6d91 100644 (file)
@@ -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 <bar.h>
+""")
+
+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 <bar.h>
-""")
-
-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()