How can one make recursive Glob() in a VariantDir() environment in Python?
The answer from the question <Use a Glob() to find files recursively in Python?> will not work, because you need use Glob() to get a list of files that is aware of VariantDir() environment.
So you need something like:
import fnmatch
import os
matches = []
for root, dirnames, filenames in os.walk('src'):
for filename in fnmatch.filter(filenames, '*.c'):
matches.append(os.path.join(root, filename))
matches = Glob(matches)
Will this work?
Your approach would work with a minor tweak as follows:
Notice that I converted it to a File(), since the SCons Glob() function returns Nodes if the “strings” parameter is false.
To be able to handle the VariantDir, etc and to better integrate the functionality with the existing SCons Glob() functionality, you could actually incorporate a call to the existing Glob() function, like this:
You could take it one step further and do the following: