[Scons-dev] How to create a builder with optional source and target parameters?

Left Right olegsivokon at gmail.com
Wed Oct 3 16:10:45 EDT 2012


Hello, list.

I'm trying to write an extension, and here's one thing I would like to
have in it: I would like to be able to call the builder without
arguments at all. To elaborate: there are few traditional patterns of
project structure in Flash, where you may know beforehand exactly the
source and can also infer the target file name(s). I.e. there's
traditional directory structure, where it is extremely common to have
$(projectedir)/src/Main.as for the entry point, and the compiler will
know how to pick the process from being given only that info.

Now, I was thinking of a way to somehow "chime in" before Builder
starts resolving sources / destination paths and supply my best guess
about what those are.
What I've tried: supplying a function as a 'generator' argument to
Builder and creating an action by extending
SCons.Action.CommandGeneratorAction.

None worked, here's an example error that I get:

scons: Reading SConscript files ...
TypeError: object of type 'NoneType' has no len():
File "/home/wvxvw/workspace/Test/SConstruct", line 2:
env.Flash()
File "/usr/lib/scons/SCons/Environment.py", line 258:
return MethodWrapper.__call__(self, target, source, *args, **kw)
File "/usr/lib/scons/SCons/Environment.py", line 222:
return self.method(*nargs, **kwargs)
File "/usr/lib/scons/SCons/Builder.py", line 632:
return self._execute(env, target, source, OverrideWarner(kw), ekw)
File "/usr/lib/scons/SCons/Builder.py", line 542:
if self.single_source and len(source) > 1 and target is None:

But I simply couldn't lay my hands on the 'source' until that point,
so I couldn't make it a list.

What would be the way to do it? I mean, of course I could've copied
the entire Builder function and replace some bits that I need, but is
that the way to go, or is there a better alternative?

Thanks.

Oleg


More information about the Scons-dev mailing list