Boost logo

Boost-Build :

From: Schnyder Franz (fschnyder_at_[hidden])
Date: 2005-11-03 17:48:00


Hello

I'm trying to write a toolset for compiling for VxWorks.
Under VxWorks C++ files need a special treatment called munching which
results a regular C file. This file must be compiled and also be linked
to the executable or the "dll".
So I wrote the rules and generators found at the bottom.
Everything worked fine when I used lib or exe.
Then I needed to set a special flag for only one source file. I used the
obj rule and run in to a problem: "error: Ambiguity found when searching
for best transformation".

I used the --debug-generators and found out that he finds the following:

1. x.cpp –> compile.c++ ->> x.obj
2. x.cpp –> compile.c++ ->> x.obj -> lst ->> x.lst -> munch ->> x.c
    -> compile.c ->> x.obj

The first one is the one I need, the second makes no sense, but the
generators can't know.
How can I "break" the second transformation so just the first one would
be successful ?
Or are my generators totally wrong and should be written in a different
way ?

Thanks,

Franz

********************************************************************************
rules:
********************************************************************************

#----------------------------------------------------------------------------
# creating list (lst) files
#----------------------------------------------------------------------------

generators.register-composing vxworks.lst : OBJ STATIC_LIB : LST
                                           : <toolset>vxworks ;

#----------------------------------------------------------------------------

rule lst ( target : source * : properties * )
{
     # create the actual filename from <pPATH>NAME
     local boundSource ;
     for local s in $(source)
     {
         local grist = [ MATCH ^<p(.*)>$ : $(s:G) ] ;
         boundSource += [ path.native [ path.join $(grist) $(s:G=) ] ] ;
     }

     # write the lst file
     print.output $(target) ;
     print.text $(boundSource) : true ;

}

#----------------------------------------------------------------------------
# munching
#----------------------------------------------------------------------------

generators.register-standard vxworks.munch : LST : C : <toolset>vxworks ;

#----------------------------------------------------------------------------

actions munch
{
     "$(MUNCH)" @$(>) | "$(GREP)" GLOBAL | "$(WTXTCL)" "$(MUNCH_TCL)"
> $(<)
}

#
-----------------------------------------------------------------------------
# linking
#
-----------------------------------------------------------------------------

class vxworks-linking-generator : gcc-linking-generator
{
     import vxworks ;

     rule for_each ( objs * : rulename )
     {
         local ret ;
         for local obj in $(objs)
         {
             ret += [ $(obj).$(rulename) ] ;
         }
         return $(ret) ;
     }

     rule run ( project name ? : property-set : sources + )
     {
       local cleanSources ;
       local usage-requirements ;

       # echo sources ist [ for_each $(sources) : name ] ;

       # remove the cmp's from the sources and add them to preloads
       for local source in $(sources)
       {
           if [ $(source).type ] = SHARED_LIB
           {
               usage-requirements += <preload>$(source) ;
           }
           else
           {
               cleanSources += $(source) ;
           }
       }

       # echo cleanSources ist [ for_each $(cleanSources) : name ] ;

       # create the lst file with all the obj's in it
       local lst-sources = [ generators.construct $(project) $(name) : LST
                                         : $(property-set) :
$(cleanSources) ] ;
       if $(lst-sources) && [ class.is-a $(lst-sources[1]) : property-set ]
       {
           $(property-set) = [ $(property-set).add-raw [
$(lst-sources[1]).raw ] ] ;
           lst-sources = $(lst-sources[2-]) ;
       }

       # munching : creates a $(name)_ctdt.c file
       local munch-sources = [ generators.construct $(project)
$(name)_ctdt : C
                                         : $(property-set) :
$(lst-sources) ] ;
       if $(munch-sources) && [ class.is-a $(munch-sources[1]) :
property-set ]
       {
          munch-sources = $(munch-sources[2-]) ;
       }

       local result = [ gcc-linking-generator.run $(project) $(name)
                                 : $(property-set)
                                 : $(lst-sources) $(munch-sources) ] ;

       local requirements-property-set ;

       # merge the requirements
       if $(result) && [ class.is-a $(result[1]) : property-set ]
       {
           requirements-property-set = $(result[1]) ;
           requirements-property-set = [
$(requirements-property-set).add-raw
                                         $(usage-requirements) ] ;
           result = $(result[2-]) ;
       }
       else
       {
           requirements-property-set = [ property-set.create
$(usage-requirements) ] ;
       }

       # if its a cmp add it self to the preloads !
       if [ $(result).type ] = SHARED_LIB
       {
         # if there allready preloads in the requirements put them in
the order befor this cmp
         local preloads = [ $(requirements-property-set).get <preload> ] ;
         vxworks.order-add $(preloads) : $(result) ;
         requirements-property-set = [
$(requirements-property-set).add-raw <preload>$(result) ] ;
       }

       return $(requirements-property-set) $(result) ;
     }

}

#----------------------------------------------------------------------------

