Boost logo

Boost-Build :

Subject: Re: [Boost-build] Forwarding <include> Requirements
From: Brad Howes (howes_at_[hidden])
Date: 2009-01-09 12:43:53


On Jan 8, 2009, at 5:21 PM, Steven Watanabe wrote:

> You can add usage-requirements in the generator's run rule.
>
> class idl-generator : generator
> {
> # ...
> rule run ( project name ? : property-set : sources + )
> {
> # ...
> result = [ generator.run $(project) $(name) : $(property-set) :
> $(sources) ] ;
> return [ property-set.create <include>some/path ] $(result) ;
> }
> }

Thanks for the guidance, however I tried that, and saw where similar
constructs were being used, but no dice. Still not seeing the required
-I directive in the g++ line.

Looking more closely at midl.idl, I found that its scanner was also
invoking property-set.create together with what looks like property
propagations into the CPP scanner. Trying a similar approach I got no
closer to a solution as far as I can tell. What follows is my idl.jam
file followed by a partial build trace:

#
# OpenSplice Interface Definition Language (IDL) routines
#

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

#
# First-time flag
#
.initialized = ;

#
# Initiaization function for this module. Just grab environment
variable values
# associated with OpenSplice and create appropriate command lines to
invoke
# OpenSplice's idlpp executable.
#
rule init ( )
{
        ECHO init ;
        if ! $(.initialized)
        {
            idl.TOP = [ modules.peek : SIDECAR_SRC ] ;
                ECHO init TOP $(idl.TOP) ;

            idl.HOME = [ modules.peek : OSPL_HOME ] ;
                ECHO init HOME $(idl.HOME) ;

                idl.INCLUDE = $(idl.HOME)/include/dcps/C++/SACPP ;
                ECHO init INCLUDE $(idl.INCLUDE) ;

                idl.IDLPP = $(idl.HOME)/bin/idlpp -I$(idl.TOP) -I$(idl.HOME)/etc/
idlpp ;
                .initialized = true ;

                #
                # Define new file types that our generator will handle.
                #
                type.register OpenSpliceIDL : idl ;
                generators.register [ new OpenSpliceIDL-generator ] ;
                scanner.register OpenSpliceIDL-scanner : include ;
                type.set-scanner OpenSpliceIDL : OpenSpliceIDL-scanner ;
        }
}

rule getOpenSpliceHome ( )
{
        ECHO getOpenSpliceHome $(idl.HOME) ;
        return $(idl.HOME) ;
}

rule getCPPInclude ( )
{
        ECHO getCPPInclude $(idl.INCLUDE) ;
        return <include>$(idl.INCLUDE) ;
}

#
# Scanner for IDL files. Adapted from midl-scanner in midl.jam
#
class OpenSpliceIDL-scanner : scanner
{
        import idl path property-set regex scanner type virtual-target ;

     rule __init__ ( includes * )
     {
                scanner.__init__ ;

                #
                # Add the CPP include directory in hopes that it will propagate to the
                # CPP targets.
                #
                local cppInclude = [ idl.getCPPInclude ] ;
                includes += $(cppInclude) ;
                ECHO OpenSpliceIDL-scanner includes $(includes) ;
                self.includes = $(includes) ;
                ECHO OpenSpliceIDL-scanner self.includes $(self.includes) ;
     }

     rule pattern ( )
     {
         return "#[ \t]*include[ ]*(<(.*)>|\"(.*)\")" ;
     }

     rule process ( target : matches * : binding )
     {
         local angle = [ regex.transform $(matches) : "<(.*)>" ] ;
         local quoted = [ regex.transform $(matches) : "\"(.*)\"" ] ;

         local g = [ on $(target) return $(HDRGRIST) ] ;
         local b = [ NORMALIZE_PATH $(binding:D) ] ;

         local g2 = $(g)"#"$(b) ;

                ECHO angle $(angle) ;
                ECHO quoted $(quoted) ;

         angle = $(angle:G=$(g)) ;
         quoted = $(quoted:G=$(g2)) ;

         local all = $(angle) $(quoted) ;
                ECHO OpenSpliceIDL-scanner process all $(all) ;
         INCLUDES $(target) : $(all) ;
         NOCARE $(all) ;
         SEARCH on $(angle) = $(self.includes:G=) ;
         SEARCH on $(quoted) = $(b) $(self.includes:G=) ;

                scanner.propagate [ type.get-scanner CPP :
                                                          [ property-set.create $(self.includes) ] ] :
                                                  $(all) : $(target) ;

         scanner.propagate $(__name__) : $(all) : $(target) ;
     }
}

class OpenSpliceIDL-generator : generator
{
        import idl property-set ;

