Boost logo

Boost-Build :

Subject: [Boost-build] Symlinks to generated by tao_idl sources
From: Anatoli Sakhnik (sakhnik_at_[hidden])
Date: 2008-12-01 03:50:39


Hi there!

I'm trying to let the BBv2 create symlinks to generated stubs and
skeletons into the source folder, but unsuccessfully yet. This is
needed to simplify code browsing and assistance in vim or Eclipse.

Let's start from the following tao.idl:

############## Begin of tao.idl ###########
import generators ;
import type ;
import feature : feature ;
import toolset : flags ;

type.register IDL : idl ;
type.register INL : inl : H ;
type.register SYM_LINK ;

feature <symlink-sources> : : free path ;

generators.register-standard tao.tao-idl : IDL : CPP(%S) H(%S) CPP(%C)
H(%C) INL(%S) INL(%C) ;

flags tao.tao-idl SYMLINK_SOURCES <symlink-sources> ;

rule tao-idl ( dstS dstS_h dstC dstC_h inlS inlC : src : properties * )
{
    INCLUDES $(dstS) : $(dstS_h) ;
    INCLUDES $(dstC) : $(dstC_h) ;
}

actions tao-idl
{
    tao_idl -o $(<[1]:D) $(>)
    symlink=$(SYMLINK_SOURCES)
    if [ "$symlink" ]; then
        for i in "$(<[1]:D)"/*.{cpp,h,inl}; do
            ln -sf "$i" $symlink/`basename "$i"`
        done
    fi
}
########### End of tao.idl ###################

It allows us to build TAO applications (almost) perfectly:

############# Begin of Jamfile ###############
import tao ;
lib Foo_idl : Foo.idl : <link>static <symlink-sources>. ;
exe FooServer : [ glob *.cc ] Foo_idl TAO_PortableServer ;
############# End of Jamfile ################

The desired symlinks are created by the actions tao-idl.
Unfortunately, they are left after doing 'bjam clean'. So I tried to
create them legally extending default generator (the idea was taken
from tools/stage.jam, shared libraries):

############# Begin ###################

class sources-from-idl-generator : generator
{
    rule __init__ ( )
    {
        generator.__init__ tao.tao-idl : IDL
            : CPP(%S) H(%S) CPP(%C) H(%C) INL(%S) INL(%C) ;
    }

    rule run ( project name ? : property-set : source : multiple ? )
    {
        local result = [ construct-result $(source) : $(project) $(name)
                                                    : $(property-set) ] ;
        local generated = [ generated-targets $(source) : $(property-set)
                                                        : $(project) $(name) ] ;
        local loc = [ $(project).location ] ;
        for local file in $(generated)
        {
            local name = [ $(file).name ] ;
            local link = $(loc)/$(name) ;
            result += [ symlink $(link) : $(project)
                                        : $(file) : $(property-set) ] ;
        }
        return $(result) ;
    }

    rule symlink ( name : project : source : properties )
    {
        local a = [ new action $(source) : symlink.ln : $(properties) ] ;
        local targets = [ new file-target $(name) exact : SYMLINK
                                                        : $(project) : $(a) ] ;
        return $(targets) ;
    }
}

generators.register [ new sources-from-idl-generator ] ;
##################################################

The needed generators are created, but obviously they aren't called
during the build. And I can't figure out how to request them. What am
I missing? How to create those symlinks and to have them removed after
cleaning?

— Anatoli Sakhnik


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