2007-01-10 17:11:43 +01:00
import python ;
2018-04-13 06:05:02 +02:00
import feature ;
2014-03-23 08:34:18 +01:00
import feature : feature ;
2014-11-28 19:58:18 +01:00
import project ;
import targets ;
import "class" : new ;
2015-08-10 03:23:11 +02:00
import modules ;
2007-01-10 17:11:43 +01:00
2007-06-13 06:22:06 +02:00
use-project /torrent : ../.. ;
2015-08-10 03:23:11 +02:00
BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ;
2018-03-25 22:31:26 +02:00
# this is used to make bjam use the same version of python which is executing setup.py
LIBTORRENT_PYTHON_INTERPRETER = [ modules.peek : LIBTORRENT_PYTHON_INTERPRETER ] ;
2008-05-08 03:53:05 +02:00
2018-11-04 16:17:30 +01:00
feature lt-visibility : default hidden : composite propagated ;
2018-10-27 15:24:05 +02:00
feature.compose <lt-visibility>hidden : <cflags>-fvisibility=hidden <cxxflags>-fvisibility-inlines-hidden ;
2014-03-23 08:34:18 +01:00
2015-06-07 07:31:09 +02:00
feature libtorrent-link : shared static : composite propagated ;
2014-11-28 19:58:18 +01:00
feature libtorrent-python-pic : off on : composite propagated link-incompatible ;
2014-04-01 04:12:11 +02:00
feature.compose <libtorrent-python-pic>on : <cflags>-fPIC ;
2014-03-31 08:43:29 +02:00
2018-03-25 22:31:26 +02:00
# this is just to force boost build to pick the desired python target when using LIBTORRENT_PYTHON_INTERPRETER
feature libtorrent-python : on ;
if $(LIBTORRENT_PYTHON_INTERPRETER)
{
echo "using python interpreter at: " $(LIBTORRENT_PYTHON_INTERPRETER) ;
using python : : "$(LIBTORRENT_PYTHON_INTERPRETER)" : : : <libtorrent-python>on ;
}
2018-04-13 06:05:02 +02:00
# copied from boost 1.63's boost python jamfile
rule find-py3-version
{
local versions = [ feature.values python ] ;
local py3ver ;
for local v in $(versions)
{
if $(v) >= 3.0
{
py3ver = $(v) ;
}
}
return $(py3ver) ;
}
2015-08-10 03:23:11 +02:00
if $(BOOST_ROOT)
{
use-project /boost : $(BOOST_ROOT) ;
alias boost_python : /boost/python//boost_python : : : <include>$(BOOST_ROOT) ;
2018-04-13 06:05:02 +02:00
if [ find-py3-version ]
{
alias boost_python3 : /boost/python//boost_python3 : : : <include>$(BOOST_ROOT) ;
}
else
{
alias boost_python3 ;
}
2015-08-10 03:23:11 +02:00
}
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>/usr/local/include
<include>/usr/sfw/include
;
# the names are decorated in MacPorts
2018-04-21 17:17:15 +02:00
lib boost_python : : <target-os>darwin <name>boost_python27-mt
2015-08-10 03:23:11 +02:00
: : $(boost-include-path) ;
2018-03-25 22:31:26 +02:00
lib boost_python3 : : <target-os>darwin <name>boost_python3-mt
: : $(boost-include-path) ;
2015-08-10 03:23:11 +02:00
lib boost_python : : <name>boost_python
: : $(boost-include-path) ;
2018-03-25 22:31:26 +02:00
lib boost_python3 : : <name>boost_python3
: : $(boost-include-path) ;
2015-08-10 03:23:11 +02:00
}
2015-06-07 07:31:09 +02:00
2008-11-23 21:41:24 +01:00
rule libtorrent_linking ( properties * )
{
local result ;
2014-12-02 11:18:07 +01:00
if ! <target-os>windows in $(properties)
&& <toolset>gcc in $(properties)
2016-05-20 07:32:32 +02:00
&& <libtorrent-link>static in $(properties)
2008-11-23 21:41:24 +01:00
{
2014-04-01 04:12:11 +02:00
result += <libtorrent-python-pic>on ;
2008-11-23 21:41:24 +01:00
}
2012-03-22 04:33:54 +01:00
if <toolset>gcc in $(properties)
2013-04-27 21:35:41 +02:00
|| <toolset>darwin in $(properties)
|| <toolset>clang in $(properties)
|| <toolset>clang-darwin in $(properties)
2012-03-22 04:33:54 +01:00
{
2018-10-27 15:24:05 +02:00
result += <lt-visibility>hidden ;
2014-03-23 08:34:18 +01:00
if ( <toolset>gcc in $(properties) )
{
result += <linkflags>-Wl,-Bsymbolic ;
}
2012-03-22 04:33:54 +01:00
}
2008-12-20 22:12:39 +01:00
2015-04-04 20:03:55 +02:00
if <link>static in $(properties)
{
ECHO "WARNING: you probably want to specify libtorrent-link=static rather than link=static" ;
}
2015-08-10 03:23:11 +02:00
if <boost-link>static in $(properties) && <target-os>linux in $(properties)
2011-07-19 03:54:57 +02:00
{
2015-08-10 03:23:11 +02:00
ECHO "WARNING: you cannot link statically against boost-python on linux, because it links against pthread statically in that case, which is not allowed" ;
}
2013-04-27 21:35:41 +02:00
2018-03-25 22:31:26 +02:00
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 ;
}
2015-08-10 03:23:11 +02:00
# 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)
{
2018-04-02 00:03:43 +02:00
result += <library>$(boost_python_lib)/<link>shared/<warnings>off ;
2011-07-19 03:54:57 +02:00
}
else
{
2018-04-02 00:03:43 +02:00
result += <library>$(boost_python_lib)/<link>static/<warnings>off ;
2015-08-10 03:23:11 +02:00
}
2014-03-23 08:34:18 +01:00
2015-08-10 03:23:11 +02:00
if <libtorrent-link>shared in $(properties)
{
2015-09-12 05:13:27 +02:00
result += <library>/torrent//torrent/<link>shared ;
2015-08-10 03:23:11 +02:00
}
else
{
2015-09-12 05:13:27 +02:00
result += <library>/torrent//torrent/<link>static ;
2011-07-19 03:54:57 +02:00
}
2008-11-23 21:41:24 +01:00
return $(result) ;
}
2014-11-28 19:58:18 +01:00
# 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) ]
] ;
}
2015-09-23 18:13:00 +02:00
my-python-extension libtorrent
2014-03-23 08:34:18 +01:00
: # sources
src/module.cpp
2016-06-19 01:24:27 +02:00
src/sha1_hash.cpp
2009-02-20 09:58:36 +01:00
src/converters.cpp
2009-02-21 09:39:26 +01:00
src/create_torrent.cpp
2007-01-10 17:11:43 +01:00
src/fingerprint.cpp
src/utility.cpp
src/session.cpp
src/entry.cpp
src/torrent_info.cpp
2012-11-23 21:43:42 +01:00
src/string.cpp
2007-01-10 17:11:43 +01:00
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
2008-02-17 22:17:43 +01:00
src/ip_filter.cpp
2008-10-02 07:00:40 +02:00
src/magnet_uri.cpp
2011-06-25 22:11:31 +02:00
src/error_code.cpp
2014-03-23 08:34:18 +01:00
: # requirements
<include>src
2015-08-21 14:03:16 +02:00
<toolset>gcc:<cxxflags>-Wno-deprecated-declarations
<toolset>darwin:<cxxflags>-Wno-deprecated-declarations
2015-09-12 05:13:27 +02:00
<toolset>darwin:<cxxflags>-Wno-unused-command-line-argument
2008-11-23 21:41:24 +01:00
<conditional>@libtorrent_linking
2017-10-09 01:21:19 +02:00
<crypto>openssl:<library>/torrent//ssl
<crypto>openssl:<library>/torrent//crypto
2016-06-19 01:24:27 +02:00
: # default-build
<warnings>all
2015-06-07 07:31:09 +02:00
: # usage-requirements
2014-11-28 19:58:18 +01:00
<suppress-import-lib>false
2007-01-10 17:11:43 +01:00
;
2015-07-27 02:22:03 +02:00
install stage_module
2015-09-23 18:13:00 +02:00
: libtorrent
2015-09-12 05:13:27 +02:00
: <location>.
2017-08-14 00:49:49 +02:00
<install-type>PYTHON_EXTENSION
;
install stage_dependencies
: /torrent//torrent
boost_python
2018-04-02 00:03:43 +02:00
boost_python3
2017-08-14 00:49:49 +02:00
: <location>dependencies
<install-dependencies>on
<install-type>SHARED_LIB
2015-09-12 05:13:27 +02:00
;
2015-07-27 02:22:03 +02:00
explicit stage_module ;
2017-08-14 00:49:49 +02:00
explicit stage_dependencies ;
2010-03-28 04:06:50 +02:00