[Scons-users] Value nodes and --debug=explain

Matthew Ryan mjr at centauri.org
Thu Oct 29 16:31:47 EDT 2015


I've noticed that, if I use Value nodes as sources, if one changes, then the
explain output claims that ALL the Value node sources are completely
different.  That is, for a Value that did not change, it claims it is both no
longer a dependency, and also a new dependency.  I would think it should
only emit messages about Values that actually changed.

For the following SConstruct:
    env = Environment()

    sources = [
        env.Value('a'),
        env.Value('b'),
    ]
    env.Command('tgt', sources, [
        'touch $TARGET'
    ])

If, after building once, I change the 'b' Value to 'c', then I see:
    $ scons --debug=explain
    scons: Reading SConscript files ...
    scons: done reading SConscript files.
    scons: Building targets ...
    scons: rebuilding `tgt' because:
               `a' is no longer a dependency
               `b' is no longer a dependency
               `a' is a new dependency
               `c' is a new dependency
    touch tgt
    scons: done building targets.


The cause here seems to that, in SCons.Node.explain(), when it checks
whether a given node from the old_bkids is in new_kids, and vice-versa, the
check always fails, because env.Value('a') != env.Value('a'), and because
there's no __hash__ override, the object id is used when doing lookups of
nodes as keys in osig (a dictionary).

So, if I add the following to SCons.Node.Python.Value:
    def __eq__(self, other):
        if isinstance(other, Value):
            return self.value == other.value
        return False

    def __hash__(self):
        return hash(self.value)

Then I get output more inline with what I'd expect:
    $ scons --debug=explain
    scons: Reading SConscript files ...
    scons: done reading SConscript files.
    scons: Building targets ...
    scons: rebuilding `tgt' because:
               `c' is no longer a dependency
               `d' is a new dependency
    touch tgt
    scons: done building targets.

However, I wonder if perhaps I'm missing something obvious that doesn't
require a code change to SCons?

I've tested both 2.3.2 and 2.4; both have the same behavior.

 - Matt


More information about the Scons-users mailing list