generators.register [ new vxworks-linking-generator vxworks.link : LST
LIB OBJ
                                 : EXE : <toolset>vxworks ] ;

#----------------------------------------------------------------------------

generators.register [ new vxworks-linking-generator vxworks.link.dll :
LST LIB OBJ
                                 : SHARED_LIB : <toolset>vxworks ] ;

#----------------------------------------------------------------------------

********************************************************************************
Output with --debug-generators :
********************************************************************************

      *** construct OBJ
          from { ../src/BSysListenerMock.cpp.CPP }
          properties: <asynch-exceptions>off <cxxflags>-Wno-deprecated
<cxxflags>-fexceptions <debug-symbols>on <exception-handling>off
<extern-c-nothrow>off <hardcode-dll-paths>true <include>../..
<inlining>off <install-dependencies>off <link>shared
<main-target-type>OBJ <optimization>off <os>NT <profiling>off <rtti>on
<runner-quiet>yes <runner-runOnTarget>yes <runtime-debugging>on
<runtime-link>shared <stdlib>native <symlink-location>project-relative
<threading>single <toolset>vxworks <user-interface>console <variant>debug
      find-viable-generators target-type= OBJ property-set= vxworks/debug
      trying type OBJ
      there are generators for this type
      trying generator gcc.compile.c++ ( CPP -> OBJ )
      trying generator gcc.compile.c ( C -> OBJ )
      trying generator vxworks.compile.c++ ( CPP -> OBJ )
        is viable
      trying generator vxworks.compile.c ( C -> OBJ )
        is viable
      *** 2 viable generators
        generator vxworks.compile.c++
        multiple:
        composing:
      alt1
        SUCCESS: { vxworks%vxworks.compile.c++-BSysListenerMock.obj.OBJ
{ ../src/BSysListenerMock.cpp.CPP } }

        generator vxworks.compile.c++ spawned
        { vxworks%vxworks.compile.c++-BSysListenerMock.obj.OBJ {
../src/BSysListenerMock.cpp.CPP } }
        generator vxworks.compile.c
        multiple:
        composing:
          *** construct C
              from { ../src/BSysListenerMock.cpp.CPP }
              properties: <asynch-exceptions>off
<cxxflags>-Wno-deprecated <cxxflags>-fexceptions <debug-symbols>on
<exception-handling>off <extern-c-nothrow>off <hardcode-dll-paths>true
<include>../.. <inlining>off <install-dependencies>off <link>shared
<main-target-type>OBJ <optimization>off <os>NT <profiling>off <rtti>on
<runner-quiet>yes <runner-runOnTarget>yes <runtime-debugging>on
<runtime-link>shared <stdlib>native <symlink-location>project-relative
<threading>single <toolset>vxworks <user-interface>console <variant>debug
          find-viable-generators target-type= C property-set= vxworks/debug
          trying type C
          there are generators for this type
          trying generator vxworks.munch ( LST -> C )
            is viable
          *** 1 viable generators
            generator vxworks.munch
            multiple:
            composing:
              *** construct LST
                  from { ../src/BSysListenerMock.cpp.CPP }
                  properties: <asynch-exceptions>off
<cxxflags>-Wno-deprecated <cxxflags>-fexceptions <debug-symbols>on
<exception-handling>off <extern-c-nothrow>off <hardcode-dll-paths>true
<include>../.. <inlining>off <install-dependencies>off <link>shared
<main-target-type>OBJ <optimization>off <os>NT <profiling>off <rtti>on
<runner-quiet>yes <runner-runOnTarget>yes <runtime-debugging>on
<runtime-link>shared <stdlib>native <symlink-location>project-relative
<threading>single <toolset>vxworks <user-interface>console <variant>debug
              find-viable-generators target-type= LST property-set=
vxworks/debug
              trying type LST
              there are generators for this type
              trying generator vxworks.lst ( OBJ STATIC_LIB -> LST )
                is viable
              *** 1 viable generators
                generator vxworks.lst
                multiple:
                composing: true
                  *** construct OBJ
                      from { ../src/BSysListenerMock.cpp.CPP }
                      properties: <asynch-exceptions>off
<cxxflags>-Wno-deprecated <cxxflags>-fexceptions <debug-symbols>on
<exception-handling>off <extern-c-nothrow>off <hardcode-dll-paths>true
<include>../.. <inlining>off <install-dependencies>off <link>shared
<main-target-type>OBJ <optimization>off <os>NT <profiling>off <rtti>on
<runner-quiet>yes <runner-runOnTarget>yes <runtime-debugging>on
<runtime-link>shared <stdlib>native <symlink-location>project-relative
<threading>single <toolset>vxworks <user-interface>console <variant>debug
                  *** 1 viable generators
                    generator vxworks.compile.c++
                    multiple:
                    composing:
                  alt1
                    SUCCESS: {
vxworks%vxworks.compile.c++-BSysListenerMock.obj.OBJ {
../src/BSysListenerMock.cpp.CPP } }

                    generator vxworks.compile.c++ spawned
                    {
vxworks%vxworks.compile.c++-BSysListenerMock.obj.OBJ {
../src/BSysListenerMock.cpp.CPP } }
                  *** construct STATIC_LIB
                      from { ../src/BSysListenerMock.cpp.CPP }
                      properties: <asynch-exceptions>off
