[Scons-users] Custom Scanner question

Gary Oberbrunner garyo at oberbrunner.com
Tue Sep 30 14:21:25 EDT 2014


On Tue, Sep 30, 2014 at 12:25 PM, Jason Fritz
<jasonfritzpublic at gmail.com> wrote:
> Hi SCons folks,
>
> I'm trying to write a custom Scanner to scan IBM Rhapsody project files and
> could use some help.
>
> Some background:
> - Rhapsody is a UML tool that allows you to define C++ classes and also
> state machines. It can generate C++ code (.h and .cpp files) from what you
> build into the project.
> - The top-level Rhapsody file is called a project (.rpy extension).  The
> project "includes" many other Rhapsody files, e.g. packages (.sbs
> extension), diagrams (.omd), components (.cmp), etc.  Some sub-files, like
> packages and components, can include other sub-files
> - The list of generated source code is totally dependent upon the contents
> of the Rhapsody project.  E.g. you could add a new class called "Foo" to the
> project, generate code, and you will get Foo.h and Foo.cpp in addition to
> whatever else is already defined in the project.  There is no one-to-one
> mapping between Rhapsody files and generated source files.
>
> Now getting back to my Scanner question
> - What exactly does my scanner need to do?  It looks like I need to write a
> Scanner function that will parse the top-level project file (.rpy) and
> return a list of Nodes for all the sub-files included by the top-level
> project.
> - What about the generated source code?  How will SCons know that Foo.h/.cpp
> are generated by Rhapsody, and therefore will be regenerated if the Rhapsody
> project files change?

A Scanner won't do enough for you here.  Your Rhapsody is a source
code generator, in particular the hard kind where you can't predict
which sources will be generated without generating them.  I have a
writeup on the wiki for one way to deal with this kind of thing:
 http://www.scons.org/wiki/DynamicSourceGenerator

There's some more info at
http://www.scons.org/wiki/NonDeterministicDependencies as well.  These
techniques depend on reading a (generated) file with a list of all the
generated sources, but you could probably get that by parsing the
Rhapsody output or something.

-- 
Gary


More information about the Scons-users mailing list