Disabling "using independent target" warning

Added by Arseny Kapoulkine over 9 years ago

I'm using an action with multiple targets; when only one of them is in the build graph, then (obviously) the other one should be rebuilt. jamplus correctly notices that both should be rebuilt but issues a warning message 'using independent target'. I can use NotFile, but this'll disable timestamp check. Also I can make a pseudo-target that depends on both of them and only use it - this is inconvenient. Perhaps either jamplus can disable the warning in such cases or provide a built-in rule for per-target control?

Example jamplus script follows:

actions Build {
cl $(>) /c

Build foo.obj bar.obj : foo.cpp bar.cpp ;
Depends foo.obj bar.obj : foo.cpp bar.cpp ;

When building it like this

jam foo.obj bar.obj

everything is fine; when building it like this

jam foo.obj

if foo.obj is up to date and bar.obj is not, action is correctly launched, but a warning is issued.

Replies (1)

RE: Disabling "using independent target" warning - Added by Joshua Jensen about 9 years ago

I have updated your sample a bit below, purposely changing the dependencies to more accurately reflect that foo.obj depends on foo.cpp but not on bar.cpp. The same applies for bar.obj depending on bar.cpp but not on foo.cpp.

I also added the updated modifier to the Build action. This allows foo.obj and foo.cpp to be removed from the action when they are up to date. Without the updated modifier, both foo.obj and bar.obj will build regardless of just one changing.

actions updated Build {
    cl $(>) /c

Build foo.obj bar.obj : foo.cpp bar.cpp ;
#Depends foo.obj bar.obj : foo.cpp bar.cpp ;
Depends foo.obj : foo.cpp ;
Depends bar.obj : bar.cpp ;
Clean clean : foo.obj bar.obj ;
Depends all : foo.obj bar.obj ;

You get the 'using independent target' warning, because foo.obj is nowhere in the dependency graph specified by bar.obj.

   0 Name: bar.obj
         : Stable
    Times: (time:1260853823)
         : Depends on bar.cpp (stable) (time:1260852459)
    1 Name: bar.cpp
          : Stable
     Times: (time:1260852459)

All targets passed to the build action must exist in the dependency graph. If any are missing, the 'using independent target' warning pops up.

In reality, my current take on this is that Jam should not allow the build to proceed. It didn't get to properly process the dependencies, such as finding #includes in the .cpp file. That doesn't make for a proper build at all.

I would like to reintroduce the batched modifier (previously specified as an action name of batched_Build) in the next version of JamPlus. The current one (which is commented out) isn't powerful enough to handle a source generating more than one target. Anyway, when that code is written, the 'using independent target' can go away for cases like this.