Boost logo

Boost-Build :

Subject: [Boost-build] Project using Boost Build : am I doing things right ?
From: yabo (yabo_at_[hidden])
Date: 2009-02-19 09:03:21


Hello,

I'm new to Boost.Build and after reading the documentation and
experimenting with simple examples I'm willing to use it in a real
project. I've managed to deploy a Boost.Build build system but was
wondering myself if I was doing things right.

Here is the project tree :

top/
  |
  +-- configure
  |
  +-- user-config.jam
  |
  +-- Jamroot
  |
  +-- network/
  | |
  | +-- Jamfile
  | `-- network.cpp
  | `-- network.hpp
  |
  `-- core/
       |
       +-- Jamfile
       `-- core.cpp

The idea is that core is the main function and network a network class
using Boost.Asio that is to be used by the core function.

The configure script generates the user-config.jam file with
informations on various library locations (boost and pthread for now).

Then the Jamroot file builds the core module which depends on network.
Therefore network is built as a static library which is linked with
core. I need network to be a library because it will be reused in other
projects.

As I said, I've managed to get everything working but I find the way I
did it a bit crappy (may be I'm just not used to Boost.Build yet).
Espcially the way I did the user-config.jam file, however I didn't find
any other method.

Thanks in advance !

Here are the jam files :

------------[ Jamroot ]-------------------------------------------------
local BOOST_INCLUDE_PATH = [ get_boost_include_path ] ;
local BOOST_LIBRARY_PATH = [ get_boost_library_path ] ;
local PTHREAD_INCLUDE_PATH = [ get_pthread_include_path ] ;
local PTHREAD_LIBRARY_PATH = [ get_pthread_library_path ] ;

project
  : requirements <include>$(BOOST_INCLUDE_PATH)
  : requirements <library>$(BOOST_LIBRARY_PATH)/libboost_system.a
  : requirements <include>$(PTHREAD_INCLUDE_PATH)
  : requirements <library>$(PTHREAD_LIBRARY_PATH)/pthread.a
  ;

use-project /network : network ;

build-project core ;
------------[ /Jamroot ]------------------------------------------------

------------[ user-config.jam ]-----------------------------------------
rule get_boost_include_path ( )
{
  return $(BOOST_INCLUDE_PATH) ;
}

rule get_boost_library_path ( )
{
  return $(BOOST_LIBRARY_PATH) ;
}

rule get_pthread_include_path ( )
{
  return $(PTHREAD_INCLUDE_PATH) ;
}

rule get_pthread_library_path ( )
{
  return $(PTHREAD_LIBRARY_PATH) ;
}

# Generated by the configure script
BOOST_INCLUDE_PATH = "/usr/include/boost" ;
BOOST_LIBRARY_PATH = "/usr/lib/boost" ;
PTHREAD_INCLUDE_PATH = "/usr/include" ;
PTHREAD_LIBRARY_PATH = "/usr/lib" ;
using gcc ;
------------[ user-config.jam ]-----------------------------------------

------------[ core/Jamfile ]--------------------------------------------
exe server
  : core.cpp /network
  ;
------------[ /core/Jamfile ]-------------------------------------------

------------[ network/Jamfile ]-----------------------------------------
project network
  : usage-requirements <include>.
  ;

lib network
  : network.cpp network.hpp
  : <link>static
  ;

------------[ /network/Jamfile ]----------------------------------------


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