Re: finding out which env causes this error: Two different environments were specified for target
daggs <[email protected]>
| Newsgroups | gmane.comp.programming.tools.scons.user |
|---|---|
| Message-ID | <trinity-4861989d-73dd-46fc-8e04-1805e5ba00d6-1648367886010@3c-app-mailcom-bs03> |
Greetings Dominic, > Sent: Friday, March 25, 2022 at 9:18 PM > From: "Dominic Binks" <[email protected]> > To: [email protected] > Cc: [email protected] > 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.