[Scons-users] Unexpected warning when defining a target twice during reading of SConscripts
Bill Deegan
bill at baddogconsulting.com
Sat Dec 2 16:29:42 EST 2017
Andrew,
You wouldn't see it build twice because you cannot due to checking for
different environments, thus the error.
There are two different Environments(), so the message is not incorrect.
Their contents may be equivalent, I know we had a patch to address override
environments which were equivalent.
Feel free to create a pull request with a fix.
In this specific case it does point out something which has no value in the
build assuming the two environments are equivalent.
Whether that's worthy of an error is probably debatable.
There is currently no bug in scons.tigris.org to capture this, so please go
ahead and file.
I think the issue is the following: (src/engine/SCons/Builder.py line 296)
if (not t.env is None and not t.env is env and
Since there are two different objects, the t.env is env fails.
Comparing two environments for equality is not done, and indeed could get
quite complicated as you'll need to compare any dictionaries, lists, sets
and functions/classes stored in both Environment()s
Hope that helps.
-Bill
On Fri, Dec 1, 2017 at 5:54 PM, Andrew Featherstone <
andrew.featherstone at gmail.com> wrote:
> They might be different instances, but they're also equal. Surely
> something must be sharing information or we'd see something like
>
> scons: Building targets ...
> simple_cmd(["foo.out"], ["foo.in"])
> simple_cmd(["foo.out"], ["foo.in"])
> scons: done building targets.
>
> In the logs.
>
> Andrew
>
>
> On 2 Dec 2017 00:26, "Bill Deegan" <bill at baddogconsulting.com> wrote:
>
> Here's my recipe for finding such in the sources:
>
> $ grep -r "Two different environments" src/engine/SCons/
>
> src/engine/SCons/Builder.py: msg = "Two different
> environments were specified for target %s,\n\tbut they appear to have the
> same action: %s" % (t, action.genstring(tlist, slist, t.env))
>
>
> Actually it's probably correct.
> Each time you call SConscript above, it's creating a new Environment().
> SConscripts are evaluated basically by python eval.
> There's no shared context between the two evaluations of the same
> SConscript in this case.
>
>
> On Fri, Dec 1, 2017 at 3:37 PM, Andrew Featherstone <
> andrew.featherstone at cantab.net> wrote:
>
>> 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
>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
>>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
>
> _______________________________________________
> 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/20171202/863f353b/attachment-0001.html>
More information about the Scons-users
mailing list