scons icon indicating copy to clipboard operation
scons copied to clipboard

Unexpected SCons behaviour with builder target of Dir (or Entry)

Open bdbaddog opened this issue 8 years ago • 0 comments

This issue was originally created at: 2006-09-08 12:09:07. This issue was reported by: jice.

jice said at 2006-09-08 12:09:08

I'm running version SCons 0.96.92.

I notice that dependencies do not behave quite as I would expect, and there seems to be a difference based on the target_factory setting. I'm hoping that someone can enlighten me, as there may be an issue with directory dependencies.

I have this example SConstruct file:

testbldr1 = Builder(
    action=[Delete("$TARGET"), Mkdir("$TARGET")],
    target_factory=Dir,
    source_factory=File,
)
env.Append(BUILDERS={"Test1": testbldr1})

testbldr2 = Builder(
    action=[Delete("$TARGET"), Mkdir("$TARGET")],
    target_factory=Entry,
    source_factory=File,
)
env.Append(BUILDERS={"Test2": testbldr2})

testbldr3 = Builder(
    action=[Delete("$TARGET"), Touch("$TARGET")],
    target_factory=File,
    source_factory=File,
)
env.Append(BUILDERS={"Test3": testbldr3})

env.Test1("testdir", "foo")
env.Test2("testentry", "foo")
env.Test3("testfile", "foo")

If none of testdir, testentry or testfile exist, then all are created the first time I run scons.

If I change nothing, and run scons again. I see that testentry is recreated. This is unexpected.

If I change the contents of foo and run scons again, I see that testentry and testfile are recreated. However, testdir is not recreated. This is also unexpected.

A user on the SCons mailing list suggested using the --debug=explain flag. That didn't show anything interesting, but it did change the behavior of scons.

Setting --debug=explain actually changed the results of running scons (in the case of target_factory = Entry).

Have a look at this sequence of events:

% scons --debug=explain
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building `testdir' because it doesn't exist
Delete("testdir")
Mkdir("testdir")
scons: building `testentry' because it doesn't exist
Delete("testentry")
Mkdir("testentry")
scons: building `testfile' because it doesn't exist
Delete("testfile")
Touch("testfile")
scons: done building targets.
% scons --debug=explain
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: done building targets.
% scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Delete("testentry")
Mkdir("testentry")
scons: done building targets.
% echo new foo > foo
% scons --debug=explain
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: rebuilding `testfile' because `foo' changed
Delete("testfile")
Touch("testfile")
scons: done building targets.
% scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Delete("testentry")
Mkdir("testentry")
scons: done building targets.

In the above, notice that testentry is rebuilt whenever scons is run, unless I use the --debug=explain flag.

Also notice that testdir is not rebuilt whether or not that flag is set.

jice said at 2006-09-19 20:43:41

I'm using 0.96.91 (not 0.96.92 ... not available via gentoo yet).

jice said at 2006-09-21 13:16:28

I've updated to 0.96.92. I notice similar (but slightly different behaviour):

% echo bar > foo
% scons --debug=explain
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building `testdir' because it doesn't exist
Delete("testdir")
Mkdir("testdir")
scons: building `testentry' because it doesn't exist
Delete("testentry")
Mkdir("testentry")
scons: building `testfile' because it doesn't exist
Delete("testfile")
Touch("testfile")
scons: done building targets.
% scons --debug=explain
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
% scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
% echo new foo > foo
% scons --debug=explain
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: rebuilding `testfile' because `foo' changed
Delete("testfile")
Touch("testfile")
scons: done building targets.
(werx:wink/trunk/foo) jice% scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
(werx:wink/trunk/foo) jice%   

mightyllamas said at 2008-03-17 18:29:52

Just tried it with head branch, still has latest behaviour

garyo said at 2008-03-17 20:28:07

Milestone: 2.x.

stevenknight said at 2009-11-10 18:00:19

stevenknight => issues@scons

Votes for this issue: 1.

gregnoel said this issue blocks #2376 at 2009-04-10 09:11:35.

bdbaddog avatar Jan 02 '18 09:01 bdbaddog