Boost logo

Boost-Build :

Subject: Re: [Boost-build] Manipulating target names
From: Johan Larsson (hnefi.mail_at_[hidden])
Date: 2009-09-17 10:47:25


I solved it - after some work. I created a custom generator, posted below in
case anyone else needs something similar.

The pattern matching in particular was troublesome to figure out. "egrep
style regexp", as the docs put it, didn't say much; particularly regarding
the way MATCH divides its matched strings into different elements of the
return value. Perhaps there is a nicer way to deal with prefixes in bjam?

# omniidl.jam

import generators ;
import type ;
import "class" : new ;

type.register IDL : idl ;

class idl-generator : generator
{
    # Determine the name of the produced target from the
    # names of the sources.
    rule determine-output-name ( 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 ] ] ;

        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 includes an I. Strip it!
        name = $(name:D=) ;
        #match the first letter I. Put it in m[1].
        #Then match everything else. Put it in m[2].
        local m = [ MATCH (^[I]?)(.*) : $(name) ] ;
        return T$(m[2]) ;
    }
}

generators.register
  [ new idl-generator omniidl.omniidl : IDL : CPP(%Caller) CPP(%Dispatcher)
] ;

rule omniidl ( targets + : source : properties * : d * : e * )
{
}

#Hrrrmmm... make this nicer. And a LOT more general.
actions omniidl
{
  <idl invocation command> -C ./ $(>)
  cp *.h bin/gcc/xxx/link-static
  cp *.cpp bin/gcc/xxx/link-static
}

# end of omniidl.jam



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