[Scons-users] finding out which env causes this error: Two different environments were specified for target
daggs
daggs at gmx.com
Sun Mar 27 03:58:06 EDT 2022
Greetings Dominic,
> Sent: Friday, March 25, 2022 at 9:18 PM
> From: "Dominic Binks" <dominic.binks at thebinkles.net>
> To: scons-users at scons.org
> Cc: daggs at gmx.com
> Subject: Re: [Scons-users] finding out which env causes this error: Two different environments were specified for target
>
> Hi Dagg,
>
> I've found the biggest problem with this issue is trying to find out
> where the duplication is arriving from.
>
> To this end, I've created a small function:
>
> def check_for_problem_file(env, scons_nodes, needle_re):
> nodes = env.Flatten([scons_nodes])
> for n in nodes:
> if re.match(needle_re, str(n)):
> print("Filename match {} against {}".format(n, needle_re))
> print_stack()
>
> needle_re is a regular expression and a stack trace is printed whenever
> the regular expression matches the name of a file that is passed in via
> the scons_nodes.
>
> The other part to this is to have a replacement for the function that
> seems to be giving rise to the duplicate entries. You've identified
> that InstallAs does this, so if you wrap the real InstallAs inside a
> MyInstallAs method, then you can call check_for_problem_file with the
> name of the file that is seeing the duplicate environment to figure out
> where the two environments are originating from.
>
> It's then not too difficult (usually) to eliminate the duplication.
>
> While it's a bit crude, it's proved quite good at helping to eliminate
> (most) of our duplicate environment warnings.
>
> Dominic
I've tried your func, the trace shows only one SConscript, the problematic on.
should I put it in all SConscript files called in the tree?
Dagg.
More information about the Scons-users
mailing list