2 messages in com.perforce.jamming[jamming] Including different Jam in ...
FromSent OnAttachments
Ehab Teima31 Jul 2002 10:50 
Ingo Weinhold01 Aug 2002 02:57 
Subject:[jamming] Including different Jam in another one
From:Ingo Weinhold (bone@cs.tu-berlin.de)
Date:08/01/2002 02:57:04 AM
List:com.perforce.jamming

On Wed, 31 Jul 2002, Ehab Teima wrote:

I'm just getting started with Jam. I have several jam files that build different pieces of a product. I'm trying to write another jam (wrapper) that includes all of those ones to build the whole product in one shot. My question is too simple but I am just a new dev to Jam. How do I tell jam to cd to a directory before trying to build some pieces? My question is because all pieces that have to be built from a different directory failed while the ones in the same directory of the wrapper succeeded.

I'm not sure, if I understand your problem correctly. You have several Jamfile trees building different parts of your project, but being completely independent from each other. And now you want to create a common root Jamfile that joins the parts.

The problem with the current Jam is, that each Jamfile needs to know its exact location in the tree, that is the path from the root to itself. If you have different trees with different roots and want to create a single root, you'll have to adjust *all* Jamfiles. Something you can do with make, to cd into a subdir and invoke another make for it, does work for Jam too, but could not be considered being very nice. You can define pseudo targets that are being built by cd'ing into a subdirectory and invoking Jam therein. This would look like: (Untested!)

rule SubDirBuild { # SubDirBuild <pseudo target> : <directory> ; Always $(1) ; NotFile $(1) ; Depends $(1) : $(2) ; # to avoid warnings Depends all : $(1) ; }

actions SubDirBuild { cd $(2) ; jam }

SubDirBuild sub1 : subdir1 ; SubDirBuild sub2 : subdir2 ; SubDirBuild sub3 : subdir3 ;

As with make, using this strategy you lose some features, e.g. to be able to specify targets on the command line and job control. So in general the unified Jamfile tree approach is to be preferred.

To analyze the actual source of your problem: It's the stupidity of the SubDir and SubInclude rules in the current Jam version. Even now and with only few changes SubInclude could take a dir argument relative to the location of the Jamfile. With a bit more work SubDir could be made clever enough to abandon the path argument. Then Jamfiles wouldn't contain any hardcoded locations any more, which increased the maintainability a lot. It would be painless to move a complete subtree, as changes had to be made only to the Jamfiles in the two concerned superdirectories.

CU, Ingo