[Scons-dev] Builder._createNodes appears to handle slist incorrectly

Ryan Saunders business at jediry.com
Mon Sep 19 03:06:26 EDT 2022


Hi Bill,

I tried multi = True, but it seemed to have no effect. At least, my unit test fails in the same way. (I'm unclear on what, precisely, multi = True does, so it's hard for me to determine whether it ought to fix my issue or not.)

So then, I switched tactics. I knew that the StaticObject builder supports lists of inputs, producing a list of outputs with 1:1 correspondence, so I debugged that scenario, and what I found is that the secret sauce is to specify single_source = True on my builder. This attribute causes my builder to be invoked in a loop, on each input separately, and then all the packages in the list get processed.

So...questions:

- Is this (single_source = True) the canonical way of handling lists of inputs?
- If it is, then what's the point of even having the single_source attribute? Why not just have this always be True? What is the single_source = False codepath for?
- On the other hand, if single_source = False is intended (as the name seems to imply) to let my builder see the list of inputs all at once, then this goes back to my original question: isn't it a bug that _createNodes doesn't iterate all of slist?

Thanks for your help,
Ryan

Sent with [Proton Mail](https://proton.me/) secure email.

------- Original Message -------
On Sunday, September 11th, 2022 at 9:39 PM, Bill Deegan <bill at baddogconsulting.com> wrote:

> I'd put money on it not being broken and your usage perhaps not quite right..
>
> There's a lot of code in your PR.
>
> You might try adding `multi=True` when you create your builder.
> That said having VcPkg as a builder may not be the best way to implement.
> You might be better off with a PseudoBuilder.
>
> I'll add some comments in the PR when I get some time to do a thorough review.
>
> On Sun, Sep 11, 2022 at 6:08 PM Ryan Saunders <business at jediry.com> wrote:
>
>> Hi guys,
>>
>> While adding some unit tests to my VCPkg builder, I thought to try the "list" case, where someone does (e.g.) "env.VCPkg(["openjpeg", "glut"])" to install a list of packages. I was surprised to discover that this doesn't work...my source type's target_from_source method only gets called for the first item in the list, and the subsequent source nodes get dropped in the trash can, with no corresponding "target" nodes created for them.
>>
>> I tracked the issue down to this code:
>> def _create_nodes(self, env, target = None, source = None):
>> """Create and return lists of target and source nodes.
>> """
>> src_suf = self.get_src_suffix(env)
>>
>> target_factory = env.get_factory(self.target_factory)
>> source_factory = env.get_factory(self.source_factory)
>>
>> source = self._adjustixes(source, None, src_suf)
>> slist = env.arg2nodes(source, source_factory)
>>
>> pre = self.get_prefix(env, slist)
>> suf = self.get_suffix(env, slist)
>>
>> if target is None:
>> try:
>> t_from_s = slist[0].target_from_source
>> except AttributeError:
>> raise UserError("Do not know how to create a target from source `%s'" % slist[0])
>> except IndexError:
>> tlist = []
>> else:
>> splitext = lambda S: self.splitext(S,env)
>> tlist = [ t_from_s(pre, suf, splitext) ]
>> I think this last bit ought to be:
>> if target is None:
>> tlist = []
>> for s in slist:
>> try:
>> t_from_s = s.target_from_source
>> except AttributeError:
>> raise UserError("Do not know how to create a target from source `%s'" % s)
>> else:
>> splitext = lambda S: self.splitext(S,env)
>> tlist += [ t_from_s(pre, suf, splitext) ]
>> Does anyone know why this code is the way it is? Fixing this code seems a tiny bit scary, since it's so fundamental... Then again, it seems fundamentally broken.
>>
>> If I were to fix this, where would the best spot be for the appropriate unit test? Any special considerations I should be aware of?
>> R
>>
>> Sent with [Proton Mail](https://proton.me/) secure email.
>> _______________________________________________
>> Scons-dev mailing list
>> Scons-dev at scons.org
>> https://pairlist2.pair.net/mailman/listinfo/scons-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/scons-dev/attachments/20220919/132ed430/attachment.htm>


More information about the Scons-dev mailing list