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

Mats Wichmann mats at wichmann.us
Sat Dec 2 10:34:35 EST 2017


On 12/01/17 16:37, Andrew Featherstone 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:

In addition to the other comments, this is kind of meaningless: you
create env_a and env_b and use their presence in a loop but you never do
anything with them - they are not passed to the SConscript unless you
pass them as an argument or export them and if necessary import them in
the sconscript.  So you could just as well have written:

for env in range(2):
    SConscript('SConscript')

That may be an artifact of trimming your code down to a simple
reproducer but just thought it was worth a mention...




More information about the Scons-users mailing list