Hi, I'd like to write an SConstruct file that will convert (e.g.) all the JPEG files in a directory into PNGs.
I think I have the Builder alright:
ConvToPNG = Builder(action = 'convert $SOURCE $TARGET',
suffix = '.png',
src_suffix = '.jpg')
env['BUILDERS']['ConvToPNG'] = ConvToPNG
But then I'm not sure how to make a list of all the targets that need to be built. I can do it in a Python-y way like this:
pix_conversions = [env.ConvToPNG(jpg_src) for jpg_src in Glob('pix/img_*.jpg')]
And then maybe I'll use an Alias for those:
env.Alias('convert_all', pix_conversions)
Or else make a Node by hand and have it Depends
on the conversions.
The thing is, this seems like it's something that Scanners are sorta made for. But I couldn't get that to work well. I tried making a Builder that would work on a directory and call a Scanner that would add a bunch of targets, but it didn't work because the SCons internals expect a Builder to run on a file. (or at least, that's what I gleaned from the error messages).
Is there a more SCons-y way of doing this?