[Boost-users] [Boost-user] bjam and env var

44 views
Skip to first unread message

Jérémie Fouché

unread,
Sep 30, 2008, 3:39:52 AM9/30/08
to boost...@lists.boost.org
Hi everybody

I'm creating python modules with boost, and I'm using bjam to compile them (because, as written in the doc, it is the easiest way to compile python module created with boost.python). Actually, my jam script is specific to my directory structure.

If I want to change my directory structure, or shared my project with someone who haven't the same directory structure (which is always the case), my jam files need to be changed.

My jam files are at the end of this post.

I tried to use environment variables without success. If I create a BOOST_ROOT env var, I can't use it in my JamRoot file, because $(BOOST_DIR) is always empty.
I also tried to create a var in my user-config.jam, but the var isn't visible in my JamRoot file.

So, here are my questions :
1 - Is there a good way to do this ?
2 - I didn't find exactly what is boost-build.jam for, have you an explanation ?

Thanks

boost-build.jam :
boost-build /_Perso/projets/lib/boost_1_36_0/tools/build/v2 ;

JamRoot :
wx = /_Perso/projets/lib/wxWidgets2.8 ;

# Specify the path to the Boost project.  If you move this project,
# adjust this path to refer to the Boost root directory.
use-project boost
  : ../../../../lib/boost_1_36_0 ;

# Set up the project-wide requirements that everything uses the
# boost_python library from the project whose global ID is /boost/python.
project
  : requirements <library>/boost/python//boost_python ;

# Declare the extension module.
python-extension gui
  : gui.cpp
  : <include>$(wx)/include
    <include>$(wx)/lib/gcc_dll/mswu
    <define>__GNUWIN32__
    <define>__WXMSW__
    <define>WXUSINGDLL
    <define>wxUSE_UNICODE
    <library-file>$(wx)/lib/gcc_dll/libwxmsw28u.a
  ;


-- 
Jérémie


Vladimir Prus

unread,
Sep 30, 2008, 6:50:36 AM9/30/08
to boost...@lists.boost.org
Jérémie Fouché wrote:

> Hi everybody
>
> I'm creating python modules with boost, and I'm using bjam to compile them
> (because, as written in the doc, it is the easiest way to compile python
> module created with boost.python). Actually, my jam script is specific to my
> directory structure.
>
> If I want to change my directory structure, or shared my project with
> someone who haven't the same directory structure (which is always the case),
> my jam files need to be changed.
>
> My jam files are at the end of this post.
>
> I tried to use environment variables without success. If I create a
> BOOST_ROOT env var, I can't use it in my JamRoot file, because $(BOOST_DIR)
> is always empty.

Did you check Boost.Build documentation? See:

http://www.boost.org/boost-build2/doc/html/bbv2/faq/envar.html

- Volodya


_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Gennadiy Rozental

unread,
Sep 30, 2008, 9:31:21 AM9/30/08
to boost...@lists.boost.org
> http://www.boost.org/boost-build2/doc/html/bbv2/faq/envar.html
>
> - Volodya

How about complete 3rd party setup? What If I need to specify include path
library path, libraries to link with list and set of defines?

Gennadiy

Vladimir Prus

unread,
Oct 3, 2008, 2:36:40 AM10/3/08
to boost...@lists.boost.org
Gennadiy Rozental wrote:

>> http://www.boost.org/boost-build2/doc/html/bbv2/faq/envar.html
>>
>> - Volodya
>
> How about complete 3rd party setup? What If I need to specify include path
> library path, libraries to link with list and set of defines?

You'd need 4 environment variables and a lib target in our project that will
use those variables to define things. Alternatively, you can declare a library
target in user-config.jam, something like this:


project user-config ;

lib third_party
: # sources
: # requirements
<name>third_party <search>some-library-path
: # default build
: # usage requirements
<include>some-include-path <define>some-define
;

and you can refer to this from your project using

/user-config//third_party

notation. More complex, but unlimately best approach is creating
file third_party.jam, with the following content:

project.initialize $(__name__) ;
project third_party ;

rule init ( name : library-path : include-path : defines * )
{
lib third_party
: # sources
: # requirements
<name>$(name) <search>$(library-path)
: # default build
: # usage requirements
<include>$(include-path) <define>$(defines)
;
}