        rule __init__ ( )
        {
                ECHO "OpenSpliceIDL-generator init" ;
                generator.__init__ idl.OpenSpliceIDLPP
                                                   : OpenSpliceIDL
                                                   :
                                                         CPP(%)
                                                         CPP(%Dcps)
                                                         CPP(%Dcps_impl)
                                                         CPP(%SplDcps)
                                                         H(ccpp_%)
                                                         H(%Dcps)
                                                         H(%Dcps_impl)
                                                         H(%SplDcps)
                                                   ;
        }

# rule generated-targets ( sources + : property-set : project name ? )
# {
# local gt = [ generator.generated-targets $(sources) : $(property-
set) :
# $(project) $(name) ] ;
# return $(gt) ;
# }
#
        rule run ( project name ? : property-set : sources + )
        {
                local cppInclude = [ idl.getCPPInclude ] ;
                ECHO OpenSpliceIDL-generator run cppInclude $(cppInclude) ;
                local rc = [ generator.run $(project) $(name) : $(property-set) :
                                                                         $(sources) ] ;
                return [ property-set.create $(cppInclude) ] $(rc) ;
        }
}

actions OpenSpliceIDLPP
{
        $(idl.IDLPP) -d $(<[1]:D) -S -l cpp $(>)
}

**** Build Run ****

howes% bjam
...using Intel Math Kernel Libraries (32)
init
init TOP /home/howes/sidecar/trunk
init HOME /opt/PrismTech/OpenSpliceDDS/V3.4.3/HDE/x86.linux2.6
init INCLUDE /opt/PrismTech/OpenSpliceDDS/V3.4.3/HDE/x86.linux2.6/
include/dcps/C++/SACPP
OpenSpliceIDL-generator init
getCPPInclude /opt/PrismTech/OpenSpliceDDS/V3.4.3/HDE/x86.linux2.6/
include/dcps/C++/SACPP
OpenSpliceIDL-generator run cppInclude <include>/opt/PrismTech/
OpenSpliceDDS/V3.4.3/HDE/x86.linux2.6/include/dcps/C++/SACPP
getCPPInclude /opt/PrismTech/OpenSpliceDDS/V3.4.3/HDE/x86.linux2.6/
include/dcps/C++/SACPP
OpenSpliceIDL-generator run cppInclude <include>/opt/PrismTech/
OpenSpliceDDS/V3.4.3/HDE/x86.linux2.6/include/dcps/C++/SACPP
getCPPInclude /opt/PrismTech/OpenSpliceDDS/V3.4.3/HDE/x86.linux2.6/
include/dcps/C++/SACPP
OpenSpliceIDL-scanner includes <include>/home/howes/sidecar/trunk
<include>/opt/PrismTech/OpenSpliceDDS/V3.4.3/HDE/x86.linux2.6/include/
dcps/C++/SACPP
OpenSpliceIDL-scanner self.includes <include>/home/howes/sidecar/trunk
<include>/opt/PrismTech/OpenSpliceDDS/V3.4.3/HDE/x86.linux2.6/include/
dcps/C++/SACPP
...found 27 targets...
...updating 14 targets...
MkDir1 bin
MkDir1 bin/gcc-4.1.2
MkDir1 bin/gcc-4.1.2/debug
MkDir1 bin/gcc-4.1.2/debug/threading-multi
idl.OpenSpliceIDLPP bin/gcc-4.1.2/debug/threading-multi/Header.cpp

OpenSplice DDS V3.4.3, (c) PrismTech Ltd.

gcc.compile.c++ bin/gcc-4.1.2/debug/threading-multi/Header.o
In file included from bin/gcc-4.1.2/debug/threading-multi/Header.cpp:15:
bin/gcc-4.1.2/debug/threading-multi/Header.h:17:26: error:
sacpp_orb_pa.h: No such file or directory
bin/gcc-4.1.2/debug/threading-multi/Header.h:18:22: error: eOrb/DDS.h:
No such file or directory
bin/gcc-4.1.2/debug/threading-multi/Header.h:19:24: error: eOrb/
idl_c.h: No such file or directory
.
.
.
     "g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -fPIC -
pthread -D__DEBUG__ -Wno-long-long -Winit-self -pipe -Dlinux -I"/home/
howes/sidecar/trunk" -I"bin/gcc-4.1.2/debug/threading-multi" -c -o
"bin/gcc-4.1.2/debug/threading-multi/Header.o" "bin/gcc-4.1.2/debug/
threading-multi/Header.cpp"

...failed gcc.compile.c++ bin/gcc-4.1.2/debug/threading-multi/
Header.o...

In short, I need to have -I$(idl.INCLUDE) in the above G++ command so
that it can find the necessary IDL C++ headers.

Regards,

Brad

-- 
Brad Howes
Group 42
MIT Lincoln Laboratory • 244 Wood St. • Lexington, MA 02173
Phone: 781.981.5292 • Fax: 781.981.3495 • Secretary: 781.981.7420

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