can be used to avoid cluttering each directory with an individual
.sconsign file.
+ From John Johnson:
+
+ - Fix (re-)scanning of dependencies in generated or installed
+ header files.
+
From Steven Knight:
- The -Q option suppressed too many messages; fix it so that it only
t.set_executor(executor)
if builder.scanner:
t.target_scanner = builder.scanner
+ if not hasattr(t, 'source_scanner'):
+ t.source_scanner = env.get_scanner(t.scanner_key())
# Last, add scanners from the Environment to the source Nodes.
for s in slist:
- src_key = s.scanner_key() # the file suffix
- scanner = env.get_scanner(src_key)
- if scanner:
- s.source_scanner = scanner
+ if not hasattr(s, 'source_scanner'):
+ s.source_scanner = env.get_scanner(s.scanner_key())
class EmitterProxy:
"""This is a callable class that can act as a
env_scanner = TestScanner()
env = Environment()
builder = SCons.Builder.Builder(action='action')
- tgt = builder(env, target='foo.x', source='bar')
+ tgt = builder(env, target='foo.x', source='bar.y')
src = tgt.sources[0]
assert tgt.target_scanner != env_scanner, tgt.target_scanner
- assert src.source_scanner == env_scanner
+ assert src.source_scanner == env_scanner, src.source_scanner
def test_Builder_Args(self):
"""Testing passing extra args to a builder."""
self.abspath_ = self.abspath + os.sep
self.repositories = []
self.srcdir = None
+ self.source_scanner = None
self.entries = {}
self.entries['.'] = self
self.implicit = None # implicit (scanned) dependencies (None means not scanned yet)
self.parents = {}
self.wkids = None # Kids yet to walk, when it's an array
- self.source_scanner = None # implicit scanner from scanner map
self.target_scanner = None # explicit scanner from this node's Builder
+ # If/when this attribute exists, it's an implicit scanner from
+ # the scanner map for an environment. The attribute is created
+ # when we select the scanner, a value of None means there is none.
+ #self.source_scanner = None
+
self.env = None
self.state = None
self.precious = None
# Clear out the implicit dependency caches:
# XXX this really should somehow be made more general and put
# under the control of the scanners.
- if self.source_scanner:
- self.found_includes = {}
- self.includes = None
+ try:
+ scanner = self.source_scanner
+ except AttributeError:
+ pass
+ else:
+ if scanner:
+ self.found_includes = {}
+ self.includes = None
- def get_parents(node, parent): return node.get_parents()
- def clear_cache(node, parent):
- node.implicit = None
- node.del_bsig()
- w = Walker(self, get_parents, ignore_cycle, clear_cache)
- while w.next(): pass
+ def get_parents(node, parent): return node.get_parents()
+ def clear_cache(node, parent):
+ node.implicit = None
+ node.del_bsig()
+ w = Walker(self, get_parents, ignore_cycle, clear_cache)
+ while w.next(): pass
# clear out the content signature, since the contents of this
# node were presumably just changed:
build_env = self.get_build_env()
for child in self.children(scan=0):
- self._add_child(self.implicit,
- self.implicit_dict,
- child.get_implicit_deps(build_env,
- child.source_scanner,
- self))
+ try:
+ scanner = child.source_scanner
+ except AttributeError:
+ pass
+ else:
+ if scanner:
+ self._add_child(self.implicit,
+ self.implicit_dict,
+ child.get_implicit_deps(build_env,
+ scanner,
+ self))
# scan this node itself for implicit dependencies
self._add_child(self.implicit,
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test that dependencies in generated header files get re-scanned correctly.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """\
+def writeFile(target, contents):
+ file = open(str(target[0]), 'wb')
+ file.write(contents)
+ file.close()
+ return 0
+
+env = Environment()
+libgen = env.StaticLibrary('gen', 'gen.cpp')
+Default(libgen)
+env.Command('gen2.h', [],
+ lambda env,target,source: writeFile(target, 'int foo = 3;\\n'))
+env.Command('gen.h', [],
+ lambda env,target,source: writeFile(target, '#include "gen2.h"\\n'))
+env.Command('gen.cpp', [],
+ lambda env,target,source: writeFile(target, '#include "gen.h"\\n'))
+""")
+
+test.run()
+
+test.up_to_date(arguments = '.')
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test that dependencies in installed header files get re-scanned correctly.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+env = Environment(CPPPATH=['#include'])
+Export('env')
+SConscript('dist/SConscript')
+libfoo = env.StaticLibrary('foo', ['foo.c'])
+Default(libfoo)
+""")
+
+test.write('foo.c', """
+#include <h1.h>
+""")
+
+test.subdir('dist')
+
+test.write(['dist', 'SConscript'], """\
+Import('env')
+env.Install('#include', ['h1.h', 'h2.h', 'h3.h'])
+""")
+
+test.write(['dist', 'h1.h'], """\
+#include "h2.h"
+""")
+
+test.write(['dist', 'h2.h'], """\
+#include "h3.h"
+""")
+
+test.write(['dist', 'h3.h'], """\
+int foo = 3;
+""")
+
+test.run(arguments = ".")
+
+test.up_to_date(arguments = ".")
+
+test.pass_test()