[Scons-users] Handling of dependencies using Scanner()

Marc Joliet marcec at gmx.de
Fri Oct 11 17:30:09 EDT 2013


Am Fri, 11 Oct 2013 14:23:40 +0100
schrieb Henry Gomersall <heng at cantab.net>:


> On 10/10/13 10:19, Henry Gomersall wrote:

> > I've built a tool for handling Jinja templates. As part of this, I've

> > made a Scanner that inspects the jinja templates and extracts the

> > files that it depends upon (it acquires with include or extends).

> >

> > I've added the Scanner to the environment, and with suitable print

> > statements I can observe the scanner in operation, and note that it is

> > successfully extracting all the filenames (from which the node list is

> > created and returned).

> >

> > The question is this: Once the nodes on which the current node depends

> > are extracted and returned by the scanner function, I would expect

> > those nodes to be part of the dependency tree - that is, modifications

> > to those nodes would trigger a rebuild of the dependent file. This

> > does not seem to be happening with me.

> >

> > I can only assume that there is an additional step to make the nodes

> > part of the dependency tree. To be clear, I don't need to explicitly

> > build those nodes that are returned from the scanner function, just

> > that modifications to those nodes causes a rebuild.

>

> I've manged to fix this by recursing through all the nodes that I

> previously just returned, scanning them as well and building a bigger

> list. See: https://gist.github.com/hgomersall/6915968

>

> I assumed that the scanner would automatically handle a new node that

> was added to the dependency tree if the suffix agreed with what the

> scanner already had - apparently not. Can someone confirm this?


I think you overlooked the "recursive" option to the Scanner(). From the man
page:

"recursive
An optional flag that specifies whether this scanner should be re-invoked on
the dependency files returned by the scanner. When this flag is not set, the
Node subsystem will only invoke the scanner on the file being scanned, and
not (for example) also on the files specified by the #include lines in the
file being scanned. recursive may be a callable function, in which case it
will be called with a list of Nodes found and should return a list of Nodes
that should be scanned recursively; this can be used to select a specific
subset of Nodes for additional scanning."

HTH
--
Marc Joliet
--
"People who think they know everything really annoy those of us who know we
don't" - Bjarne Stroustrup
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
Url : http://four.pairlist.net/pipermail/scons-users/attachments/20131011/e2c0c6dc/attachment-0001.pgp


More information about the Scons-users mailing list