[Scons-dev] How to traverse the graph after files are read

anatoly techtonik techtonik at gmail.com
Wed May 20 03:01:00 EDT 2015


On Tue, May 19, 2015 at 3:19 PM, Gary Oberbrunner <garyo at oberbrunner.com> wrote:
> At the end of your SConstruct, start with the target nodes and recurse into
> each node.sources . This is incomplete of course if you have any source
> generation or emitters etc. But it may be useful depending on what you're
> doing.

I am in the middle of Main.py - at this point:

>> >>> https://bitbucket.org/scons/scons/src/95b566e4baf0253e1b36b8a9e00a97cd84d22566/src/engine/SCons/Script/Main.py?at=default#cl-1091

There is FS object named fs, but I don't see why is it is a build graph. Later,
the node list is derived from it at line 1204:

    nodes = [_f for _f in map(Entry, targets) if _f]

Entry is:

    def Entry(x, ltop=lookup_top, ttop=target_top, fs=fs):
        if isinstance(x, SCons.Node.Node):
            node = x
        else:
            node = None
            # Why would ltop be None? Unfortunately this happens.
            if ltop is None: ltop = ''
            # Curdir becomes important when SCons is called with -u, -C,
            # or similar option that changes directory, and so the paths
            # of targets given on the command line need to be adjusted.
            curdir = os.path.join(os.getcwd(), str(ltop))
            for lookup in SCons.Node.arg2nodes_lookups:
                node = lookup(x, curdir=curdir)
                if node is not None:
                    break
            if node is None:
                node = fs.Entry(x, directory=ltop, create=1)
        if ttop and not node.is_under(ttop):
            if isinstance(node, SCons.Node.FS.Dir) and ttop.is_under(node):
                node = ttop
            else:
                node = None
        return node

But the logic what happens here and how FS object is transformed
into DAG, escapes me.


More information about the Scons-dev mailing list