If the build tool in question will use a path variable to search
for included files or other dependencies, then the Scanner will
need to take that path variable into account as well -
$LIBPATH are used this way,
for example. The path to search is passed to your
Scanner as the
path argument. Path variables
may be lists of nodes, semicolon-separated strings, or even
contain construction variables which need to be expanded.
SCons provides the
FindPathDirs function which returns
a callable to expand a given path (given as a SCons construction variable
name) to a list of paths at the time the Scanner is called.
Deferring evaluation until that point allows, for instance,
the path to contain
$TARGET references which differ for
each file scanned.
FindPathDirs is quite easy. Continuing the above example,
KPATH as the construction variable with the search path
$CPPPATH), we just modify the call to
Scanner factory function to include a path keyword arg:
kscan = Scanner(function=kfile_scan, skeys=['.k'], path_function=FindPathDirs('KPATH'))
FindPathDirs returns a callable object that, when called, will
essentially expand the elements in
and tell the Scanner to search in those dirs. It will also properly
add related repository and variant dirs to the search list. As a side
note, the returned method stores the path in an efficient way so
lookups are fast even when variable substitutions may be needed.
This is important since many files get scanned in a typical build.