[Scons-users] How to restart a scanner if it cannot provide all dependencies.

Michael Hasling Michael.Hasling at synopsys.com
Tue Sep 16 12:48:32 EDT 2014


Hi Dirk,

I'm following up an email I sent back in April about restarting scanners. But given the time it's taken me to get back to this maybe it's worth restating the problems afresh.

Here's a fragment of a SConscript, to illustrate the issue:

    final = env.MyTclTool( 'final.xml', 'first.tcl' )

    first = env.Textfile( 'first.tcl', [
        'set name_of_third_script_file "third.tcl"',
        'source second.tcl'
    ] )

    second = env.Textfile( 'second.tcl', [
        'source $$name_of_third_script_file'
    ] )

    third = env.Textfile( 'third.tcl', [
        'generate_xml "final.xml"'
    ] )


TclTool is a custom pseudo-builder for a Tcl based tool that will generate final.xml by executing the Tcl script first.tcl. It includes a scanner to detect dependencies using python's Tkinter module with customisations to detect files that will be sourced (as well as other file use, but that's unimportant here).

In your reply back in April you suggested that, if an initial scan of a source reported a non-existing dependency then the scanner would be run again when the target was revisited before the builder would get invoked:

> As a result, when the target "a.o" is visited next time to check 
> whether all of its children (=dependencies) are up-to-date, "a.cpp" 
> gets rescanned. And with this also "a.h" and (since it now
> exists) also "b.h", where the latter might add new implicit 
> dependencies to the target.

My investigations suggest that is not happening with our custom Tcl builder/scanner. What I see is:

    scons: Building targets ...
    my_tcl_tool_scancheck: node=first.tcl
    my_tcl_tool_scancheck: returning: None
    Creating 'first.tcl'
    my_tcl_tool_scancheck: node=first.tcl
    my_tcl_tool_scancheck: returning: True
    my_tcl_tool_scanner: node=first.tcl
    my_tcl_tool_scanner: returning ['second.tcl']
    Creating 'second.tcl'
    my_tcl_tool: target=final.xml source=first.tcl
    couldn't read file "third.tcl": no such file or directory
        while executing
    "source $name_of_third_script_file"
        (file "second.tcl" line 2)
        invoked from within
    "source second.tcl"
        (file "first.tcl" line 2)
        invoked from within
    "source first.tcl"
        ("uplevel" body line 1)
        invoked from within
    "::uplevel source $file"
        (procedure "::scsh::impl::evalWrap" line 10)
        invoked from within
    "::scsh::impl::evalWrap  {::scsh::impl::sourceWrap first...."
    scons: *** [final.xml] Explicit exit, status 1
    scons: building terminated because of errors.

If I understood your explanation correctly then I was expecting to see the scanner invoked again between "Creating 'second.tcl'" and the builder "my_tcl_tool: target=final.xml source=first.tcl".

In this scenario I have 'recursive=False' for the env.Scanner() declaration. I have also experimented with 'recursive=True'. Whilst this does result in the scanner being invoked again for 'second.tcl' that doesn't really help in this case, since the Tcl interpreter used for the scan is missing the context that's defined in first.tcl. The scanner really needs to be started again with the top-level 'first.tcl' source file.

Am I missing something obvious, or is this a bug? (I should also mention that we're using SCons 2.2.0 in case it is an old bug that's been fixed in later versions, although I didn't spot anything in the change logs that looked like this.)

Best regards,
Michael



More information about the Scons-users mailing list