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

Bill Deegan bill at baddogconsulting.com
Mon Sep 12 00:39:52 EDT 2022


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/20220911/d1b36edc/attachment.htm>


More information about the Scons-dev mailing list