Skip to content

Commit 330dc6f

Browse files
committed
openssl libtorrent optional dependency;
1 parent 24831df commit 330dc6f

File tree

4 files changed

+51
-16
lines changed

4 files changed

+51
-16
lines changed

pythonforandroid/recipes/boost/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def prebuild_arch(self, arch):
2828
'--install-dir=' + env['CROSSHOME'],
2929
'--system=' + 'linux-x86_64'
3030
)
31-
# Install app stl
32-
shutil.copyfile(join(env['CROSSHOME'], env['CROSSHOST'], 'lib/libgnustl_shared.so'),
33-
join(self.ctx.get_libs_dir(arch.arch), 'libgnustl_shared.so'))
31+
# Set custom configuration
32+
shutil.copyfile(join(self.get_recipe_dir(), 'user-config.jam'),
33+
join(env['BOOST_BUILD_PATH'], 'user-config.jam'))
3434

3535
def build_arch(self, arch):
3636
super(BoostRecipe, self).build_arch(arch)
@@ -43,15 +43,15 @@ def build_arch(self, arch):
4343
'--with-python-version=2.7',
4444
'--with-python-root=' + env['PYTHON_ROOT']
4545
) # Do not pass env
46-
shutil.copyfile(join(self.get_recipe_dir(), 'user-config.jam'),
47-
join(env['BOOST_BUILD_PATH'], 'user-config.jam'))
46+
# Install app stl
47+
shutil.copyfile(join(env['CROSSHOME'], env['CROSSHOST'], 'lib/libgnustl_shared.so'),
48+
join(self.ctx.get_libs_dir(arch.arch), 'libgnustl_shared.so'))
4849

4950
def select_build_arch(self, arch):
5051
return arch.arch.replace('eabi', '')
5152

5253
def get_recipe_env(self, arch):
5354
env = super(BoostRecipe, self).get_recipe_env(arch)
54-
#env['OPENSSL_BUILD_PATH'] = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
5555
env['BOOST_BUILD_PATH'] = self.get_build_dir(arch.arch) # find user-config.jam
5656
env['BOOST_ROOT'] = env['BOOST_BUILD_PATH'] # find boost source
5757
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()

pythonforandroid/recipes/boost/user-config.jam

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ local TOOLCHAIN_VERSION = [ os.environ TOOLCHAIN_VERSION ] ;
66
local TOOLCHAIN_PREFIX = [ os.environ TOOLCHAIN_PREFIX ] ;
77
local ARCH = [ os.environ ARCH ] ;
88
local PYTHON_ROOT = [ os.environ PYTHON_ROOT ] ;
9-
#local OPENSSL_BUILD_PATH = [ os.environ OPENSSL_BUILD_PATH ] ;
109

1110
using gcc : $(ARCH) : $(TOOLCHAIN_PREFIX)-g++ :
1211
<architecture>$(ARCH)
@@ -21,14 +20,9 @@ using gcc : $(ARCH) : $(TOOLCHAIN_PREFIX)-g++ :
2120
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include
2221
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)/include
2322
<compileflags>-I$(PYTHON_ROOT)/include/python2.7
24-
#<compileflags>-I$(OPENSSL_BUILD_PATH)/include
25-
#<compileflags>-I$(OPENSSL_BUILD_PATH)/include/openssl
2623
<linkflags>--sysroot=$(ANDROIDNDK)/platforms/android-$(ANDROIDAPI)/arch-$(ARCH)
2724
<linkflags>-L$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)
2825
<linkflags>-L$(PYTHON_ROOT)/lib
29-
#<linkflags>-L$(OPENSSL_BUILD_PATH)
3026
<linkflags>-lgnustl_shared
3127
<linkflags>-lpython2.7
32-
#<linkflags>-lcrypto
33-
#<linkflags>-lssl
3428
;

pythonforandroid/recipes/libtorrent/__init__.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@ class LibtorrentRecipe(Recipe):
99
version = '1.0.8'
1010
# Don't forget to change the URL when changing the version
1111
url = 'http://github.com/arvidn/libtorrent/archive/libtorrent-1_0_8.tar.gz'
12-
depends = ['boost', 'python2'] #'openssl'
12+
depends = ['boost', 'python2']
13+
opt_depends = ['openssl']
1314
patches = ['disable-so-version.patch', 'use-soname-python.patch']
1415

