Skip to content

Commit 8c170d9

Browse files
committed
Fix building of multiple BPL libs even when the configured python does
not match.
1 parent 0224f54 commit 8c170d9

1 file changed

Lines changed: 37 additions & 41 deletions

File tree

build/Jamfile

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import os ;
66
import indirect ;
77
import modules ;
88
import feature ;
9+
import property ;
910

1011
import python ;
1112

@@ -30,33 +31,23 @@ else
3031
;
3132
}
3233

33-
rule find-py3-version
34-
{
35-
local versions = [ feature.values python ] ;
36-
local py3ver ;
37-
for local v in $(versions)
38-
{
39-
if $(v) >= 3.0
40-
{
41-
py3ver = $(v) ;
42-
}
43-
}
44-
return $(py3ver) ;
45-
}
46-
47-
py3-version = [ find-py3-version ] ;
34+
py2-version = [ py-version 2 ] ;
35+
py3-version = [ py-version 3 ] ;
4836

4937
project boost/python
5038
: source-location ../src
5139
;
5240

5341
rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } }
5442
rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } }
43+
local rule eq ( a : b ) { if $(a) = $(b) { return 1 ; } }
5544

56-
rule lib_boost_python ( is-py3 ? )
57-
{
45+
lib_boost_python($(py2-version)) = boost_python ;
46+
lib_boost_python($(py3-version)) = boost_python3 ;
5847

59-
lib [ cond $(is-py3) : boost_python3 : boost_python ]
48+
rule lib_boost_python ( version )
49+
{
50+
lib $(lib_boost_python($(version)))
6051
: # sources
6152
numeric.cpp
6253
list.cpp
@@ -112,11 +103,13 @@ rule lib_boost_python ( is-py3 ? )
112103
<dependency>config-warning
113104

114105
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
115-
[ cond $(is-py3) : <python>$(py3-version) ]
106+
<python>$(version)
116107

117108
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
118109
<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).python-tag
119110

111+
<conditional>@python.require-py
112+
120113
: # default build
121114
<link>shared
122115
: # usage requirements
@@ -125,51 +118,54 @@ rule lib_boost_python ( is-py3 ? )
125118
;
126119
}
127120

128-
rule lib_boost_numpy ( is-py3 ? )
121+
lib_boost_numpy($(py2-version)) = boost_numpy ;
122+
lib_boost_numpy($(py3-version)) = boost_numpy3 ;
123+
124+
rule lib_boost_numpy ( version )
129125
{
130126
numpy-include = [ python.numpy-include ] ;
131-
lib [ cond $(is-py3) : boost_numpy3 : boost_numpy ]
127+
lib $(lib_boost_numpy$(version))
132128
: # sources
133129
numpy/dtype.cpp
134130
numpy/matrix.cpp
135131
numpy/ndarray.cpp
136-
numpy/numpy.cpp
137-
numpy/scalars.cpp
138-
numpy/ufunc.cpp
132+
numpy/numpy.cpp
133+
numpy/scalars.cpp
134+
numpy/ufunc.cpp
139135
: # requirements
140136
[ cond [ python.numpy ] : <library>/python//python_for_extensions ]
141137
[ unless [ python.numpy ] : <build>no ]
142-
<include>$(numpy-include)
143-
[ cond $(is-py3) : <library>boost_python3 : <library>boost_python ]
138+
<include>$(numpy-include)
139+
<library>$(lib_boost_python($(version)))
144140
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
145-
[ cond $(is-py3) : <python>$(py3-version) ]
141+
<python>$(version)
146142

147143
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
148144
<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).python-tag
149145

146+
<conditional>@python.require-py
147+
150148
: # default build
151149
<link>shared
152150
: # usage requirements
153151
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
154152
;
155153
}
156154

157-
libraries = boost_python ;
158-
libraries3 = boost_python3 ;
159-
if [ python.numpy ]
160-
{
161-
libraries += boost_numpy ;
162-
libraries3 += boost_numpy3 ;
163-
}
164-
165-
lib_boost_python ;
166-
lib_boost_numpy ;
155+
libraries = ;
167156

168-
if $(py3-version)
157+
for local N in 2 3
169158
{
170-
lib_boost_python yes ;
171-
lib_boost_numpy yes ;
172-
libraries += $(libraries3) ;
159+
if $(py$(N)-version)
160+
{
161+
lib_boost_python $(py$(N)-version) ;
162+
libraries += $(lib_boost_python($(py$(N)-version))) ;
163+
if [ python.numpy ]
164+
{
165+
lib_boost_numpy $(py$(N)-version) ;
166+
libraries += $(lib_boost_numpy($(py$(N)-version))) ;
167+
}
168+
}
173169
}
174170

175171
boost-install $(libraries) ;

0 commit comments

Comments
 (0)