Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2006-04-26 03:31:21


On Tuesday 25 April 2006 23:22, Mark Evans wrote:
> It turns out that the desired behavior can be achieved by extending the
> interface of path.glob in util/path.jam and adding a few lines of jam code.
> I added two optional parameters, 'recurse' and 'maxdepth'. If a non-null
> argument is passed to 'recurse', then up to 'maxdepth' levels of
> subdirectories are globbed. By default 'maxdepth' is MAXINT. I will
> submit a patch after I do the hard work of documentation and selftest after
> some discovery of what needs to be done there.

Hi Mark,
I've just realized that some time ago a recursive glob was already set, as a
part of larger code by João Abecasis:

   http://article.gmane.org/gmane.comp.lib.boost.devel/140966

Also, search found me this post:

   http://article.gmane.org/gmane.comp.lib.boost.build/7846

which I apparently missed back then. I'm not saying those version should be
used, or that they are better or worse than what you proposed. Just in case
you want to look at other implementations.

> In-line documentation reads
> as follows:
>
> # Returns the list of files matching the given pattern in the
> # specified directory. Both directories and patterns are
> # supplied as portable paths. Each pattern should be non-absolute
> # path, and can't contain "." or ".." elements. Each slash separated
> # element of pattern can contain the following special characters:
> # - '?', which match any character
> # - '*', which matches arbitrary number of characters.
> # A file $(d)/e1/e2/e3 (where 'd' is in $(dirs)) matches pattern
> p1/p2/p3 # if and only if e1 matches p1, e2 matches p2 and so on.
> #
> # If optional parameter 'recurse' is passed a non-null argument, the
> # entire tree is walked. The maximum number of subtree levels to be
> walked # can be controlled by the optional 'maxdepth' parameter. The
> default # is no limit. Maxdepth of 1 limits the search to one sublevel.
> For # example, [ glob . : *.cpp *.h : t : 2 ] matches all *.cpp and *.h
> # files in the current directory and two levels of subdirectories. #
> # For example:
> # [ glob . : *.cpp ]
> # [ glob . : */build/Jamfile ]
> # [ glob . : *.cpp *.h : t ]
> rule glob ( dirs * : patterns + : recurse ? : maxdepth ? )
>
> How does this sound?

This sounds good. One question is whether we should have an explicit list of
patterns to exclude, like in João's code.

And we'd also need 'recursive-glob' to be available in Jamroot context, like
like we have 'glob' that relays to 'path.glob' but has simpler interface and
works relatively to source location of project.

Say, the prototype can be:
I think for recursive glob we should have:

   recursive-glob /dir/ : /patterns-to-include/ : /maxdepth/ ;

with maybe excluded patterns added somewhere.

- Volodya

-- 
Vladimir Prus
http://vladimir_prus.blogspot.com
Boost.Build V2: http://boost.org/boost-build2

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk