From 604465ba32b0ccc1966c99b1c466823233768edf Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sun, 6 Nov 2005 23:00:32 +0000 Subject: [PATCH] Do not throw an exception if the type of a stored implicit dependency has changed since last run. (Dobes Vandermeer) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1384 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 4 + src/engine/SCons/Node/__init__.py | 17 +++- test/changed-node.py | 142 ++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 test/changed-node.py diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 8bf385ff..4e8e377a 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -739,6 +739,10 @@ RELEASE 0.97 - XXX external environment, or settable internally) to put a shortened SCons execution line in the Visual Studio project file. + - Don't throw an exception if the configuration changes and a stored + implicit dependency now has a different type (File or Dir) than it + did last time. + From Greg Ward: - Fix a misplaced line in the man page. diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index b04284d3..e73e5f38 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -516,8 +516,21 @@ class Node: implicit = self.get_stored_implicit() if implicit: factory = build_env.get_factory(self.builder.source_factory) - implicit = map(factory, implicit) - self._add_child(self.implicit, self.implicit_dict, implicit) + nodes = [] + for i in implicit: + try: + n = factory(i) + except TypeError: + # The implicit dependency was cached as one type + # of Node last time, but the configuration has + # changed (probably) and it's a different type + # this time. Just ignore the mismatch and go + # with what our current configuration says the + # Node is. + pass + else: + nodes.append(n) + self._add_child(self.implicit, self.implicit_dict, nodes) calc = build_env.get_calculator() if implicit_deps_unchanged or self.current(calc): return diff --git a/test/changed-node.py b/test/changed-node.py new file mode 100644 index 00000000..99a16acd --- /dev/null +++ b/test/changed-node.py @@ -0,0 +1,142 @@ +#!/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__" + +""" +Verify that we don't throw an exception if a stored implicit +dependency has changed +""" + +import TestSCons + +test = TestSCons.TestSCons() + + + +test.subdir('d', + ['d', '1'], + ['d', '2'], + ['d', '3']) + +test.write('SConstruct', """\ +SetOption('implicit_cache', 1) +SetOption('max_drift', 1) +SourceCode('.', None) + +def lister(target, source, env): + import os + fp = open(str(target[0]), 'w') + s = str(source[0]) + if os.path.isdir(s): + for l in os.listdir(str(source[0])): + fp.write(l + '\\n') + else: + fp.write(s + '\\n') + fp.close() + +builder = Builder(action=lister, + source_factory=Dir, + source_scanner=DirScanner) +env = Environment(tools=[]) +env['BUILDERS']['builder'] = builder +env.builder('d/xfactor', 'd/1') +env.builder('a', 'd') +""") + +test.write(['d', '1', 'x'], "d/1/x\n") +test.write(['d', '1', 'y'], "d/1/y\n") +test.write(['d', '1', 'z'], "d/1/z\n") +test.write(['d', '2', 'x'], "d/2/x\n") +test.write(['d', '2', 'y'], "d/2/y\n") +test.write(['d', '2', 'z'], "d/2/x\n") +test.write(['d', '3', 'x'], "d/3/x\n") +test.write(['d', '3', 'y'], "d/3/y\n") +test.write(['d', '3', 'z'], "d/3/z\n") + +test.run('--debug=stacktrace') + + + +test.write('SConstruct', """\ +SetOption('implicit_cache', 1) +SetOption('max_drift', 1) +SourceCode('.', None) + +def lister(target, source, env): + import os.path + fp = open(str(target[0]), 'w') + s = str(source[0]) + if os.path.isdir(s): + for l in os.listdir(str(source[0])): + fp.write(l + '\\n') + else: + fp.write(s + '\\n') + fp.close() + +builder = Builder(action=lister, + source_factory=File) +env = Environment(tools=[]) +env['BUILDERS']['builder'] = builder + +env.builder('a', 'SConstruct') +""") + +test.run('--debug=stacktrace') + +test.pass_test() + + + + +#from os import system, rmdir, remove, mkdir, listdir +#from os.path import exists, isdir +#import sys +# +# +#def setfile(f, content): +# f = open(f, 'w') +# try: f.write(content) +# finally: f.close() +# +#def checkfile(f, content): +# assert open(f).read().strip() == content +# +#def rm(f): +# if exists(f): +# if isdir(f): +# for name in listdir(f): +# rm(f+'/'+name) +# rmdir(f) +# else: remove(f) +#def clean(full=0): +# for f in ('d','b','a','SConstruct'): +# rm(f) +# if full: +# for f in ('.sconsign.dblite', 'build.py'): +# rm(f) +# +#clean(1) +# +#clean(1) -- 2.26.2