Boost logo

Boost-Build :

From: Roland Schwarz (roland.schwarz_at_[hidden])
Date: 2007-07-25 11:49:43


Vladimir Prus wrote:
> I wanted to quickly reply, so that you don't think your
> contribution is ignored.

:-)

> I've some personal matters at hand right now, so I won't
> be able to look into this in detail today. However, I hope
> to reply by Thursday; if I fail, feel free to ping me here,
> on on IRC.

Ok.

In the meantime I managed to arrive at a functional stub Jamroot
as you can see in the attachement. I also made some preliminary
sucessful tests on linux and windows.

If you like it I would be glad to contribute it to Boost.Build.
If for nothing else it could go to the examples directory.

I will try to contact you tomorrow, as I ran across a couple of
questions that while not directly related to the issue might have
an impact on the installation in general.

Regards
Roland


# Copyright 2007 Roland Schwarz
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

import property-set ;
import type ;
import generators ;
import "class" : new ;

type.register EXTERNAL_LIB : : SEARCHED_LIB ;

# The following is needed to suppress the pre and suffix,
# since these are usually not allowed on searched libs.
# I am not sure if these better go into tools/types
type.set-generated-target-prefix SEARCHED_LIB : : "" ;
type.set-generated-target-suffix SEARCHED_LIB : : "" ;

class external-lib-generator : searched-lib-generator
{
        import indirect ;
        import set ;
        import property-set ;

        rule __init__ ( )
        {
                # bypassing the base class init is questionable, but it seems to work ...
                generator.__init__ external-lib-generator : : EXTERNAL_LIB ;
        }

        rule run ( project name ? : property-set : sources * : multiple ? )
        {
                local real-name = [ $(property-set).get <name> ] ;
                local props = [ set.difference [ $(property-set).raw ] : <name>$(real-name) ] ;
                if $(real-name)-not-empty
                {
                        local rule-name = [ MATCH ^@(.*) : $(real-name) ] ;
                        if $(rule-name)
                        {
                                real-name = [ indirect.call $(rule-name) $(name) : SEARCHED_LIB : $(property-set) ] ;
                        }
                }

                return [ searched-lib-generator.run
                                    $(project) $(name)
                                : [ property-set.create $(props) <name>$(real-name) ]
                                : $(sources)
                                : $(multiple)
                        ] ;
        }
}

generators.register [ new external-lib-generator ] ;


# Copyright 2007 Roland Schwarz
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

# This is a stub projectfile that can act in lieu of the boost project root.
# It allows to use the boost pre-built libraries as if the boost source tree
# was present. It handles the issue of library tagging in a platform independent
# manner.
# To make use of it you have to copy it as file Jamroot to a convenient place,
# e.g. to dierctory vendor/boost under your project root, or to a system wide
# directory. The file external.jam must be loadable by means of the import
# rule. This can be achieved e.g. by copying it also to vendor/boost.
# Example usage:
#
# use-project boost : vendor/boost ;
# project myproject ;
# exe hello : hello.cpp /boost//boost_program_options ;
#
# You can also use it to refer to header only libraries, altough this is not
# really required in this case:
#
# use-project boost : vendor/boost ;
# project myproject ;
# exe hello : hello.cpp /boost//boost_header_only ;
#
# The advantage in the latter case is, that you can simply switch between
# different installed versions of the library by adjusting the parameters
# in vendor/boost/Jamroot file.

import external ;
import property-set ;
import common ;
import os ;

####################################################################################
# The following items must match the libraries generated by the build system
# install rules
# You can also use this stub boost project file by simply adjusting the below
# variables to your environment.

layout = ;
local build-id = ;
constant BOOST_VERSION : 1.34.0 ;

library-search-path = ;
include-search-path = ;

####################################################################################
# This is the part that could (must) be shared between the source tree and
# this pre-built lib project Jamroot file.
# If the tagging algorithm of the boost library is not changed, this part need
# not to be touched.

layout ?= versioned ;
layout-$(layout) = true ;

local version-tag = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(BOOST_VERSION) ] ;
if $(version-tag[3]) = 0
{
    version-tag = $(version-tag[1-2]) ;
}

constant BOOST_VERSION_TAG : $(version-tag:J="_") ;

if $(build-id)
{
    constant BUILD_ID : [ regex.replace $(build-id) "[*\\/:.\"\' ]" "_" ] ;
}

rule tag ( name : type ? : property-set )
{
    # the SEARCHED_LIB is necessary but not yet present in the original
    if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB SEARCHED_LIB
    {
        if $(type) = SEARCHED_LIB &&
            ( [ $(property-set).get <link> ] in static ) &&
            ( [ $(property-set).get <target-os> ] in windows )
        {
                name = lib$(name) ;
        }
        if $(layout) = versioned
        {
            local result = [ common.format-name
                <base> <toolset> <threading> <runtime> -$(BOOST_VERSION_TAG)
                -$(BUILD_ID)
                : $(name) : $(type) : $(property-set) ] ;
            
            # Optionally add version suffix.
            # On NT, library with version suffix won't be recognized
            # by linkers. On CYGWIN, we get strage duplicate symbol
            # errors when library is generated with version suffix.
            # On OSX, version suffix is not needed -- the linker expets
            # libFoo.1.2.3.dylib format.
            # AIX linkers don't accept version suffixes either.
            if $(type) = SHARED_LIB &&
              ! ( [ $(property-set).get <target-os> ] in windows cygwin darwin aix )
            {
                result = $(result).$(BOOST_VERSION) ;
            }
            
            return $(result) ;
        }
        else
        {
            return [ common.format-name
                <base> <threading> <runtime> -$(BUILD_ID)
                : $(name) : $(type) : $(property-set) ] ;
        }
    }
}
####################################################################################
# Try to find some default values on windows
if [ os.on-windows ]
{
    if $(layout) = versioned
    {
        include-search-path ?= "C:/Boost/include/boost-$(BOOST_VERSION_TAG)" ;
    }
    else
    {
        include-search-path ?= "C:Boost/include" ;
    }
    library-search-path ?= "C:/Boost/lib" ;
}

# The <name> has been extended by allowing a rule.
# The external-lib targets are derivatives of SEARCHED_LIB type
# so they are recognized by the linking target.
# In my opinion instead of using my external.jam, an even better
# solution would be to extend the searched-lib-target to allow
# for the <name>@tagrule feature.

project boost
    : usage-requirements <include>$(include-search-path)
    : requirements <name>@tag <search>$(library-search-path)
    ;

alias boost_header_only ;

####################################################################################
# The below list needs to be extended for every new library that needs building.
# I.e. bjam --show-libraries

external-lib boost_program_options ;
external-lib boost_thread ;
external-lib boost_iostreams ;
external-lib boost_wave ;
external-lib boost_python ;
external-lib boost_serialization ;
external-lib boost_graph ;
external-lib boost_date_time ;
external-lib boost_test ;
external-lib boost_regex ;
external-lib boost_filesystem ;
external-lib boost_signals ;


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