Skip to content

OpenSSL for LibTorrent optional dependency #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pythonforandroid/recipes/boost/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def prebuild_arch(self, arch):
'--install-dir=' + env['CROSSHOME'],
'--system=' + 'linux-x86_64'
)
# Install app stl
shutil.copyfile(join(env['CROSSHOME'], env['CROSSHOST'], 'lib/libgnustl_shared.so'),
join(self.ctx.get_libs_dir(arch.arch), 'libgnustl_shared.so'))
# Set custom configuration
shutil.copyfile(join(self.get_recipe_dir(), 'user-config.jam'),
join(env['BOOST_BUILD_PATH'], 'user-config.jam'))

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

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

def get_recipe_env(self, arch):
env = super(BoostRecipe, self).get_recipe_env(arch)
#env['OPENSSL_BUILD_PATH'] = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
env['BOOST_BUILD_PATH'] = self.get_build_dir(arch.arch) # find user-config.jam
env['BOOST_ROOT'] = env['BOOST_BUILD_PATH'] # find boost source
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
Expand Down
6 changes: 0 additions & 6 deletions pythonforandroid/recipes/boost/user-config.jam
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ local TOOLCHAIN_VERSION = [ os.environ TOOLCHAIN_VERSION ] ;
local TOOLCHAIN_PREFIX = [ os.environ TOOLCHAIN_PREFIX ] ;
local ARCH = [ os.environ ARCH ] ;
local PYTHON_ROOT = [ os.environ PYTHON_ROOT ] ;
#local OPENSSL_BUILD_PATH = [ os.environ OPENSSL_BUILD_PATH ] ;

using gcc : $(ARCH) : $(TOOLCHAIN_PREFIX)-g++ :
<architecture>$(ARCH)
Expand All @@ -21,14 +20,9 @@ using gcc : $(ARCH) : $(TOOLCHAIN_PREFIX)-g++ :
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)/include
<compileflags>-I$(PYTHON_ROOT)/include/python2.7
#<compileflags>-I$(OPENSSL_BUILD_PATH)/include
#<compileflags>-I$(OPENSSL_BUILD_PATH)/include/openssl
<linkflags>--sysroot=$(ANDROIDNDK)/platforms/android-$(ANDROIDAPI)/arch-$(ARCH)
<linkflags>-L$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)
<linkflags>-L$(PYTHON_ROOT)/lib
#<linkflags>-L$(OPENSSL_BUILD_PATH)
<linkflags>-lgnustl_shared
<linkflags>-lpython2.7
#<linkflags>-lcrypto
#<linkflags>-lssl
;
24 changes: 20 additions & 4 deletions pythonforandroid/recipes/libtorrent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ class LibtorrentRecipe(Recipe):
version = '1.0.8'
# Don't forget to change the URL when changing the version
url = 'http://github.com/arvidn/libtorrent/archive/libtorrent-1_0_8.tar.gz'
depends = ['boost', 'python2'] #'openssl'
depends = ['boost', 'python2']
opt_depends = ['openssl']
patches = ['disable-so-version.patch', 'use-soname-python.patch']

def should_build(self, arch):
return not ( self.has_libs(arch, 'libboost_python.so', 'libboost_system.so', 'libtorrent.so')
and self.ctx.has_package('libtorrent.so', arch.arch) )
and self.ctx.has_package('libtorrent', arch.arch) )

def prebuild_arch(self, arch):
super(LibtorrentRecipe, self).prebuild_arch(arch)
if 'openssl' in recipe.ctx.recipe_build_order:
# Patch boost user-config.jam to use openssl
self.get_recipe('boost', self.ctx).apply_patch(join(self.get_recipe_dir(), 'user-config-openssl.patch'), arch.arch)

def build_arch(self, arch):
super(LibtorrentRecipe, self).build_arch(arch)
Expand All @@ -31,16 +38,23 @@ def build_arch(self, arch):
'link=shared',
'boost-link=shared',
'boost=source',
# 'encryption=openssl',
'encryption=openssl' if 'openssl' in recipe.ctx.recipe_build_order else '',
'--prefix=' + env['CROSSHOME'],
'release'
, _env=env)
# Common build directories
build_subdirs = 'gcc-arm/release/boost-link-shared/boost-source'
if 'openssl' in recipe.ctx.recipe_build_order:
build_subdirs += '/encryption-openssl'
build_subdirs += '/libtorrent-python-pic-on/target-os-android/threading-multi/visibility-hidden'
# Copy the shared libraries into the libs folder
build_subdirs = 'gcc-arm/release/boost-link-shared/boost-source/libtorrent-python-pic-on/target-os-android/threading-multi/visibility-hidden' #encryption-openssl
shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/python/build', build_subdirs, 'libboost_python.so'),
join(self.ctx.get_libs_dir(arch.arch), 'libboost_python.so'))
shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/system/build', build_subdirs, 'libboost_system.so'),
join(self.ctx.get_libs_dir(arch.arch), 'libboost_system.so'))
if 'openssl' in recipe.ctx.recipe_build_order:
shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/date_time/build', build_subdirs, 'libboost_date_time.so'),
join(self.ctx.get_libs_dir(arch.arch), 'libboost_date_time.so'))
shutil.copyfile(join(self.get_build_dir(arch.arch), 'bin', build_subdirs, 'libtorrent.so'),
join(self.ctx.get_libs_dir(arch.arch), 'libtorrent.so'))
shutil.copyfile(join(self.get_build_dir(arch.arch), 'bindings/python/bin', build_subdirs, 'libtorrent.so'),
Expand All @@ -50,6 +64,8 @@ def get_recipe_env(self, arch):
env = super(LibtorrentRecipe, self).get_recipe_env(arch)
# Copy environment from boost recipe
env.update(self.get_recipe('boost', self.ctx).get_recipe_env(arch))
if 'openssl' in recipe.ctx.recipe_build_order:
env['OPENSSL_BUILD_PATH'] = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
return env

recipe = LibtorrentRecipe()
25 changes: 25 additions & 0 deletions pythonforandroid/recipes/libtorrent/user-config-openssl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--- boost/user-config.jam 2016-03-02 14:31:41.280414820 +0100
+++ boost-patch/user-config.jam 2016-03-02 14:32:08.904384741 +0100
@@ -6,6 +6,7 @@
local TOOLCHAIN_PREFIX = [ os.environ TOOLCHAIN_PREFIX ] ;
local ARCH = [ os.environ ARCH ] ;
local PYTHON_ROOT = [ os.environ PYTHON_ROOT ] ;
+local OPENSSL_BUILD_PATH = [ os.environ OPENSSL_BUILD_PATH ] ;

using gcc : $(ARCH) : $(TOOLCHAIN_PREFIX)-g++ :
<architecture>$(ARCH)
@@ -20,9 +21,14 @@
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)/include
<compileflags>-I$(PYTHON_ROOT)/include/python2.7
+<compileflags>-I$(OPENSSL_BUILD_PATH)/include
+<compileflags>-I$(OPENSSL_BUILD_PATH)/include/openssl
<linkflags>--sysroot=$(ANDROIDNDK)/platforms/android-$(ANDROIDAPI)/arch-$(ARCH)
<linkflags>-L$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)
<linkflags>-L$(PYTHON_ROOT)/lib
+<linkflags>-L$(OPENSSL_BUILD_PATH)
<linkflags>-lgnustl_shared
<linkflags>-lpython2.7
+<linkflags>-lcrypto
+<linkflags>-lssl
;