[Scons-users] Unexpected warning when defining a target twice during reading of SConscripts

Andrew Featherstone andrew.featherstone at cantab.net
Fri Dec 1 18:37:22 EST 2017


Hi all,

Here's a simple setup using scons 3.0.1

$ ls
SConscript  SConstruct  foo.in
$ cat SConstruct
env_a = Environment()
env_b = Environment()
for env in (env_a, env_b):
    SConscript(
        'SConscript'
    )
$ cat SConscript
import shutil

env_c = Environment()

def simple_cmd(target, source, env):
    shutil.copy(str(source[0]), str(target[0]))

env_c.Command('foo.out', 'foo.in', simple_cmd)

The expected behaviour when running scons is that the foo.out is produced
once. This does happen, but SCons incorrectly (AFAICT) warns that different
environments are used to build the target foo.out:

$ scons
scons: Reading SConscript files ...

scons: warning: Two different environments were specified for target
foo.out,
        but they appear to have the same action: simple_cmd(target, source,
env)
File "C:\Users\Andrew\projects\scons-env\SConscript", line 8, in <module>
scons: done reading SConscript files.
scons: Building targets ...
simple_cmd(["foo.out"], ["foo.in"])
scons: done building targets.

The output of --taskmastertrace:


Taskmaster: Looking for a node to evaluate
Taskmaster:     Considering node <no_state   0   '.'> and its children:
Taskmaster:        <no_state   0   'foo.in'>
Taskmaster:        <no_state   0   'foo.out'>
Taskmaster:        <no_state   0   'SConscript'>
Taskmaster:        <no_state   0   'SConstruct'>
Taskmaster:      adjusted ref count: <pending    1   '.'>, child 'foo.in'
Taskmaster:      adjusted ref count: <pending    2   '.'>, child 'foo.out'
Taskmaster:      adjusted ref count: <pending    3   '.'>, child
'SConscript'
Taskmaster:      adjusted ref count: <pending    4   '.'>, child
'SConstruct'
Taskmaster:     Considering node <no_state   0   'foo.in'> and its children:
Taskmaster: Evaluating <pending    0   'foo.in'>

Task.make_ready_current(): node <pending    0   'foo.in'>
Task.prepare():      node <up_to_date 0   'foo.in'>
Task.executed_with_callbacks(): node <up_to_date 0   'foo.in'>
Task.postprocess():  node <up_to_date 0   'foo.in'>
Task.postprocess():  removing <up_to_date 0   'foo.in'>
Task.postprocess():  adjusted parent ref count <pending    3   '.'>

Taskmaster: Looking for a node to evaluate
Taskmaster:     Considering node <no_state   0   'foo.out'> and its
children:
Taskmaster:        <up_to_date 0   'foo.in'>
Taskmaster: Evaluating <pending    0   'foo.out'>

Task.make_ready_current(): node <pending    0   'foo.out'>
Task.prepare():      node <executing  0   'foo.out'>
Task.execute():      node <executing  0   'foo.out'>
Task.executed_with_callbacks(): node <executing  0   'foo.out'>
Task.postprocess():  node <executed   0   'foo.out'>
Task.postprocess():  removing <executed   0   'foo.out'>
Task.postprocess():  adjusted parent ref count <pending    2   '.'>

Taskmaster: Looking for a node to evaluate
Taskmaster:     Considering node <no_state   0   'SConscript'> and its
children:
Taskmaster: Evaluating <pending    0   'SConscript'>

Task.make_ready_current(): node <pending    0   'SConscript'>
Task.prepare():      node <up_to_date 0   'SConscript'>
Task.executed_with_callbacks(): node <up_to_date 0   'SConscript'>
Task.postprocess():  node <up_to_date 0   'SConscript'>
Task.postprocess():  removing <up_to_date 0   'SConscript'>
Task.postprocess():  adjusted parent ref count <pending    1   '.'>

Taskmaster: Looking for a node to evaluate
Taskmaster:     Considering node <no_state   0   'SConstruct'> and its
children:
Taskmaster: Evaluating <pending    0   'SConstruct'>

Task.make_ready_current(): node <pending    0   'SConstruct'>
Task.prepare():      node <up_to_date 0   'SConstruct'>
Task.executed_with_callbacks(): node <up_to_date 0   'SConstruct'>
Task.postprocess():  node <up_to_date 0   'SConstruct'>
Task.postprocess():  removing <up_to_date 0   'SConstruct'>
Task.postprocess():  adjusted parent ref count <pending    0   '.'>

Taskmaster: Looking for a node to evaluate
Taskmaster:     Considering node <pending    0   '.'> and its children:
Taskmaster:        <up_to_date 0   'foo.in'>
Taskmaster:        <executed   0   'foo.out'>
Taskmaster:        <up_to_date 0   'SConscript'>
Taskmaster:        <up_to_date 0   'SConstruct'>
Taskmaster: Evaluating <pending    0   '.'>

Task.make_ready_current(): node <pending    0   '.'>
Task.prepare():      node <executing  0   '.'>
Task.execute():      node <executing  0   '.'>
Task.executed_with_callbacks(): node <executing  0   '.'>
Task.postprocess():  node <executed   0   '.'>

Taskmaster: Looking for a node to evaluate
Taskmaster: No candidate anymore.

Any ideas on how to debug this further?

Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20171201/3d73fff8/attachment.html>


More information about the Scons-users mailing list