[Scons-users] cache + sideeffect not working as expected ?
Dirk Bächle
tshortik at gmx.de
Thu Dec 6 13:25:40 EST 2012
Hi Julien,
On 05.12.2012 14:09, Julien Pommier wrote:
> Hi,
>
> I'm a bit puzzled by the behaviour of the cache when sideeffects are
> specified. See this very simple example:
>
> [...]
> Only foo was retrieved from the cache, bar is not retrieved or rebuilt
> while I did ask explicitely for it. Is there something I did not
> understand about the meaning of the SideEffect function, or is this a
> bug in scons ?
>
you can even trim down your example to:
env = Environment()
env.Command(['foo'], [], 'touch foo && touch bar')
env.SideEffect('bar','foo')
Default('foo')
and will get the same behaviour, without any CacheDir involved. If you
define a file as SideEffect, you declare it to be a by-product of your
build step. It gets removed on a "scons -c", because it might still be
there from a previous build. But it is not a real target for SCons, and
this is intended behaviour.
Some additional info about SideEffect: it is a method reserved for the
special case where your build step emits not only the required target,
but also an additional file(s) which always carries the same name (e.g.
"default.h"), no matter how the names of your sources and targets look like.
When you wanted to use the "-j" option, this could lead to trouble if
several threads tried to create and write to the same file at once. By
marking the "default.h" as SideEffect(), SCons ensures that only one
thread creating/writing "default.h" can run at the same time.
What you probably want in the above situation is:
env = Environment()
env.Command(['foo','bar'], [], 'touch foo && touch bar')
Default('foo')
(now both files are targets), or define your own Emitter that returns
the proper list of targets for your build step.
Best regards,
Dirk
More information about the Scons-users
mailing list