|
| 1 | + |
| 2 | +from pythonforandroid.toolchain import ( |
| 3 | + CompiledComponentsPythonRecipe, |
| 4 | + Recipe, |
| 5 | + current_directory, |
| 6 | + info, |
| 7 | + shprint, |
| 8 | +) |
| 9 | +from os.path import exists, join, realpath |
| 10 | +import sh |
| 11 | +import glob |
| 12 | + |
| 13 | + |
| 14 | +class PyCryptoRecipe(CompiledComponentsPythonRecipe): |
| 15 | + version = '2.6.1' |
| 16 | + url = 'https://pypi.python.org/packages/source/p/pycrypto/pycrypto-{version}.tar.gz' |
| 17 | + depends = ['openssl', 'python2'] |
| 18 | + |
| 19 | + def prebuild_arch(self, arch): |
| 20 | + super(PyCryptoRecipe, self).prebuild_arch(arch) |
| 21 | + build_dir = self.get_build_dir(arch.arch) |
| 22 | + if exists(join(build_dir, '.patched')): |
| 23 | + print('pycrypto already patched, skipping') |
| 24 | + return |
| 25 | + self.apply_patch('add_length.patch') |
| 26 | + shprint(sh.touch, join(build_dir, '.patched')) |
| 27 | + |
| 28 | + def get_recipe_env(self, arch): |
| 29 | + env = super(PyCryptoRecipe, self).get_recipe_env(arch) |
| 30 | + openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch) |
| 31 | + env['CC'] = '%s -I%s' % (env['CC'], join(openssl_build_dir, 'include')) |
| 32 | + env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format( |
| 33 | + self.ctx.get_libs_dir(arch.arch) + |
| 34 | + '-L{}'.format(self.ctx.libs_dir)) + ' -L{}'.format( |
| 35 | + openssl_build_dir) |
| 36 | + env['EXTRA_CFLAGS'] = '--host linux-armv' |
| 37 | + env['ac_cv_func_malloc_0_nonnull'] = 'yes' |
| 38 | + return env |
| 39 | + |
| 40 | + def build_compiled_components(self, arch): |
| 41 | + info('Configuring compiled components in {}'.format(self.name)) |
| 42 | + |
| 43 | + env = self.get_recipe_env(arch) |
| 44 | + with current_directory(self.get_build_dir(arch.arch)): |
| 45 | + configure = sh.Command('./configure') |
| 46 | + shprint(configure, '--host=arm-eabi', |
| 47 | + '--prefix={}'.format(self.ctx.get_python_install_dir()), |
| 48 | + '--enable-shared', _env=env) |
| 49 | + super(PyCryptoRecipe, self).build_compiled_components(arch) |
| 50 | + |
| 51 | +recipe = PyCryptoRecipe() |
0 commit comments