|
| 1 | +from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory |
| 2 | +from os.path import exists, join |
| 3 | +import sh |
| 4 | + |
| 5 | +class Libxml2Recipe(Recipe): |
| 6 | + version = '2.7.8' |
| 7 | + url = 'http://xmlsoft.org/sources/libxml2-{version}.tar.gz' |
| 8 | + depends = [] |
| 9 | + patches = ['add-glob.c.patch'] |
| 10 | + |
| 11 | + def should_build(self, arch): |
| 12 | + super(Libxml2Recipe, self).should_build(arch) |
| 13 | + return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libxml2.a')) |
| 14 | + |
| 15 | + def build_arch(self, arch): |
| 16 | + super(Libxml2Recipe, self).build_arch(arch) |
| 17 | + env = self.get_recipe_env(arch) |
| 18 | + with current_directory(self.get_build_dir(arch.arch)): |
| 19 | + env['CC'] += " -I%s" % self.get_build_dir(arch.arch) |
| 20 | + shprint(sh.Command('./configure'), '--host=arm-linux-eabi', |
| 21 | + '--without-modules', '--without-legacy', '--without-hfinistory', '--without-debug', '--without-docbook', '--without-python', '--without-threads', '--without-iconv', |
| 22 | + _env=env) |
| 23 | + |
| 24 | + # Ensure we only build libxml2.la as if we do everything |
| 25 | + # we'll need the glob dependency which is a big headache |
| 26 | + shprint(sh.make, "libxml2.la", _env=env) |
| 27 | + shutil.copyfile('.libs/libxml2.a', join(self.ctx.get_libs_dir(arch.arch), 'libxml2.a')) |
| 28 | + |
| 29 | + |
| 30 | + def get_recipe_env(self, arch): |
| 31 | + env = super(Libxml2Recipe, self).get_recipe_env(arch) |
| 32 | + env['CONFIG_SHELL'] = '/bin/bash' |
| 33 | + env['SHELL'] = '/bin/bash' |
| 34 | + env['CC'] = '/usr/bin/ccache arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer' |
| 35 | + return env |
| 36 | + |
| 37 | +recipe = Libxml2Recipe() |
0 commit comments