[Scons-dev] Chained DynamicSourceGenerators: Chicken-and-egg problem

eKiwi electron.kiwi at gmail.com
Thu May 23 13:26:36 EDT 2013


Hey everyone,

I am working on a project that uses SCons as its build system.
My problem right now is that I am trying to have several
DynamicSourceGenerators [1] chained together.

My Dependency Chain (from bottom up) looks something like this:
(I marked every action that I have implemented as a builder right now
with [B(#)])

Config File that contains name of device this library is to be built for

=> [B(1)] with the device name one can search for a xml device file
describing the properties of the device/the properties od the family the
device belongs to (the search starts with the most specific device file
possible and then searches for less specific ones)

=> [B(2)] the device file (output from B[1]) specifies the drivers that
need to be built. Every driver has its own xml file. These are assigned
to [B(3)]

=> [B(3)] takes the driver xml file as well as some data in a dictionary
(handed to it from [B(2)] via the local environment and marked as a
dependency by this builders emitter). From this it can derive a list of
files template files that need to be processed (by a template Builder)
and static files that just need to be copied to a 'generated' directory

The Files that are marked to be generated/copied by [B(3)] are cpp files
that need to be compiled as well as hpp files that some files outside of
the 'generated' directory include.

The problem I am having with this approach right now is a chicken and
egg problem.

When scons starts without any saved data, it simply can not know how to
build any file in the 'generated' directory, because the Builders
mentioned above are never executed. This is because the Builders were
never executed.

So for initial build the system above is useless (it took me a while to
understand that).

But as far as rebuilds are concerned it all makes a lot of sense in my
opinion: If the xml device file is changed, [B(1)], [B(2)], [B(3)] and
all Template/Copy/Program Builders need to be run. If one driver xml
file changes [B(2)] only needs to be run for the specific driver ans
only the template/static files of that driver need to be rebuilt.
If one driver template file changes, only that certain file and any
other file that might depend on it needs to be rebuilt.

So I was wondering: Does anyone here (who might know a lot more about
the internal workings of SCons) have any suggestion on how to solve my
Chicken-and-egg problem?

What I would basically need is something like a Builder that has a file
as source, no specific target and outputs dependencies (that is what I
am doing with a Builder right now, but SCons is not really "aware
enough" of that).

I already thought about building a Scanner, but these work the other way
around: They specify dependencies of their source file. In my case the
output depends on my source.

So I am looking forward to any suggestion.

Best Regards
Kevin

[1] http://www.scons.org/wiki/DynamicSourceGenerator


More information about the Scons-dev mailing list