|
Boost-Build : |
From: Fabien Chêne (fabien.chene_at_[hidden])
Date: 2007-01-12 14:04:41
fabien.chene_at_[hidden] (Fabien Chêne) writes:
Sorry to answer to myself, but a few month later, I'm still on this
problem :-/
> I am currently trying to move a project from Boost.Jam to
> Boost.Build-V2. A major thing to do is to manage compilation and
> dependancies of IDL files, using omniidl.
>
> omniidl -Wba -bcxx invoked on an IDL file (saying foo.idl) generate 3
> files : fooSK.h fooSK.cc fooDynSK.cc
^^^^^^^
not fooSK.h, but foo.hh
> Since I'm a newbie in bbv2, I try to go crescendo and start with a
> standard generator. This is OK, but it compiles foo.o. To solve this
> problem, I think I need to create a custom generator for that
> (right?). I'm stuck at the following step, I copy-paste and adapt the
> exemple given in the documentation, in a file named idl.jam:
>
> #------------------------ idl.jam ----------------------------
> import type ;
> type.register IDL : idl ;
>
> import generators ;
>
> actions stub-skeleton-files
> {
> "omniidl -Wba -bcxx" $(>)
> }
>
> class omniidl-generator : generator
> {
> rule __init__ ( * : * )
> {
> generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6)
> : $(7) : $(8) : $(9) ;
> }
> }
>
> generators.register
> [ new omniidl-generator idl.stub-skeleton-files : IDL : CPP ] ;
>
> #---------------------------------------------------------
>
> But bjam grouses and says:
> « /home/fabien/prog/C++/Bjam/rep1/idl.jam:29:in load
> rule new unknown in module idl. »
>
> What is wrong with that ?
I add the following line : import "class" : new ; and it solves the
problem -- it was not in the documentation, is it so obvious ?
> Otherwise, how can I tell bjam that a single IDL file will produce 2
> CPP files and 1 CPP header file ? Have I got to modify the following
> instruction (something like this) ?
>
> generators.register
> [ new omniidl-generator idl.stub-skeleton-files : IDL : CPP CPP HPP ] ;
Finally, I wrote
generators.register
[ new omniidl-generator idl.stub-skeleton-files : IDL : CPP HPP ] ;
and I override the rule generated-targets in idl.jam :
rule generated-targets ( sources + : property-set : project name ? )
{
if ! $(name)
{
# Determine the name of the produced target from the
# names of the sources. The simple case if when a name
# of source has single dot. Then, we take the part before
# dot. Several dots can be caused by:
# - Using source file like a.host.cpp
# - A type which suffix has a dot. Say, we can
# type 'host_cpp' with extension 'host.cpp'.
# In the first case, we want to take the part till the last
# dot. In the second case -- no sure, but for now take
# the part till the last dot too.
name = [ utility.basename [ $(sources[1]).name ] ] ;
echo "name:" $(name) ;
for local s in $(sources[2])
{
local n2 = [ utility.basename [ $(s).name ] ] ;
if $(n2) != $(name)
{
error "$(self.id): source targets have different names: cannot determine target name" ;
}
}
# Names of sources might include directory. We should strip it.
name = $(name:D=) ;
}
# Assign an action for each target
local action = [ action-class ] ;
local a = [ class.new $(action) $(sources) : $(self.id) :
$(property-set) ] ;
# Create generated target for each target type.
local targets ;
local pre = $(self.name-prefix) ;
local post1 = SK ;
local post2 = DynSK ;
for local t in $(self.target-types)
{
if $(t) = CPP
{
local generated-name = $(pre[1])$(name)$(post1[1]) ;
local generated-name2 = $(pre[1])$(name)$(post2[1]) ;
targets += [ class.new file-target $(generated-name)
: $(t) : $(project) : $(a) ] ;
targets += [ class.new file-target $(generated-name2)
: $(t) : $(project) : $(a) ] ;
}
else if $(t) = HPP
{
targets += [ class.new file-target $(name)
: $(t) : $(project) : $(a) ] ;
}
pre = $(pre[2-]) ; #don't know what it means
post = $(post[2-]) ; #don't know what it means
}
return [ sequence.transform virtual-target.register : $(targets) ] ;
}
In my Jamfile :
exe e : toto.idl ;
it produces the following compilation commands :
idl.stub-skeleton-files bin/gcc-4.1.1/debug/totoSK.cc
bin/gcc-4.1.1/debug/totoDynSK.cc bin/gcc-4.1.1/debug/toto.hh
"omniidl" -bcxx toto.idl
gcc.compile.c++ bin/gcc-4.1.1/debug/totoSK.o
"ccache" "g++" -Wall -ftemplate-depth-100 -O0 -fno-inline -g -fPIC
-I"bin/gcc-4.1.1/debug" -c -o "bin/gcc-4.1.1/debug/totoSK.o"
"bin/gcc-4.1.1/debug/totoSK.cc"
gcc.compile.c++ bin/gcc-4.1.1/debug/totoDynSK.o
"ccache" "g++" -Wall -ftemplate-depth-100 -O0 -fno-inline -g -fPIC
-I"bin/gcc-4.1.1/debug" -c -o "bin/gcc-4.1.1/debug/totoDynSK.o"
"bin/gcc-4.1.1/debug/totoDynSK.cc"
The problem is that the .cc file is not at the good location. It is
normaly in the same directory of the Jamfile, instead of being in the
directory "bin/gcc-4.1.1/debug/. How can I fix that ?
Any help will be greatly appreciated !
Thanks
-- Fab
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