|
| 1 | +import sh |
| 2 | +from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory |
| 3 | +from pythonforandroid.util import ensure_dir |
| 4 | +from os.path import exists, join, abspath |
| 5 | +from multiprocessing import cpu_count |
| 6 | + |
| 7 | + |
| 8 | +class LibcurlRecipe(Recipe): |
| 9 | + version = '7.55.1' |
| 10 | + url = 'https://curl.haxx.se/download/curl-7.55.1.tar.gz' |
| 11 | + depends = ['openssl'] |
| 12 | + |
| 13 | + def should_build(self, arch): |
| 14 | + super(LibcurlRecipe, self).should_build(arch) |
| 15 | + return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libcurl.so')) |
| 16 | + |
| 17 | + def build_arch(self, arch): |
| 18 | + super(LibcurlRecipe, self).build_arch(arch) |
| 19 | + env = self.get_recipe_env(arch) |
| 20 | + |
| 21 | + r = self.get_recipe('openssl', self.ctx) |
| 22 | + openssl_dir = r.get_build_dir(arch.arch) |
| 23 | + |
| 24 | + with current_directory(self.get_build_dir(arch.arch)): |
| 25 | + dst_dir = join(self.get_build_dir(arch.arch), 'dist') |
| 26 | + shprint( |
| 27 | + sh.Command('./configure'), |
| 28 | + '--host=arm-linux-androideabi', |
| 29 | + '--enable-shared', |
| 30 | + '--with-ssl={}'.format(openssl_dir), |
| 31 | + '--prefix={}'.format(dst_dir), |
| 32 | + _env=env) |
| 33 | + shprint(sh.make, '-j', str(cpu_count()), _env=env) |
| 34 | + shprint(sh.make, 'install', _env=env) |
| 35 | + shutil.copyfile('{}/lib/libcurl.so'.format(dst_dir), |
| 36 | + join( |
| 37 | + self.ctx.get_libs_dir(arch.arch), |
| 38 | + 'libcurl.so')) |
| 39 | + |
| 40 | +recipe = LibcurlRecipe() |
0 commit comments