Skip to content

Commit

Permalink
Rework libxml2 recipe and update version
Browse files Browse the repository at this point in the history
Actions taken:
  - replace double quotes to single quotes because I think that it's more readable
  - fixed imports
  - shortened lines
  • Loading branch information
opacam committed Jan 11, 2019
1 parent 21bc8b8 commit 6ed40d5
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions pythonforandroid/recipes/libxml2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,58 @@
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
from pythonforandroid.recipe import Recipe
from pythonforandroid.toolchain import shprint, shutil, current_directory
from os.path import exists, join
import sh


class Libxml2Recipe(Recipe):
version = "2.7.8"
url = "http://xmlsoft.org/sources/libxml2-{version}.tar.gz"
version = '2.9.8'
url = 'http://xmlsoft.org/sources/libxml2-{version}.tar.gz'
depends = []
patches = ["add-glob.c.patch"]
patches = ['add-glob.c.patch']

def should_build(self, arch):
super(Libxml2Recipe, self).should_build(arch)
return not exists(join(self.ctx.get_libs_dir(arch.arch), "libxml2.a"))
return not exists(
join(self.get_build_dir(arch.arch), '.libs', 'libxml2.a'))

def build_arch(self, arch):
super(Libxml2Recipe, self).build_arch(arch)
env = self.get_recipe_env(arch)
with current_directory(self.get_build_dir(arch.arch)):
env["CC"] += " -I%s" % self.get_build_dir(arch.arch)
shprint(
sh.Command("./configure"),
"--host=arm-linux-eabi",
"--without-modules",
"--without-legacy",
"--without-history",
"--without-debug",
"--without-docbook",
"--without-python",
"--without-threads",
"--without-iconv",
_env=env,
)

if not exists('configure'):
shprint(sh.Command('./autogen.sh'), _env=env)
shprint(sh.Command('autoreconf'), '-vif', _env=env)
build_arch = shprint(
sh.gcc, '-dumpmachine').stdout.decode('utf-8').split('\n')[0]
shprint(sh.Command('./configure'),
'--build=' + build_arch,
'--host=' + arch.command_prefix,
'--target=' + arch.command_prefix,
'--without-modules',
'--without-legacy',
'--without-history',
'--without-debug',
'--without-docbook',
'--without-python',
'--without-threads',
'--without-iconv',
'--disable-shared',
'--enable-static',
_env=env)

# Ensure we only build libxml2.la as if we do everything
# we'll need the glob dependency which is a big headache
shprint(sh.make, "libxml2.la", _env=env)
shutil.copyfile(
".libs/libxml2.a", join(self.ctx.get_libs_dir(arch.arch), "libxml2.a")
)

shutil.copyfile('.libs/libxml2.a',
join(self.ctx.libs_dir, 'libxml2.a'))

def get_recipe_env(self, arch):
env = super(Libxml2Recipe, self).get_recipe_env(arch)
env["CONFIG_SHELL"] = "/bin/bash"
env["SHELL"] = "/bin/bash"
env[
"CC"
] = "arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot={}".format(
self.ctx.ndk_platform
)
env['CONFIG_SHELL'] = '/bin/bash'
env['SHELL'] = '/bin/bash'
env['CC'] += ' -I' + self.get_build_dir(arch.arch)
return env


Expand Down

0 comments on commit 6ed40d5

Please sign in to comment.