[Scons-dev] Possible minor bug + how to get (or assign) a builder to a file node?

Left Right olegsivokon at gmail.com
Thu Oct 4 13:03:58 EDT 2012



>Can you back up a few steps and say what you're trying to do? (Note

>that you say you're creating a File Node, but the code you show is for

>a subclass of Builder, which is pretty odd.) Have you been through

>Chapter 18 of the User's Guide?

>http://www.scons.org/doc/production/HTML/scons-user/c3621.html



>--

>Gary


Thanks for reply. I'm probably "that deep" because of a mismatch in
the regular way C or Java projects are built vs Flash. The thing is,
managing sources is very simple in Flash (the compiler does almost all
the job, it find the required sources by inferring from the code what
it should be looking for), but there are many configuration settings
that one should pass to compiler, which are given per project, or per
certain part of the project.

So, I'm much more interested in having a reference to the builder in
the generator function, then the source file names (I can obtain the
reference to the source files at any time, actually, and it's not very
important), but I need to somehow transfer a lot of information with
the group of files. For instance, the compiler has a concept of
modules, so it would compile a group of files, and then would compile
a module using the first group in a similar way you'd use headers in
C, when linking dynamic libraries.

Anyways, I think I can better explain my problem in terms of the code,
which isn't working quite as I'd need it to.

Step 0: I've extended BuilderBase with FlashBuilderBase and added this
builder to env[BUILDERS].
Step 1: I've overridden _execute in FlashBuilderBase in order to be
able to gather some important information about the project (often
times Flash comes with Eclipse-style project files, so I'm parsing the
project file, and interpret the information I find in it in a way it
will be useful later during the build).
Step 2: This information is saved in a FlashBuilderBase field.
Step 3: The overriden _execute() calls super(FlashBuilderBase, self)._execute()
Step 4: BuilderBase._execute() at some point calls
self.action.batch_key(env or self.env, tlist, slist)
Step 5: batch_key() calls my generator function. In that generator
function I must have a reference to the builder which submitted the
source files, but I can't because it is only in
Step 6: that BuilderBase._execute() calls t.builder_set(self) - and
this is too late :( because in my generator function I needed that
source.builder would give me the reference to FlashBuilderBase.

If I try to circumvent this by either calling
t.builder_set(FlashBuilderBaseInstance) before generator function is
called, it enters an infinite loop (why - I don't know yet)
Also, if I try, in FlashBuilderBase self.src_builder = [self] - this
enters infinite loop too.

I could find a solution by making generator function capture the
builder instance I need to acces in it, but this is super convoluted,
and it also means that I would need a function per builder (while it
could've been more generic).

What could've helped - is if BuilderBase._execute() called
t.builder_set(self) before it calls self.action.batch_key(env or
self.env, tlist, slist)

Sorry for a very long message!


More information about the Scons-dev mailing list