1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
|
import python ;
import feature ;
import feature : feature ;
import project ;
import targets ;
import "class" : new ;
import modules ;
use-project /torrent : ../.. ;
BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ;
CXXFLAGS = [ modules.peek : CXXFLAGS ] ;
LDFLAGS = [ modules.peek : LDFLAGS ] ;
ECHO "CXXFLAGS =" $(CXXFLAGS) ;
ECHO "LDFLAGS =" $(LDFLAGS) ;
# this is used to make bjam use the same version of python which is executing setup.py
feature libtorrent-link : shared static prebuilt : composite propagated ;
feature libtorrent-python-pic : off on : composite propagated link-incompatible ;
feature.compose <libtorrent-python-pic>on : <cxxflags>-fPIC ;
# when invoking the install_module target, this feature can be specified to
# install the python module to a specific directory
feature python-install-path : : free path ;
# when not specifying a custom install path, this controls whether to install
# the python module in the system directory or user-specific directory
feature python-install-scope : user system : ;
# copied from boost 1.63's boost python jamfile
rule find-py3-version
{
local BOOST_VERSION_TAG = [ modules.peek boostcpp : BOOST_VERSION_TAG ] ;
if $(BOOST_VERSION_TAG) >= 1_67
{
# starting with boost 1.67.0 boost python no longer define a separate
# target for python3 (boost_python3) so then we just use the regular
# boost_python target
return ;
}
local versions = [ feature.values python ] ;
local py3ver ;
for local v in $(versions)
{
if $(v) >= 3.0
{
py3ver = $(v) ;
}
}
return $(py3ver) ;
}
if $(BOOST_ROOT)
{
use-project /boost : $(BOOST_ROOT) ;
alias boost_python : /boost/python//boost_python : : : <include>$(BOOST_ROOT) ;
if [ find-py3-version ]
{
alias boost_python3 : /boost/python//boost_python3 : : : <include>$(BOOST_ROOT) ;
}
else
{
alias boost_python3 : boost_python ;
}
}
else
{
local boost-lib-search-path =
<search>/opt/local/lib
<search>/usr/lib
<search>/usr/local/lib
<search>/sw/lib
<search>/usr/g++/lib
;
local boost-include-path =
<include>/opt/local/include
<include>/opt/homebrew/include
<include>/usr/local/include
<include>/usr/sfw/include
;
import version ;
rule boost_python_version ( name : type ? : properties * )
{
# examples of names for the boost_python library:
# ubuntu bionic (1.65.1): libboost_python3-py36.so.1.65.1
# ubuntu bionic (1.65): libboost_python-py36.so
# libboost_python3-py36.so
# libboost_python3.so
# ubuntu bionic (1.62.0): libboost_python-py36.so.1.62.0
# ubuntu focal (1.67.0): libboost_python38.so.1.67.0
# ubuntu focal (1.71.0): libboost_python38.so
# ubuntu groovy (1.71.0): libboost_python38.so
# ubuntu hirsute(1.71.0): libboost_python39.so
# debian buster (1.67.0): libboost_python37.so
# libboost_python3.so
# libboost_python3-py37.so
# debian sid (1.74.0): libboost_python39.so
# debian sid (1.71.0): libboost_python39.so
# debian bullseye (1.71): libboost_python39.so
# devian buster-backports (1.71): libboost_python37.so
# debian buster (1.67): libboost_python37.so.1.67.0
# debian stretch (1.62.0): libboost_python-py35.so.1.62.0
# debian stretch (1.62): libboost_python-py35.so
# debian jessie (1.55.0): libboost_python-py34.so.1.55.0
# boost Jamfile: libboost_python38.so.1.73.0
local py-version-str = [ $(properties).get <python> ] ;
local py-version = "" ;
local infix = "" ;
if $(py-version-str) {
py-version = [ SPLIT_BY_CHARACTERS $(py-version-str) : "." ] ;
if [ version.version-less $(py-version) : 3 7 ] && [ $(properties).get <target-os> ] = linux
{
infix = "-py" ;
}
}
local boost-python-lib = "boost_python" $(infix) $(py-version) ;
if $(type) in SEARCHED_LIB
{
return $(boost-python-lib:J) ;
}
return ;
}
lib boost_python : : <tag>@boost_python_version : : $(boost-include-path) ;
alias boost_python3 : boost_python ;
}
lib prebuilt_libtorrent : : <name>torrent-rasterbar : : <include>../../include ;
lib prebuilt_libtorrent : : <target-os>windows <name>torrent : : <include>../../include ;
rule libtorrent_linking ( properties * )
{
local result ;
# allow larger .obj files (with more sections)
if <toolset>msvc in $(properties) || <toolset>intel-win in $(properties)
{
# allow larger .obj files (with more sections)
result += <cxxflags>/bigobj ;
}
if <toolset>gcc in $(properties) && <target-os>windows in $(properties)
{
# allow larger .obj files (with more sections)
result += <cxxflags>-Wa,-mbig-obj ;
}
if ! <target-os>windows in $(properties)
&& <toolset>gcc in $(properties)
&& <libtorrent-link>static in $(properties)
{
result += <libtorrent-python-pic>on ;
}
if <toolset>gcc in $(properties)
|| <toolset>darwin in $(properties)
|| <toolset>clang in $(properties)
|| <toolset>clang-darwin in $(properties)
{
# hide non-external symbols
result += <cxxflags>-fvisibility=hidden ;
result += <cxxflags>-fvisibility-inlines-hidden ;
if ( <toolset>gcc in $(properties) )
{
result += <linkflags>-Wl,-Bsymbolic ;
}
}
if <link>static in $(properties)
{
ECHO "WARNING: you probably want to specify libtorrent-link=static rather than link=static" ;
}
local BOOST_VERSION_TAG = [ modules.peek boostcpp : BOOST_VERSION_TAG ] ;
if <boost-link>static in $(properties) && $(BOOST_VERSION_TAG) < 1_74 && <target-os>linux in $(properties)
{
ECHO "WARNING: you cannot link statically against boost-python on linux before version 1.74.0, because it links against pthread statically in that case, which is not allowed" ;
}
local boost_python_lib ;
for local prop in $(properties)
{
switch $(prop)
{
case <python>2.* : boost_python_lib = boost_python ;
case <python>3.* : boost_python_lib = boost_python3 ;
}
}
if ! $(boost_python_lib)
{
ECHO "WARNING: unknown python version" ;
boost_python_lib = boost_python ;
}
# linux must link dynamically against boost python because it pulls
# in libpthread, which must be linked dynamically since we're building a .so
# (the static build of libpthread is not position independent)
if <boost-link>shared in $(properties) || ( <target-os>linux in $(properties) && $(BOOST_VERSION_TAG) < 1_74 )
{
result += <library>$(boost_python_lib)/<link>shared/<warnings>off ;
}
else
{
result += <library>$(boost_python_lib)/<link>static/<warnings>off ;
}
if <libtorrent-link>shared in $(properties)
{
result += <library>/torrent//torrent/<link>shared ;
}
else if <libtorrent-link>static in $(properties)
{
result += <library>/torrent//torrent/<link>static ;
}
else
{
result += <library>prebuilt_libtorrent ;
}
return $(result) ;
}
# this is a copy of the rule from boost-build's python-extension, but without
# specifying <suppress-import-lib>no as a mandatory property. That property
# would otherwise cause build failures because it suppresses linking against the
# runtime library and kernel32 on windows
rule my-python-extension ( name : sources * : requirements * : default-build * :
usage-requirements * )
{
requirements += <use>/python//python_for_extensions ;
local project = [ project.current ] ;
targets.main-target-alternative
[ new typed-target $(name) : $(project) : PYTHON_EXTENSION
: [ targets.main-target-sources $(sources) : $(name) ]
: [ targets.main-target-requirements $(requirements) : $(project) ]
: [ targets.main-target-default-build $(default-build) : $(project) ]
] ;
}
my-python-extension libtorrent
: # sources
src/module.cpp
src/sha1_hash.cpp
src/sha256_hash.cpp
src/info_hash.cpp
src/converters.cpp
src/create_torrent.cpp
src/fingerprint.cpp
src/utility.cpp
src/session.cpp
src/entry.cpp
src/torrent_info.cpp
src/string.cpp
src/torrent_handle.cpp
src/torrent_status.cpp
src/session_settings.cpp
src/version.cpp
src/alert.cpp
src/datetime.cpp
src/peer_info.cpp
src/ip_filter.cpp
src/magnet_uri.cpp
src/error_code.cpp
src/load_torrent.cpp
: # requirements
<include>src
<toolset>gcc:<cxxflags>-Wno-deprecated-declarations
<toolset>darwin:<cxxflags>-Wno-deprecated-declarations
<toolset>darwin:<cxxflags>-Wno-unused-command-line-argument
<conditional>@libtorrent_linking
<crypto>openssl:<library>/torrent//ssl
<crypto>openssl:<library>/torrent//crypto
<cxxflags>"$(CXXFLAGS:J= )"
<linkflags>"$(LDFLAGS:J= )"
# C4268: 'identifier' : 'const' static/global data initialized
# with compiler generated default constructor fills the object with zeros
<toolset>msvc:<cxxflags>/wd4268
: # default-build
<warnings>all
<cxxstd>14
: # usage-requirements
<suppress-import-lib>false
;
rule python-install-dir ( properties * )
{
local install-dir = [ feature.get-values python-install-path : $(properties) ] ;
if ( $(install-dir) != "" )
{
# if the user has provided an install location, use that one
return <location>$(install-dir) ;
}
local python-interpreter = [ feature.get-values python.interpreter : $(properties) ] ;
if ( $(python-interpreter) = "" )
{
return <location>. ;
}
# sys.path are defined differently between python2 and python3
local python-path ;
if <python-install-scope>system in $(properties)
{
python-path = [ SHELL "$(python-interpreter) -c \"import distutils.sysconfig; import sys; sys.stdout.write(distutils.sysconfig.get_python_lib())\"" ] ;
}
else
{
python-path = [ SHELL "$(python-interpreter) -c \"import site; import sys; sys.stdout.write(site.USER_SITE)\"" ] ;
}
if $(python-path) = ""
{
return <location>. ;
}
ECHO "python install directory:" $(python-path) ;
return <location>$(python-path) ;
}
install install_module
: libtorrent
: <conditional>@python-install-dir
<install-type>PYTHON_EXTENSION
;
explicit install_module ;
install stage_module
: libtorrent
: <location>.
<install-type>PYTHON_EXTENSION
: <cxxstd>14
;
install stage_dependencies
: /torrent//torrent
boost_python
boost_python3
: <location>dependencies
<install-dependencies>on
<install-type>SHARED_LIB
: <cxxstd>14
;
explicit stage_module ;
explicit stage_dependencies ;
|