Skip to content

Commit f6d20e1

Browse files
grafikrobotstefanseefeld
authored andcommitted
Make the library modular usable.
1 parent 99a5352 commit f6d20e1

File tree

4 files changed

+76
-37
lines changed

4 files changed

+76
-37
lines changed

build.jam

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright René Ferdinand Rivera Morell 2024
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
import project ;
7+
8+
project /boost/python
9+
: common-requirements
10+
<source>/boost/align//boost_align
11+
<source>/boost/bind//boost_bind
12+
<source>/boost/config//boost_config
13+
<source>/boost/conversion//boost_conversion
14+
<source>/boost/core//boost_core
15+
<source>/boost/detail//boost_detail
16+
<source>/boost/foreach//boost_foreach
17+
<source>/boost/function//boost_function
18+
<source>/boost/graph//boost_graph
19+
<source>/boost/integer//boost_integer
20+
<source>/boost/iterator//boost_iterator
21+
<source>/boost/lexical_cast//boost_lexical_cast
22+
<source>/boost/mpl//boost_mpl
23+
<source>/boost/numeric_conversion//boost_numeric_conversion
24+
<source>/boost/preprocessor//boost_preprocessor
25+
<source>/boost/property_map//boost_property_map
26+
<source>/boost/smart_ptr//boost_smart_ptr
27+
<source>/boost/static_assert//boost_static_assert
28+
<source>/boost/tuple//boost_tuple
29+
<source>/boost/type_traits//boost_type_traits
30+
<source>/boost/utility//boost_utility
31+
<include>include
32+
;
33+
34+
explicit
35+
[ alias boost_python : build//boost_python ]
36+
[ alias boost_numpy : build//boost_numpy ]
37+
[ alias all : boost_python boost_numpy test ]
38+
;
39+
40+
call-if : boost-library python
41+
: install boost_python boost_numpy
42+
;

build/Jamfile

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,25 @@ else
3030
;
3131
}
3232

33-
project boost/python
33+
project
3434
: source-location ../src
3535
;
3636

3737
rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } }
3838
rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } }
3939
local rule eq ( a : b ) { if $(a) = $(b) { return 1 ; } }
4040

41+
rule tag ( name : type ? : property-set )
42+
{
43+
if python-tag in [ RULENAMES $(__name__) ]
44+
{
45+
return [ $(__name__).python-tag $(name) : $(type) : $(property-set) ] ;
46+
}
47+
}
48+
49+
if [ python.configured ]
50+
{
51+
4152
lib boost_python
4253
: # sources
4354
list.cpp
@@ -92,8 +103,8 @@ lib boost_python
92103
[ unless [ python.configured ] : <build>no ]
93104
<dependency>config-warning
94105
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
95-
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
96-
<tag>@python-tag
106+
-<tag>@%boostcpp.tag
107+
<tag>@tag
97108
<conditional>@python.require-py
98109

99110
: # default build
@@ -103,6 +114,17 @@ lib boost_python
103114
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
104115
;
105116

117+
}
118+
else
119+
{
120+
121+
alias boost_python : config-warning ;
122+
123+
}
124+
125+
if [ python.configured ] && [ python.numpy ]
126+
{
127+
106128
numpy-include = [ python.numpy-include ] ;
107129
lib boost_numpy
108130
: # sources
@@ -120,8 +142,8 @@ lib boost_numpy
120142
<library>/python//numpy
121143
<library>boost_python
122144
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
123-
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
124-
<tag>@python-tag
145+
-<tag>@%boostcpp.tag
146+
<tag>@tag
125147
<conditional>@python.require-py
126148

127149
: # default build
@@ -131,37 +153,10 @@ lib boost_numpy
131153
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
132154
;
133155

134-
# boost-install creates `stage` and `install` targets
135-
#
136-
# `stage` stages (builds and copies into `stage/lib`) the given libraries
137-
# `boost_python` and `boost_numpy` and their dependencies and is similar
138-
# to issuing `b2 --with-python stage` from top level
139-
#
140-
# `install` installs the two libraries and their dependencies and is similar
141-
# to issuing `b2 --with-python install` from top level
142-
143-
if [ python.configured ]
144-
{
145-
if [ python.numpy ]
146-
{
147-
boost-install boost_python boost_numpy ;
148-
}
149-
else
150-
{
151-
boost-install boost_python ;
152-
}
153156
}
154157
else
155158
{
156159

157-
# When Python isn't configured, the above `boost-install` is not executed,
158-
# so we create empty `stage` and `install` targets that do nothing but issue
159-
# a warning message unless `--without-python` is given
160-
161-
alias stage : config-warning ;
162-
explicit stage ;
163-
164-
alias install : config-warning ;
165-
explicit install ;
160+
alias boost_numpy : config-warning ;
166161

167162
}

example/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Examples
44

55
This directory contains various examples using Boost.Python.
6-
You may compile these using the `bjam` command either in this directory
6+
You may compile these using the `b2` command either in this directory
77
or in any of the subdirectories.
88
You may need to adjust the paths in the Jamroot file if Boost.Python
99
is not installed in a default location.

test/Jamfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
# Software License, Version 1.0. (See accompanying
33
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
44

5+
require-b2 5.0.1 ;
6+
import-search /boost/config/checks ;
7+
58
import python ;
69
import os ;
7-
import ../../config/checks/config : requires ;
10+
import config : requires ;
811

912
lib socket ;
1013

11-
use-project /boost/python : ../build ;
12-
project /boost/python/test
14+
project
1315
: requirements
1416
<toolset>gcc:<cxxflags>-Wextra
1517
<target-os>qnxnto:<library>socket

0 commit comments

Comments
 (0)