and add

using third_party : .... ;

to user-config.jam and refer to this library as

/third_party//third_party

The last approach is better because the 'init' rule can do smart things --
like adding some defines automatically, or accepting just 'install root'
and computing library paths and includes paths from that, etc.

Does this answer your question?

- Volodya

Jérémie Fouché

unread,
Oct 3, 2008, 9:05:59 AM10/3/08
to boost...@lists.boost.org
2008/10/3 Vladimir Prus <vlad...@codesourcery.com>
Gennadiy Rozental wrote:

>>         http://www.boost.org/boost-build2/doc/html/bbv2/faq/envar.html
>>
>> - Volodya
>
> How about complete 3rd party setup? What If I need to specify include path
> library path, libraries to link with list and set of defines?

...

Does this answer your question?

Sure it does, thanks a lot.
--
Jérémie Fouché

Sebastian Hauer

unread,
Oct 3, 2008, 10:49:31 AM10/3/08
to boost...@lists.boost.org, Boost.Build developer's and user's list
Hello Vladimir,

On Fri, Oct 3, 2008 at 2:36 AM, Vladimir Prus <vlad...@codesourcery.com> wrote:
> notation. More complex, but unlimately best approach is creating
> file third_party.jam, with the following content:
> project.initialize $(__name__) ;
> project third_party ;
> rule init ( name : library-path : include-path : defines * )
> {
> lib third_party
> : # sources
> : # requirements
> <name>$(name) <search>$(library-path)
> : # default build
> : # usage requirements
> <include>$(include-path) <define>$(defines)
> ;
> }
> and add
> using third_party : .... ;

Thanks for the example on how to initialize standalone 3rd party
projects. Base on the comments in project.jam I eventually figured
out how to do it myself although slightly less elegant and without
'using'.
I'm just wondering is there somewhere a cookbook style set of examples
of how various things can be done using boost build (something beyond
the included examples with boost build that is). I really like boost
build, it solves a lot of problems for me out of the box which I
previously had with other make replacements but the documentation is
sometimes a bit brief.
Also is there somewhere a document which gives an overview of some of
the design ideas behind boost build?

Thanks,
Sebastian

Gennadiy Rozental

unread,
Oct 3, 2008, 12:01:40 PM10/3/08
to boost...@lists.boost.org
Vladimir Prus <vladimir <at> codesourcery.com> writes:

> > How about complete 3rd party setup? What If I need to specify include path
> > library path, libraries to link with list and set of defines?
>
> You'd need 4 environment variables and a lib target in our project that will
> use those variables to define things.

I've got only one "unknown" - env var 3RD_PARTY_LIB_HOME. The rest is deducible.
The list of libs to link with and list of defines I know.

> Alternatively, you can declare a library
> target in user-config.jam, something like this:

I don't think user-config is an option here. I need to setup my Jamfile so that
user only need to set 1 env var for it to work.



> project user-config ;
>
> lib third_party
> : # sources
> : # requirements
> <name>third_party <search>some-library-path
> : # default build
> : # usage requirements
> <include>some-include-path <define>some-define
> ;

How do I list all the libraries to link with? Some static some dynamic.



> and you can refer to this from your project using
>
> /user-config//third_party
>
> notation. More complex, but unlimately best approach is creating
> file third_party.jam, with the following content:

Can I put this file along with my own Jamfile? How will I refer to it?

[...]

> The last approach is better because the 'init' rule can do smart things --
> like adding some defines automatically, or accepting just 'install root'
> and computing library paths and includes paths from that, etc.

Why Can't I do a deduction in regular lib rule? in most cases it's just simple
$(HOME)/include and $(HOME)/lib

Gennadiy

Vladimir Prus

unread,
Oct 3, 2008, 12:07:27 PM10/3/08
to boost...@lists.boost.org, boost...@lists.boost.org
Sebastian Hauer wrote:

There was something on boost wiki, but I'm not sure it has much. At this
point, things like above can probably go into main documentation.

> Also is there somewhere a document which gives an overview of some of
> the design ideas behind boost build?

(Re)writing overview section of the doc is on my todo list, very close to the
top -- it seems like documentation starts to become the most critical part
of boost.build.

- Volodya

Reply all
Reply to author
Forward
0 new messages