Skip to content

Commit 84709a6

Browse files
committed
add libtorrent recipe;
1 parent 8b0b7b1 commit 84709a6

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
2+
from os.path import join, exists
3+
import sh
4+
5+
# This recipe builds libtorrent with Python bindings
6+
# It depends on Boost.Build and the source of several Boost libraries present in BOOST_ROOT,
7+
# which is all provided by the boost recipe
8+
class LibtorrentRecipe(Recipe):
9+
version = '1.0.8'
10+
# Don't forget to change the URL when changing the version
11+
url = 'http://github.com/arvidn/libtorrent/archive/libtorrent-1_0_8.tar.gz'
12+
depends = ['boost', 'python2'] #'openssl'
13+
patches = ['disable-so-version.patch', 'use-soname-python.patch']
14+
15+
def should_build(self, arch):
16+
return not ( self.has_libs(arch, 'libboost_python.so', 'libboost_system.so', 'libtorrent.so')
17+
and self.ctx.has_package('libtorrent.so', arch.arch) )
18+
19+
def build_arch(self, arch):
20+
super(LibtorrentRecipe, self).build_arch(arch)
21+
env = self.get_recipe_env(arch)
22+
with current_directory(join(self.get_build_dir(arch.arch), 'bindings/python')):
23+
# Compile libtorrent with boost libraries and python bindings
24+
b2 = sh.Command(join(env['BOOST_ROOT'], 'b2'))
25+
shprint(b2,
26+
'-q',
27+
'-j5',
28+
'toolset=gcc-' + env['ARCH'],
29+
'target-os=android',
30+
'threading=multi',
31+
'link=shared',
32+
'boost-link=shared',
33+
'boost=source',
34+
# 'encryption=openssl',
35+
'--prefix=' + env['CROSSHOME'],
36+
'release'
37+
, _env=env)
38+
# Copy the shared libraries into the libs folder
39+
build_subdirs = 'gcc-arm/release/boost-link-shared/boost-source/libtorrent-python-pic-on/target-os-android/threading-multi/visibility-hidden' #encryption-openssl
40+
shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/python/build', build_subdirs, 'libboost_python.so'),
41+
join(self.ctx.get_libs_dir(arch.arch), 'libboost_python.so'))
42+
shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/system/build', build_subdirs, 'libboost_system.so'),
43+
join(self.ctx.get_libs_dir(arch.arch), 'libboost_system.so'))
44+
shutil.copyfile(join(self.get_build_dir(arch.arch), 'bin', build_subdirs, 'libtorrent.so'),
45+
join(self.ctx.get_libs_dir(arch.arch), 'libtorrent.so'))
46+
shutil.copyfile(join(self.get_build_dir(arch.arch), 'bindings/python/bin', build_subdirs, 'libtorrent.so'),
47+
join(self.ctx.get_site_packages_dir(arch.arch), 'libtorrent.so'))
48+
49+
def get_recipe_env(self, arch):
50+
env = super(LibtorrentRecipe, self).get_recipe_env(arch)
51+
# Copy environment from boost recipe
52+
env.update(self.get_recipe('boost', self.ctx).get_recipe_env(arch))
53+
return env
54+
55+
recipe = LibtorrentRecipe()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- libtorrent/Jamfile 2016-01-17 23:52:45.000000000 +0100
2+
+++ libtorrent-patch/Jamfile 2016-02-09 13:37:57.499561750 +0100
3+
@@ -325,6 +325,7 @@
4+
if $(type) = SHARED_LIB &&
5+
( ! ( [ $(property-set).get <target-os> ] in windows cygwin ) )
6+
{
7+
+ return $(name) ; # disable version suffix for android
8+
name = $(name).$(VERSION) ;
9+
}
10+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- libtorrent/bindings/python/Jamfile 2016-01-17 23:52:45.000000000 +0100
2+
+++ libtorrent-patch/bindings/python/Jamfile 2016-02-09 17:11:44.261578000 +0100
3+
@@ -35,7 +35,7 @@
4+
5+
if ( <toolset>gcc in $(properties) )
6+
{
7+
- result += <linkflags>-Wl,-Bsymbolic ;
8+
+ result += <linkflags>-Wl,-soname=libtorrentpython.so,-Bsymbolic ;
9+
}
10+
}
11+

0 commit comments

Comments
 (0)