10000 Openssl for Python 2.7.11 (mandatory dependency of Python 2.7.11) by opacam · Pull Request #774 · kivy/python-for-android · GitHub
[go: up one dir, main page]

Skip to content
8000

Openssl for Python 2.7.11 (mandatory dependency of Python 2.7.11) #774

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

Closed
wants to merge 1 commit into from
Closed
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
49 changes: 41 additions & 8 deletions pythonforandroid/recipes/openssl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
from functools import partial

from pythonforandroid.toolchain import Recipe, shprint, current_directory
from pythonforandroid.toolchain import Recipe, current_directory
from pythonforandroid.logger import shprint
from os.path import join, exists
import sh


class OpenSSLRecipe(Recipe):
version = '1.0.2g'
url = 'https://www.openssl.org/source/openssl-{version}.tar.gz'
force_shared = False

@property
def build_static(self):
if self.force_shared:
return False
return True if 'python2' in self.ctx.recipe_build_order else False

@property
def libssl(self):
return 'libssl.a' if self.build_static else 'libssl.so'

@property
def libcrypto(self):
return 'libcrypto.a' if self.build_static else 'libcrypto.so'

def should_build(self, arch):
return not self.has_libs(arch, 'libssl.so', 'libcrypto.so')
if exists(join(self.get_build_dir(arch.arch), self.libssl)):
return False
return True

def check_symbol(self, env, sofile, symbol):
nm = env.get('NM', 'nm')
Expand Down Expand Up @@ -43,17 +60,33 @@ def build_arch(self, arch):
# so instead we manually run perl passing in Configure
perl = sh.Command('perl')
buildarch = self.select_build_arch(arch)
shprint(perl, 'Configure', 'shared', 'no-dso', 'no-krb5', buildarch, _env=env)

# NOTE: Disabled the build of shared libraries to prevent anything to be
# linked against them by mistake. It's better to build the openssl libs as
# static because this way we avoid conflicts with the openssl libs
# distributed with android system. You can force the build of shared libs
# setting the variable 'force_shared' to True, but probably,
# your app will not be able to use the compiled openssl libraries because
# when the app loads them, first will use the system ones,instead of the compiled
if self.build_static:
shprint(perl, 'Configure', 'no-dso', 'no-krb5', buildarch, _env=env)
else:
shprint(perl, 'Configure', 'shared', 'no-dso', 'no-krb5', buildarch, _env=env)

self.apply_patch('disable-sover.patch', arch.arch)

check_crypto = partial(self.check_symbol, env, 'libcrypto.so')
# check_ssl = partial(self.check_symbol, env, 'libssl.so')
check_crypto = partial(self.check_symbol, env, self.libcrypto)
# check_ssl = partial(self.check_symbol, env, self.libssl)
while True:
shprint(sh.make, 'build_libs', _env=env)
if all(map(check_crypto, ('SSLeay', 'MD5_Transform', 'MD4_Init'))):
break
shprint(sh.make, 'clean', _env=env)

self.install_libs(arch, 'libssl.so', 'libcrypto.so')
if exists('libssl.so') and not self.build_static:
self.install_libs(arch, 'libssl.so', 'libcrypto.so')
else:
shprint(sh.cp, 'libssl.a', self.ctx.libs_dir)
shprint(sh.cp, 'libcrypto.a', self.ctx.libs_dir)

recipe = OpenSSLRecipe()
0