Boost logo

Boost-Build :

From: Jan Langer (jan_at_[hidden])
Date: 2005-07-29 06:56:54


Vladimir Prus schrieb:
>>I was wondering if someone has already written BBv2 rules for PCCTS. I
>>had a look at
>>
>>http://article.gmane.org/gmane.comp.lib.boost.build/5855
>>
>>but it is not quite what I want. At least I could not adapt it to PCCTS
>>because I have significant problems understanding and using the
>>generator framework of boost-build.
>
> I don't know about PCCTS rules, but current CVS has rules for bison, lex and
> another parser/lexer combo -- Whale/Dolphin.
>
> You probably can base PCCTS on that.

I have already looked at these files, but PCCTS rules seem to be a bit
more complicated.

For example the tool Sorcerer takes an input file treewalker.sor and
generates three files treewalker.cpp, TW.cpp and TW.hpp, where TW is the
name of a class defined inside the sor file. So, the rule had to search
the sor file for a matching regexp. I had it working for a fixed string
(EvaluateRelation in this case), which is of no big use in a general
scenario.

Furthermore, I couldnt figure out how to put usage requirements on the
generated targets (for example a PCCTS specific <include> definition).

I will attach my progress so far.
Jan

 --------------040706020001040302080506 Content-Type: text/plain;
name="pccts.jam"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="pccts.jam"

import type ;
import generators ;
import path ;
import common : find-tool ;
import errors ;
import "class" : new ;

type.register SOR : sor ;

class sorcerer-generator : generator
{
rule __init__ ( id : source : targets + : requirements * )
{
generator.__init__ $(id) : $(source) : $(targets) : $(requirements) ;
}
rule generated-targets ( source : property-set : project name ? )
{
if ! $(name)
{
name = [ $(source).name ] ;
name = $(name:D=) ;
}

local cname = EvaluateRelation ;
local targets =
[ class.new file-target $(name) : $(self.target-types[1]) : $(project) ]
[ class.new file-target $(cname) : $(self.target-types[2]) : $(project) ]
[ class.new file-target $(cname) : $(self.target-types[3]) : $(project) ] ;

local action = [ action-class ] ;
local a = [ class.new $(action) $(targets) : $(source) : $(self.id) : $(property-set) ] ;
for local t in $(targets)
{
$(t).action $(a) ;
$(t).set-intermediate true ;
}

local tar = [ sequence.transform virtual-target.register : $(targets) ] ;
return $(tar) ;
}
}

generators.register [ new sorcerer-generator pccts.sorcerer : SOR : CPP CPP HPP ] ;

rule sorcerer ( target + : source : properties * )
{
local PCCTS = [ modules.peek : PCCTS ] ;
local sorcerer = [ find-tool sor : $(PCCTS)/bin ] ;
if ! $(sorcerer) { errors.error "cannot find sorcerer executable" ; }
sorcerer on $(<) = $(sorcerer) ;
<toolset>gcc:<cxxflags> on $(<[1]) = -Wno-unused ;
<include> on $(<[1]) = $(PCCTS)/sorcerer/h ;
<include> on $(<[1]) = $(PCCTS)/h ;
}

actions sorcerer
{
$(sorcerer) -CPP $(>) -out-dir $(<[1]:D)
}

 --------------040706020001040302080506--


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk