[jamming] trouble with rule that generates a .cpp file

Joshua ChaitinPollak jpollak at kivasystems.com
Thu Jul 5 13:21:51 PDT 2007


Hello,

I have a rule, WriteRevision, in my Jamrules file that polls my revision
control system and generates a file called revision.cpp. I'm having
trouble getting it to work reliably with multiple sub executables.
Either the revision.cpp file is created in an unexpected directory, or
jam can't find it correctly. What I would like is to make my
WriteRevision rule alway create revision.cpp in $(TOP), and have jam
know to look there for revision.cpp when I include it in my binaries
with the Main rule. 

Can someone help? Examples and my WriteRevision rule are below.

Thanks,

-Josh

#### foo/Jamfile
SubDir TOP foo ;

WriteRevision revision.cpp ;

Main foo : 
	foo.cpp
	revision.cpp  # I would like jam to look in $(TOP) for this
	;
#### end foo/Jamfile


#### begin $(TOP)/Jamrules

rule WriteRevision
{
  Always $(<) ;
  WriteRevision1 $(<) : $(>) ;
  Clean clean : $(<) ;
}

# I would like to force this to write to $(TOP)
actions WriteRevision1
{
  rev=`svnversion`
  url=`svn info | grep URL | cut -f2 -d\ `
  echo "#include <Config.h>" > $(<)
  echo "void getRev(std::string& rev) { rev = \"$rev\"; }" >> $(<)
  echo "void getRevUrl(std::string& url) { url = \"${url}\"; }" >> $(<)
}
#### end $(TOP)/Jamrules


More information about the jamming mailing list