SCons / scons

SCons - a software construction tool
http://scons.org
MIT License
2.06k stars 314 forks source link

Support recursive globbing in Glob() #3851

Open mwichmann opened 3 years ago

mwichmann commented 3 years ago

This has been discussed in Discord, wanted to record it.

Python's glob.glob now has a specifier for a recursive glob:

Changed in version 3.5: Support for recursive globs using “**”.

and it seems, since the SCons Glob rather mirrors the Python module (though it's not the same), that it would be a useful addition there. Other build tools, e.g. Bazel, also support the recursive syntax in their globbing functionality.

bdbaddog commented 3 years ago

I think this would be great and very useful enhancement!

mwichmann commented 3 years ago

So while we're at it, Python's glob module has a companion iglob method, which returns an iterator, and the implementation of glob itself is now this simple:

    return list(iglob(pathname, root_dir=root_dir, dir_fd=dir_fd, recursive=recursive))

Is it worth doing similar for SCons? If so - iGlob? Globi? other name?

Meanwhile, the pathlib glob support took a slightly different design choice. Path.glob() automatically selects recursive mode if the pattern starts with **/, a kwarg to enable recursive is not needed; it also has a Path.rglob()which does the recursive globbing without needing the **/ in the pattern. Just some things to think about.