Boost logo

Boost-Build :

Subject: [Boost-build] shared (prebuilt) libraries question
From: George Georgiev (george.georgiev.sf_at_[hidden])
Date: 2012-03-17 14:59:16


Hi,

I am relatively new to the Boost Build.

I have a prebuilt library that I need to link against in my projects.

To accomplish this I created a rule that defines the library. Then in
the beginning of every jamfile where this library will be used I call
this rule.

There are several things that concerns me and I hope you guys will
give me ideas how to do this better.

1. Is it possible I to avoid the need of calling the rule for every
project. Somehow to define the library in the root and it to become
visible for every project.
2. With adding more and more platforms to the project the rule becomes
uglier and uglier. There is a lot of repeating requirements, see
following the rule:

rule xercesDefines
{
   if NT
   {
       lib advapi32
         :
         : <name>advapi32
         ;
   }

   lib prebuilt_xerces
     :
     : <toolset>msvc <version>10.0 <variant>debug <address-model>32
           <file>$(ROOT)/xerces/lib/ntx86/vs10/dyng/xerces-c_static_3D.lib
     :
     :
       <include>$(ROOT)/xerces/include
       <library>advapi32
       <define>XERCES_STATIC_LIBRARY
     ;

   lib prebuilt_xerces
     :
     : <toolset>msvc <version>10.0 <variant>release <address-model>32
           <file>$(ROOT)/xerces/lib/ntx86/vs10/dyn/xerces-c_static_3.lib
     :
     :
       <include>$(ROOT)/xerces/include
       <library>advapi32
       <define>XERCES_STATIC_LIBRARY
     ;

   lib prebuilt_xerces
     :
     : <toolset>msvc <version>10.0 <variant>debug <address-model>64
           <file>$(ROOT)/xerces/lib/ntx64/vs10/dyng/xerces-c_static_3D.lib
     :
     :
       <include>$(ROOT)/xerces/include
       <library>advapi32
       <define>XERCES_STATIC_LIBRARY
     ;

   lib prebuilt_xerces
     :
     : <toolset>msvc <version>10.0 <variant>release <address-model>64
           <file>$(ROOT)/xerces/lib/ntx64/vs10/dyn/xerces-c_static_3.lib
     :
     :
       <include>$(ROOT)/xerces/include
       <library>advapi32
       <define>XERCES_STATIC_LIBRARY
     ;

   if MACOSX
   {
       lib curl
         :
         : <name>curl
         ;
   }

   lib prebuilt_xerces
     :
     : <toolset>darwin <variant>debug <address-model>64
           <file>$(ROOT)/xerces/lib/macosxx86_64/sdk10.5/dyng/libxerces-c.a
     :
     :
       <include>$(ROOT)/xerces/include
       <framework>CoreServices
       <library>curl
       <define>XERCES_STATIC_LIBRARY
       <cxxflags>-fvisibility-inlines-hidden
       <cflags>-mmacosx-version-min=10.5
     ;

   lib prebuilt_xerces
     :
     : <toolset>darwin <variant>release <address-model>64
           <file>$(ROOT)/xerces/lib/macosxx86_64/sdk10.5/dyn/libxerces-c.a
     :
     :
       <include>$(ROOT)/xerces/include
       <framework>CoreServices
       <library>curl
       <define>XERCES_STATIC_LIBRARY
       <cxxflags>-fvisibility-inlines-hidden
       <cflags>-mmacosx-version-min=10.5
     ;

   lib prebuilt_xerces
     :
     : <toolset>gcc <variant>debug <address-model>64
           <file>$(ROOT)/xerces/lib/linuxx86_64/gcc44libc211/dyng/libxerces-c.a
     :
     :
       <include>$(ROOT)/xerces/include
       <define>XERCES_STATIC_LIBRARY
     ;

   lib prebuilt_xerces
     :
     : <toolset>gcc <variant>release <address-model>64
           <file>$(ROOT)/xerces/lib/linuxx86_64/gcc44libc211/dyn/libxerces-c.a
     :
     :
       <include>$(ROOT)/xerces/include
       <define>XERCES_STATIC_LIBRARY
     ;

}

I wish there is a way I to be able to structure this:

rule xercesDefines
{
   lib prebuilt_xerces
    # for all
       <include>$(ROOT)/xerces/include
        <define>XERCES_STATIC_LIBRARY
     ;

   if NT
   {
       lib advapi32
         :
         : <name>advapi32
         ;
   }

   lib prebuilt_xerces
     :
     : # for <toolset>msvc
     :
     :
       <library>advapi32
     ;

   if MACOSX
   {
       lib curl
         :
         : <name>curl
         ;
   }

   lib prebuilt_xerces
     :
     : # for <toolset>darwin
     :
     :
       <framework>CoreServices
       <library>curl
       <cxxflags>-fvisibility-inlines-hidden
       <cflags>-mmacosx-version-min=10.5
     ;

   lib prebuilt_xerces
     :
     : <toolset>msvc <version>10.0 <variant>debug <address-model>32
           <file>$(ROOT)/xerces/lib/ntx86/vs10/dyng/xerces-c_static_3D.lib
     ;

   lib prebuilt_xerces
     :
     : <toolset>msvc <version>10.0 <variant>release <address-model>32
           <file>$(ROOT)/xerces/lib/ntx86/vs10/dyn/xerces-c_static_3.lib
     ;

   lib prebuilt_xerces
     :
     : <toolset>msvc <version>10.0 <variant>debug <address-model>64
           <file>$(ROOT)/xerces/lib/ntx64/vs10/dyng/xerces-c_static_3D.lib
     ;

   lib prebuilt_xerces
     :
     : <toolset>msvc <version>10.0 <variant>release <address-model>64
           <file>$(ROOT)/xerces/lib/ntx64/vs10/dyn/xerces-c_static_3.lib
     ;

   lib prebuilt_xerces
     :
     : <toolset>darwin <variant>debug <address-model>64
           <file>$(ROOT)/xerces/lib/macosxx86_64/sdk10.5/dyng/libxerces-c.a
     ;

   lib prebuilt_xerces
     :
     : <toolset>darwin <variant>release <address-model>64
           <file>$(ROOT)/xerces/lib/macosxx86_64/sdk10.5/dyn/libxerces-c.a
     ;

   lib prebuilt_xerces
     :
     : <toolset>gcc <variant>debug <address-model>64
           <file>$(ROOT)/xerces/lib/linuxx86_64/gcc44libc211/dyng/libxerces-c.a
     ;

   lib prebuilt_xerces
     :
     : <toolset>gcc <variant>release <address-model>64
           <file>$(ROOT)/xerces/lib/linuxx86_64/gcc44libc211/dyn/libxerces-c.a
     ;

}

3. How I can avoid listing all combination per every prebuilt library.
For example lib/linuxx86_64/gcc44libc211/dyn this part of the path is
going to be the same for all prebuilt libraries. I wish there was a
way I to say:

   lib prebuilt_xerces
     :
     : <file>$(ROOT)/xerces/$(libsubdirectory)/libxerces-c.a
     ;

And libsubdirectory to be different based on the toolset, version,
variant, address-model etc.

Suggestions?

Thank you,
George


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