# 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.
#
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.
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
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)
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.
binfo = self.new_binfo()
- self.scan()
+ if scan:
+ self.scan()
sources = self.filter_ignore(self.sources)
depends = self.filter_ignore(self.depends)
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)
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)
""")
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'],
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', """
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', """
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()