1516
def should_build(self, arch):
1617
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+
and self.ctx.has_package('libtorrent', arch.arch) )
19+
20+
def prebuild_arch(self, arch):
21+
super(LibtorrentRecipe, self).prebuild_arch(arch)
22+
if 'openssl' in recipe.ctx.recipe_build_order:
23+
# Patch boost user-config.jam to use openssl
24+
self.get_recipe('boost', self.ctx).apply_patch(join(self.get_recipe_dir(), 'user-config-openssl.patch'), arch.arch)
1825

1926
def build_arch(self, arch):
2027
super(LibtorrentRecipe, self).build_arch(arch)
@@ -31,16 +38,23 @@ def build_arch(self, arch):
3138
'link=shared',
3239
'boost-link=shared',
3340
'boost=source',
34-
# 'encryption=openssl',
41+
'encryption=openssl' if 'openssl' in recipe.ctx.recipe_build_order else '',
3542
'--prefix=' + env['CROSSHOME'],
3643
'release'
3744
, _env=env)
45+
# Common build directories
46+
build_subdirs = 'gcc-arm/release/boost-link-shared/boost-source'
47+
if 'openssl' in recipe.ctx.recipe_build_order:
48+
build_subdirs += '/encryption-openssl'
49+
build_subdirs += '/libtorrent-python-pic-on/target-os-android/threading-multi/visibility-hidden'
3850
# 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
4051
shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/python/build', build_subdirs, 'libboost_python.so'),
4152
join(self.ctx.get_libs_dir(arch.arch), 'libboost_python.so'))
4253
shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/system/build', build_subdirs, 'libboost_system.so'),
4354
join(self.ctx.get_libs_dir(arch.arch), 'libboost_system.so'))
55+
if 'openssl' in recipe.ctx.recipe_build_order:
56+
shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/date_time/build', build_subdirs, 'libboost_date_time.so'),
57+
join(self.ctx.get_libs_dir(arch.arch), 'libboost_date_time.so'))
4458
shutil.copyfile(join(self.get_build_dir(arch.arch), 'bin', build_subdirs, 'libtorrent.so'),
4559
join(self.ctx.get_libs_dir(arch.arch), 'libtorrent.so'))
4660
shutil.copyfile(join(self.get_build_dir(arch.arch), 'bindings/python/bin', build_subdirs, 'libtorrent.so'),
@@ -50,6 +64,8 @@ def get_recipe_env(self, arch):
5064
env = super(LibtorrentRecipe, self).get_recipe_env(arch)
5165
# Copy environment from boost recipe
5266
env.update(self.get_recipe('boost', self.ctx).get_recipe_env(arch))
67+
if 'openssl' in recipe.ctx.recipe_build_order:
68+
env['OPENSSL_BUILD_PATH'] = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
5369
return env
5470

5571
recipe = LibtorrentRecipe()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--- boost/user-config.jam 2016-03-02 14:31:41.280414820 +0100
2+
+++ boost-patch/user-config.jam 2016-03-02 14:32:08.904384741 +0100
3+
@@ -6,6 +6,7 @@
4+
local TOOLCHAIN_PREFIX = [ os.environ TOOLCHAIN_PREFIX ] ;
5+
local ARCH = [ os.environ ARCH ] ;
6+
local PYTHON_ROOT = [ os.environ PYTHON_ROOT ] ;
7+
+local OPENSSL_BUILD_PATH = [ os.environ OPENSSL_BUILD_PATH ] ;
8+
9+
using gcc : $(ARCH) : $(TOOLCHAIN_PREFIX)-g++ :
10+
<architecture>$(ARCH)
11+
@@ -20,9 +21,14 @@
12+
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include
13+
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)/include
14+
<compileflags>-I$(PYTHON_ROOT)/include/python2.7
15+
+<compileflags>-I$(OPENSSL_BUILD_PATH)/include
16+
+<compileflags>-I$(OPENSSL_BUILD_PATH)/include/openssl
17+
<linkflags>--sysroot=$(ANDROIDNDK)/platforms/android-$(ANDROIDAPI)/arch-$(ARCH)
18+
<linkflags>-L$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)
19+
<linkflags>-L$(PYTHON_ROOT)/lib
20+
+<linkflags>-L$(OPENSSL_BUILD_PATH)
21+
<linkflags>-lgnustl_shared
22+
<linkflags>-lpython2.7
23+
+<linkflags>-lcrypto
24+
+<linkflags>-lssl
25+
;

0 commit comments

Comments
 (0)