[jamming] Implicit action won't work

Russell rjshaw at iprimus.com.au
Mon Feb 10 21:01:27 PST 2003

Chris Antos wrote:
>>I thought if rule HEX was executed, then action HEX would 
>>*always* be executed too. It says here:
>>  http://www.perforce.com/perforce/conf2001/wingerd/WPLaura.pdf
>>3.7 Implicity Invoked Actions
>>When an action and a rule have the same name, Jam implicitly 
>>invokes the action with the same arguments that were used in 
>>the rule invocation.
> It's true, if you take into account that the whole point of Jam or Make
> or Nmake or etc is to define dependencies so that only the actions that
> *need* to happen are actually executed.  It seems you interpreted the
> section as saying "actions are always executed if a rule is executed",
> but (a) I can't find where it says that [good, because it's not true
> :-)] and (b) the point that section is trying to make is that "when an
> action is executed, its arguments are the same as those used in the rule
> invocation".
> In your case, the problem is simple.  You never said that $(<) depends
> on $(_h).  So de facto it does not.  :-)
>    Depends all : $(_h) ;

I don't seem to get it yet;)
The original code is at the end of this message for clarity.
In Jamfile, i have:

   HEX myprog : myprog.exe ;

In Jamrules:

   _h = $(<:S=.hex) ;         # _h is myprog.hex
   Depends $(_h) : $(>) ;     # myprog.hex depends on myprog.exe
   Depends all : $(_h) ;      # 'all' depends on myprog.hex

So, jam sees that 'all' depends on myprog.hex, which in
turn depends on myprog.exe. Therefore, the actions for
building myprog.exe and myprog.hex should execute. However,
i still don't get why the "actions HEX" for myprog.hex
doesn't happen.

> You did say that "all" depends on $(_h), so at some point during Jam it
> should in fact build the .hex file, but possibly not in time for it to
> serve as an input to whatever actions are using.  "all" is a
> pseudo-target; note that the statement above does not mean "make each
> individual target depend on $(_h)".  Did you add that line just to
> suppress the "independent target" warning that you'd otherwise get?
> Here's the line you should be using instead:
>    Depends $(<) : $(_h) ;

This means:
   Depends myprog : myprog.hex ;

That's what i don't get. If 'all' depends on myprog.hex,
then why is 'myprog' needed in a Depends statement?

Original post:

In Jamfile, i have:
SubDir TOP ;
HEX myprog : myprog.exe ;

In Jamrules, i have:
TOP = /home/russell/test ;
SUFEXE = .exe ;
rule HEX
   local _h ;
   _h = $(<:S=.hex) ;
   Depends $(_h) : $(>) ;
   Depends all : $(_h) ;
   echo "Rule Hex:" $(<) $(_h) S(>) ;
actions HEX
   echo "Action hex:" $(<) $(>)

I created /home/russell/test/myprog.exe with "touch myprog.exe".

When i run jam, i get:

   Rule hex: myprog myprog.hex myprog.exe
   ...found 9 target(s)...

which shows action HEX didn't execute. The last few lines of jam -d 3
   made  newer myprog.exe
   made+ missing myprog.hex
   made  update all
   ...found 9 target(s)...

I don't know why "actions HEX" doesn't work.

More information about the jamming mailing list