[Scons-users] Build results of a scanner function?

Chris BeHanna chris at behanna.org
Thu Aug 16 17:13:55 EDT 2012


On Aug 15, 2012, at 15:43 , Justin Tulloss <justin at rd.io> wrote:


> Hello,

>

> This is a newbie question, so hopefully it's straightforward to answer. I'm using scons to build my web frontend. I have a list of .less files that I want to compile to .css files. These less files are listed in a manifest file. I have a scanner that reads the manifest file and returns the files listed. As I understand it, this makes them implicit dependencies of the target. How do I indicate that I want my .less builder to run against all of these source files?


It seems like you want something like what the Program() builder does with C or C++ files: you can specify a list of sources, and Program() will compile them with the appropriate compiler and link them with the appropriate linker. It will also scan the dependencies of the libraries against which you link, and add them to the program's dependency graph.

The Program() builder uses the Object() as its src_builder, and Object() in turn uses CFile() and CXXFile() for its list of src_builders (see /usr/lib/scons/SCons/Tool/__init__.py).

You could either do this, or do something simpler, such as, within your scanner, invoke your CSS builder on each .less file that you find. This will insert that builder step into the DAG for the manifest. Something like this:

BuildManifest('targetmanifest', 'sourcemanifest')

and BuildManifest() has a scanner for the source manifest, and for every .less file it finds in there, it invokes, say

CSS('foo.css', 'foo.less')

and

Depends('targetmanifest', 'foo.css')

That last step would be implicit if your manifest listed CSS files rather than .less files, and your scanner simply knew to transform the file suffixes to invoke the CSS builder.

--
Chris BeHanna
chris at behanna.org



More information about the Scons-users mailing list