14 messages in com.perforce.jamming[jamming] Implicit action won't work| From | Sent On | Attachments |
|---|---|---|
| Russell | 08 Feb 2003 08:16 | |
| Russell | 08 Feb 2003 17:21 | |
| Ingo Weinhold | 09 Feb 2003 07:23 | |
| Russell | 09 Feb 2003 17:31 | |
| Ingo Weinhold | 10 Feb 2003 02:39 | |
| Russell | 10 Feb 2003 04:27 | |
| Ingo Weinhold | 10 Feb 2003 06:30 | |
| Russell | 10 Feb 2003 19:48 | |
| Chris Antos | 10 Feb 2003 20:13 | |
| Russell | 10 Feb 2003 21:01 | |
| Diane Holt | 10 Feb 2003 21:52 | |
| Diane Holt | 10 Feb 2003 21:54 | |
| Russell | 11 Feb 2003 00:04 | |
| Russell | 11 Feb 2003 00:33 |
| Subject: | [jamming] Implicit action won't work![]() |
|---|---|
| From: | Russell (rjs...@iprimus.com.au) |
| Date: | 02/11/2003 12:04:39 AM |
| List: | com.perforce.jamming |
Diane Holt wrote:
--- Chris Antos <chri...@windows.microsoft.com> wrote:
I thought if rule HEX was executed, then action HEX would *always* be executed too.
Rules aren't exactly what you'd call "executed", but let's leave that for now... I believe your confusion regarding actions always getting run probably arises from the difference between this:
$ cat Jamfile rule HEX { Echo "Doing rule" ; } actions HEX { echo "Doing action" }
HEX somefoo ;
$ jam Doing rule ...found 7 target(s)...
And this:
$ jam somefoo Doing rule ...found 1 target(s)... ...updating 1 target(s)... HEX somefoo Doing action ...updated 1 target(s)...
In the second case I've specifically asked Jam to build "somefoo", and so it does. In order for just 'jam' to do the actions, however, you need to have something that you've asked for depend on the target that your actions would build. Which I assume is why you added the dependency of "all" (the default "asked for without having to explicitly do so" Jam target) to your rule:
rule HEX { Echo "Doing rule" ; Depends all : $(<) ; }
$ jam Doing rule ...found 8 target(s)... ...updating 1 target(s)... HEX somefoo Doing action ...updated 1 target(s)...
Since the actions at this stage of your experimenting don't actually create "somefoo", the target will always be out-of-date, so the actions will always run.
Now let's look at where you currently really are with your rule, actions and target:
rule HEX { local _h ; _h = $(<:S=.hex) ; Depends $(_h) : $(>) ; Depends all : $(_h) ; echo "Rule Hex:" $(<) $(_h) S(>) ; } actions HEX { echo "Action hex:" $(<) $(>) }
HEX myprog : myprog.exe ;
$ jam Rule Hex: myprog myprog.hex myprog.exe ...found 9 target(s)...
$ jam myprog Rule Hex: myprog myprog.hex myprog.exe ...found 1 target(s)... ...updating 1 target(s)... warning: using independent target myprog.exe HEX myprog Action hex: myprog myprog.exe ...updated 1 target(s)...
Note two things -- one, you still need to ask for your target in order for Jam to build it (because nothing depends on it), and two, you've got an "independent target".
What you've not actually done yet is told Jam that just saying 'jam' should build HEX targets -- nor have you got your dependency on myprog.exe set up correctly, which is why it's an "independent target" -- no target depends on it, because "myprog.hex" isn't a target, and "myprog", which is, doesn't depend on "myprog.exe".
The simplest solution -- change your target to be:
HEX myprog.hex : myprog.exe ;
Or, if you want to be a bit more generic:
HEX myprog$(SUFHEX) : myprog$(SUFEXE) ;
And change your rule to be: rule HEX { Depends all : $(<) ; Depends $(<) : $(>) ; Echo "Rule Hex:" $(<) $(>) ; }
Now just running 'jam' will do what you want:
$ jam Rule Hex: myprog.hex myprog.exe ...found 9 target(s)... ...updating 1 target(s)... HEX myprog.hex Action hex: myprog.hex myprog.exe ...updated 1 target(s)...
Because you (implicitly) asked for the (pseudo) target "all" (by just running 'jam') and everything it depends on to be built.
If you didn't want to include the $(SUFHEX) in your target's name, then you can keep your rule as it is, but you'd need to pass $(_h) to, eg., a HEX1 actions:
rule HEX { [...] HEX1 $(_h) : $(>) ; } actions HEX1 { echo "Action hex:" $(<) $(>) }
Note that you can't have your actions just be "HEX", because you need to pass $(_h) to an actions in order for it to get made, because that's not your target in your Jamfile -- myprog is -- and nothing depends on myprog.
Hope this helps, Diane
Hmm. That seems to be the solution. Implicit actions *aren't* always called when the corresponding rule is.
HEX myprog : myprog.exe ;
An impicit rule/action should be thought of as:
HEX(the hex rule) myprog : myprog.exe ; HEX(the hex action) myprog : myprog.exe ;
From what i see, "actions HEX" should be invoked if "rule HEX" sets up a dependency of 'myprog' on 'myprog.exe'.
I see now that an implicit rule is unsuitable for what i'm doing. Thanks for the long answer; i think i get it now;) I'll attempt to submit a multi-subdirectory jam example some time.




