[Scons-users] Bug in up_to_date for directory targets

Manish Vachharajani manishv at unbounded.systems
Mon Mar 20 13:47:51 EDT 2017


I believe there is a bug in how up to date is computed for file nodes and
directory targets.  Below is a SConstruct and run output illustrating the
bug.

##############
# SConstruct
env = Environment()
targets = env.Command('foo',
                      'foo-contents.txt',
                      ['mkdir foo',
                       'cp foo-contents.txt foo'])
env.Default(targets)

##############
# Shell log

# Create the file that will be installed into foo/foo-contents.txt
$ echo "Hello, " >> foo-contents.txt
# All is well, scons runs the command builder as expected
$ scons

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
mkdir foo
cp foo-contents.txt foo
scons: done building targets.

# All is well, the target is up to date as expected
$ scons

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `foo' is up to date.
scons: done building targets.

# Uh-oh, source is updated but the target is considered up to date!
$ echo "World!" >> foo-contents.txt
$ scons

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `foo' is up to date.
scons: done building targets.

For the bug to trigger, all targets for a builder must be directories.  The
target directory must exist and the source file must exist and be out of
date due to a content update (resulting in a signature mismatch).

I think the problem is that is_up_to_date for File nodes only checks the
signatures of its children, which avoids this bug as long as one of the
builder targets is a File and not a Directory.  However, I haven't done
enough analysis to be sure that this is the issue.

A work around is to make sure that you have a file (or create a dummy
.built file) and include it as a target.

This is showing up specifically for us when trying to calculate
dependencies for a package manager (npm) where we have no insight into the
contents of the resulting directory.

Manish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170320/8a566487/attachment.html>


More information about the Scons-users mailing list