[Scons-users] Custom Scanner question

Dirk Bächle tshortik at gmx.de
Tue Sep 30 13:24:24 EDT 2014


Hi Jason,

On 30.09.2014 18:25, Jason Fritz wrote:
> Hi SCons folks,
>
> I'm trying to write a custom Scanner to scan IBM Rhapsody project 
> files and could use some help.
>
> [...]
>
>
> 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?
>
Scanners usually detect "implicit dependencies", meaning you have 
specified a build step "source->target" where source depends on other 
files (like includes in C/C++, for example). So whenever a source file 
of type "x" (in your case "*.rpy") is encountered, you want to 
automatically scan the file for "includes" and add them as dependencies 
to the target (!) as well.

If you have just one single Action, where you call a command-line tool 
like "rpy-compile foo.rpy", it may be enough to define a custom Emitter 
instead. Within the Emitter you'd parse the *.rpy project file too, and 
directly add the referenced "*.cpp/*.h" files as sources and a possible 
"*.exe" as target.

You can read a bit more about Scanners in this recent post to the 
mailing list:

https://pairlist4.pair.net/pipermail/scons-users/2014-September/002977.html

For Emitters you might want to take a look at

   http://www.scons.org/wiki/ToolsForFools

, and if you get stuck, just come back with more questions. ;)

Best regards,

Dirk



More information about the Scons-users mailing list