Boost logo

Boost-Build :

From: Frank Birbacher (bloodymir.crap_at_[hidden])
Date: 2007-08-31 14:14:49


Hi!

I don't come to grips with the following problem. I want to use ZeroC
Ice and I want to extend Build for slice files. These slice files
contain interface definitions and get compiled using "slice2cpp". This
program takes an "*.ice" file as input an generates a *.cpp/*.h pair. I got:

type.register SLICE : ice ;
generators.register-standard slices.slice2cpp : SLICE : CPP H ;

Problem 1: the slice2cpp tool does not accept an output filename, but
only an output directory. I got this running by using:

rule slice2cpp ( targets * : source : properties * )
{
        local t_src = $(targets[1]) ;
        local path = [ MATCH "<p([^<>]+)>" : $(t_src:P) ] ;
        OUTPUTDIR on $(targets) = $(path) ;
}
...
obj slice_obj_$(source) : $(source) : $(requirements) ;

But Build seems to dictate a specific output filename "slice_obj_foo.h"
which differs from the input filename "foo.ice". This would make the
"slice_obj_foo.cpp" contain wrong includes: ("#include <foo.h>" won't
work). So I need to tell Build the correct output filename. How?

Problem 2: when compiling multiple slice files into a single library the
c++ compiler complains about not finding includes: the generated .cpp
files include other headers which need to be generated first and then
included.

complete slices.jam:

import type ;
import project ;
import generators ;

type.register SLICE : ice ;
generators.register-standard slices.slice2cpp : SLICE : CPP H ;

rule slice2cpp ( targets * : source : properties * )
{
        local t_src = $(targets[1]) ;
        local path = [ MATCH "<p([^<>]+)>" : $(t_src:P) ] ;
        OUTPUTDIR on $(targets) = $(path) ;
}

actions slice2cpp
{
        slice2cpp --ice -I.. --output-dir $(OUTPUTDIR) $(>)
}

rule slices ( name : sources * : requirements * )
{
        local project = [ project.current ] ;

        for source in $(sources)
        {
                obj slice_obj_$(source) : $(source) : $(requirements)
                                <implicit-dependency>$(sources) ;
########## ^^ HERE ^^ implicit dependency??? ######
                $(project).mark-target-as-explicit slice_obj_$(source) ;
        }
        lib slice_$(name) : slice_obj_$(sources) : $(requirements) ;
        $(project).mark-target-as-explicit slice_$(name) ;

        alias $(name) : slice_$(name) : : :
                <implicit-dependency>slice_$(name) ;
}

IMPORT $(__name__) : slices : : slices ;

I think I should be using a custom generator, but I had no luck using
classes yet (class "new" could not find the __init__ function of my
class?!?).

Frank


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