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

Ryan Saunders business at jediry.com
Sun Sep 11 21:08:18 EDT 2022


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/scons-dev/attachments/20220912/c930fa27/attachment.htm>


More information about the Scons-dev mailing list