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

Dirk Bächle tshortik at gmx.de
Wed Sep 17 15:22:41 EDT 2014


Hi Michael,

On 17.09.2014 10:55, Michael Hasling wrote:
> Hi Dirk,
>
>> your build simply breaks, because there is no way for SCons to detect that
>> second.tcl depends on third.tcl, and first.tcl depends on second.tcl. This
>> has to get fixed first, then we can continue to talk about scanners. ;)
> But I thought that scanners exist for exactly the purpose of discovering these dependencies?! ;)
yes, implicit dependencies...which get detected while scanning a 
"source" file for a target that's supposed to get built. This requires 
to have a "target" and a "source" in the node graph, with a Builder 
linking the two...like the Obj Builder which creates an *.obj from a *.c 
file for example. Then, if a Scanner for the ".c" extension is 
registered in the current environment, it will get run and scans the 
"source" file that was specified. It then returns (assuming it has the 
"recursive" flag set) all implicit dependencies (header files and their 
includes) that currently can be found while scanning the *.c file.
If a header file doesn't exist yet (because it's created by another 
Builder itself), SCons defers building the target in question, waiting 
for the header to appear. Once this has happened, the previous scanning 
results for the target get reset (cleaned if you will, this is 
simplified a lot anyway)...such that the header gets rescanned 
completely, since it could produce a whole new list of dependencies, 
based on the exact contents of the created header file.

But if all headers (implicit dependencies, in general) exist and are 
up-to-date, SCons goes ahead and builds the target. And that's what 
happens in your build, it tries to create "second.tcl", because your 
Scanner didn't see/report the dependency to "third.tcl". If your Scanner 
says "Look, these are the dependencies I found." SCons checks the list 
to see if all files exist...and relies on this information. There is no 
way to say "Uhh, I found some dependencies...but some more may follow 
later, please hang on.". If that would be the case, how and under which 
condition(s) exactly should the build stop...meaning: when exactly 
should the Taskmaster decide that all dependencies are found?

Looks like you have to make your scanner find "third.tcl" as dependency 
in the first run, too.

What's maybe important to know here is, that SCons doesn't first build a 
complete DAG for the build phase...and then traverses it. Instead, it 
starts with one of the targets (default or given on the command-line) 
and "expands" the implicit DAG "on the fly". As soon as a node is marked 
as being ready to be built (all dependencies met), it gets scheduled to 
have its Action(s) executed. Then other nodes are probed as 
"candidates",...and so on.
> [...]
>

> I do think that "final.xml" should have the dependencies ["first.tcl", "second.tcl", "third.tcl"], and that's what my scanner is supposed to establish. It can't always do it in one pass though, so rescanning is required.

Then you're stuck, I guess...and have to resort to defining the 
dependencies your Scanner misses, explicitly with Depends(), sorry.

Regards,

Dirk



More information about the Scons-users mailing list