<cxxflags>-Wno-deprecated <cxxflags>-fexceptions <debug-symbols>on
<exception-handling>off <extern-c-nothrow>off <hardcode-dll-paths>true
<include>../.. <inlining>off <install-dependencies>off <link>shared
<main-target-type>OBJ <optimization>off <os>NT <profiling>off <rtti>on
<runner-quiet>yes <runner-runOnTarget>yes <runtime-debugging>on
<runtime-link>shared <stdlib>native <symlink-location>project-relative
<threading>single <toolset>vxworks <user-interface>console <variant>debug
                  find-viable-generators target-type= STATIC_LIB
property-set= vxworks/debug
                  trying type STATIC_LIB
                  there are generators for this type
                  trying generator unix.archive ( OBJ -> STATIC_LIB )
                  trying generator gcc.archive ( OBJ -> STATIC_LIB )
                  trying generator mingw.archive ( OBJ -> STATIC_LIB )
                  trying generator vxworks.archive ( OBJ -> STATIC_LIB )
                    is viable
                  *** 1 viable generators
                    generator vxworks.archive
                    multiple:
                    composing: true
                    generator vxworks.archive spawned

              alt2 : consumed is {
vxworks%vxworks.compile.c++-BSysListenerMock.obj.OBJ {
../src/BSysListenerMock.cpp.CPP } }
                SUCCESS: { vxworks%vxworks.lst-BSysListenerMock.lst.LST
{ vxworks%vxworks.compile.c++-BSysListenerMock.obj.OBJ {
../src/BSysListenerMock.cpp.CPP } } }

                generator vxworks.lst spawned
                { vxworks%vxworks.lst-BSysListenerMock.lst.LST {
vxworks%vxworks.compile.c++-BSysListenerMock.obj.OBJ {
../src/BSysListenerMock.cpp.CPP } } }
          alt1
            SUCCESS: { vxworks%vxworks.munch-BSysListenerMock.c.C {
vxworks%vxworks.lst-BSysListenerMock.lst.LST {
vxworks%vxworks.compile.c++-BSysListenerMock.obj.OBJ {
../src/BSysListenerMock.cpp.CPP } } } }

            generator vxworks.munch spawned
            { vxworks%vxworks.munch-BSysListenerMock.c.C {
vxworks%vxworks.lst-BSysListenerMock.lst.LST {
vxworks%vxworks.compile.c++-BSysListenerMock.obj.OBJ {
../src/BSysListenerMock.cpp.CPP } } } }
      alt1
        SUCCESS: { vxworks%vxworks.compile.c-BSysListenerMock.obj.OBJ {
vxworks%vxworks.munch-BSysListenerMock.c.C {
vxworks%vxworks.lst-BSysListenerMock.lst.LST {
vxworks%vxworks.compile.c++-BSysListenerMock.obj.OBJ {
../src/BSysListenerMock.cpp.CPP } } } } }

        generator vxworks.compile.c spawned
        { vxworks%vxworks.compile.c-BSysListenerMock.obj.OBJ {
vxworks%vxworks.munch-BSysListenerMock.c.C {
vxworks%vxworks.lst-BSysListenerMock.lst.LST {
vxworks%vxworks.compile.c++-BSysListenerMock.obj.OBJ {
../src/BSysListenerMock.cpp.CPP } } } } }
H:/xrun/bb/make/2_0_x/work/v2/build\generators.jam:1087: in
construct-really from module generators
error: Ambiguity found when searching for best transformation
H:/xrun/bb/make/2_0_x/work/v2/build\generators.jam:1140: in
generators.construct from module generators
H:/xrun/bb/make/2_0_x/work/v2/build\targets.jam:1245: in construct from
module object(typed-target)@1
H:/xrun/bb/make/2_0_x/work/v2/build\targets.jam:1131: in
object(typed-target)@1.generate from module object(typed-target)@1
H:/xrun/bb/make/2_0_x/work/v2/build\targets.jam:760: in generate-really
from module object(main-target)@1
H:/xrun/bb/make/2_0_x/work/v2/build\targets.jam:730: in
object(main-target)@1.generate from module object(main-target)@1
H:/xrun/bb/make/2_0_x/work/v2/build\targets.jam:252: in
object(project-target)@4.generate from module object(project-target)@4
H:/xrun/bb/make/2_0_x/work/v2\build-system.jam:267: in load from module
build-system
H:\xrun\bb\make\2_0_x\work\v2/kernel\modules.jam:259: in import from
module modules
H:\xrun\bb\make\2_0_x\work\v2/kernel/bootstrap.jam:153: in boost-build
from module
D:\gekko\nm\projects\xrun\bb\make\2_0_x\work\spikes\code\boost-build.jam:2:
in module scope from module


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