2017-08-28 14:07:06 +02:00
|
|
|
from functools import partial
|
|
|
|
|
2019-03-29 16:34:59 +01:00
|
|
|
from pythonforandroid.recipe import Recipe
|
|
|
|
from pythonforandroid.toolchain import shprint, current_directory
|
2017-08-28 14:07:06 +02:00
|
|
|
import sh
|
|
|
|
|
|
|
|
|
|
|
|
class OpenSSLRecipe(Recipe):
|
2019-03-29 16:34:59 +01:00
|
|
|
version = '1.1'
|
|
|
|
url_version = '1.1.1b'
|
|
|
|
url = 'https://www.openssl.org/source/openssl-{url_version}.tar.gz'
|
|
|
|
|
|
|
|
@property
|
|
|
|
def versioned_url(self):
|
|
|
|
if self.url is None:
|
|
|
|
return None
|
|
|
|
return self.url.format(url_version=self.url_version)
|
2017-08-28 14:07:06 +02:00
|
|
|
|
|
|
|
def should_build(self, arch):
|
|
|
|
return not self.has_libs(arch, 'libssl' + self.version + '.so',
|
|
|
|
'libcrypto' + self.version + '.so')
|
|
|
|
|
|
|
|
def check_symbol(self, env, sofile, symbol):
|
|
|
|
nm = env.get('NM', 'nm')
|
|
|
|
syms = sh.sh('-c', "{} -gp {} | cut -d' ' -f3".format(
|
|
|
|
nm, sofile), _env=env).splitlines()
|
|
|
|
if symbol in syms:
|
|
|
|
return True
|
|
|
|
print('{} missing symbol {}; rebuilding'.format(sofile, symbol))
|
|
|
|
return False
|
|
|
|
|
|
|
|
def get_recipe_env(self, arch=None):
|
|
|
|
env = super(OpenSSLRecipe, self).get_recipe_env(arch)
|
|
|
|
env['OPENSSL_VERSION'] = self.version
|
2019-03-29 16:34:59 +01:00
|
|
|
env['MAKE'] = 'make' # This removes the '-j5', which isn't safe
|
2017-08-28 14:07:06 +02:00
|
|
|
env['CFLAGS'] += ' ' + env['LDFLAGS']
|
|
|
|
env['CC'] += ' ' + env['LDFLAGS']
|
2019-03-29 16:34:59 +01:00
|
|
|
env['ANDROID_NDK'] = self.ctx.ndk_dir
|
2017-08-28 14:07:06 +02:00
|
|
|
return env
|
|
|
|
|
|
|
|
def select_build_arch(self, arch):
|
|
|
|
aname = arch.arch
|
|
|
|
if 'arm64' in aname:
|
2019-03-29 16:34:59 +01:00
|
|
|
return 'android-arm64'
|
2017-08-28 14:07:06 +02:00
|
|
|
if 'v7a' in aname:
|
2019-03-29 16:34:59 +01:00
|
|
|
return 'android-arm'
|
2017-08-28 14:07:06 +02:00
|
|
|
if 'arm' in aname:
|
|
|
|
return 'android'
|
|
|
|
return 'linux-armv4'
|
|
|
|
|
|
|
|
def build_arch(self, arch):
|
|
|
|
env = self.get_recipe_env(arch)
|
|
|
|
with current_directory(self.get_build_dir(arch.arch)):
|
|
|
|
# sh fails with code 255 trying to execute ./Configure
|
|
|
|
# so instead we manually run perl passing in Configure
|
|
|
|
perl = sh.Command('perl')
|
|
|
|
buildarch = self.select_build_arch(arch)
|
2019-03-29 16:34:59 +01:00
|
|
|
|
|
|
|
config_args = ['shared', 'no-dso', 'no-asm']
|
|
|
|
config_args.append(buildarch)
|
|
|
|
shprint(perl, 'Configure', *config_args, _env=env)
|
2017-08-28 14:07:06 +02:00
|
|
|
self.apply_patch('disable-sover.patch', arch.arch)
|
2019-03-29 16:34:59 +01:00
|
|
|
self.apply_patch('fix-cross-compile.patch', arch.arch)
|
|
|
|
|
|
|
|
shprint(sh.make, 'build_libs', _env=env)
|
2017-08-28 14:07:06 +02:00
|
|
|
|
2018-10-07 16:59:03 +02:00
|
|
|
self.install_libs(arch, 'libssl.a', 'libssl' + self.version + '.so',
|
|
|
|
'libcrypto.a', 'libcrypto' + self.version + '.so')
|
2017-08-28 14:07:06 +02:00
|
|
|
|
|
|
|
recipe = OpenSSLRecipe()
|