4 messages in com.perforce.jamming[jamming] Newbie: simplest system for
FromSent OnAttachments
Dann...@ishiboo.com15 Sep 2000 18:09 
Eric...@Adobe.COM16 Sep 2000 09:10 
Gran...@palm.com Grant_Glouser@palm.com19 Sep 2000 15:36 
Gran...@palm.com Grant_Glouser@palm.com19 Sep 2000 17:22 
Subject:[jamming] Newbie: simplest system for
From:Gran...@palm.com Grant_Glouser@palm.com (Gran@palm.com Grant_Glouser@palm.com)
Date:09/19/2000 03:36:47 PM
List:com.perforce.jamming

Eric Scouten scou@Adobe.COM, Thu, 14 Sep 2000 08:41:

At 09/14/2000 09:16, Amaury FORGEOT-d'ARC wrote:

You could create a new SubDir rule (in your Jamrules file):

rule MySubDir { SubDir $(<) ; if $(DEBUG) { LOCATE_TARGET = $(SUBDIR)/debug ; } }

This trick won't work reliably. (I tried something similar recently.)

If you look at the definition of SubDir (in Jambase), the first Jamfile that gets read in relies on SubDir to read Jamrules, so your build will fail with an unknown command "MySubDir" if you start jam from a directory with a Jamfile that uses this rule because it hasn't seen the definition in Jamrules yet. :-(

For this to work, you'd have to add the rule to Jambase and rebuild Jam.

My solution to this is to add a "hook" to the SubDir rule. This requies changing the Jambase and rebuilding Jam - but only once! After that you can change the behavior of SubDir without rebuilding Jam every time.

At the end of SubDir in the Jambase, I add this: # invoke SubDirHook for customization by Jamrules SubDirHook $(<) ;

Then add an empty SubDirHook to the Jambase (this prevents Jam from complaining if you decide not to use a SubDirHook in your Jamrules): rule SubDirHook { # Override this rule in the Jamrules }

Notice that the SubDirHook is invoked *after* reading Jamrules. So, the new SubDirHook rule in your Jamrules will always be used, even in the first call to SubDir.

In the Jamrules, in this example, you could put a SubDirHook like this: rule SubDirHook { if $(DEBUG) { LOCATE_TARGET = $(SUBDIR)/debug ; } }

This technique (hooks that can be overridden in Jamrules) could be used in other places, but SubDir is where I've found it most useful.

Grant