[Scons-users] Bug in up_to_date for directory targets
William Blevins
wblevins001 at gmail.com
Mon Mar 20 23:09:43 EDT 2017
Manish,
* Why does my example not work?
SCons Comand Builder parameters are target(s), source(s), command(s):
http://scons.org/doc/HTML/scons-user.html#chap-builders-commands
Foo is the target parameter, and foo-contents.txt is the source parameter.
Targets explicitly depend on sources. In your example, directory foo
depends on source file foo-contents.txt; target file copy does not depend
on source file.
* How do I fix this issue?
1. Call Command Builder correctly: Command('foo', 'foo-contents', 'mkdir
$TARGET') which creates file dependency on directory, and then
Command('foo/foo-contents.txt', 'foo-contents.txt', 'cp $SOURCE $TARGET')
which creates file target dependency on file source.
2: [PREFERRED] Use the SCons FileSystem factory
http://scons.org/doc/HTML/scons-user.html#chap-factories
V/R,
William
On Mon, Mar 20, 2017 at 1:47 PM, Manish Vachharajani <
manishv at unbounded.systems> wrote:
> 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
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170320/327a3f33/attachment-0001.html>
More information about the Scons-users
mailing list