|
1 |
| -from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory |
| 1 | +from pythonforandroid.recipe import Recipe |
| 2 | +from pythonforandroid.toolchain import shprint, shutil, current_directory |
2 | 3 | from os.path import exists, join
|
3 | 4 | import sh
|
4 | 5 |
|
5 | 6 |
|
6 | 7 | class LibxsltRecipe(Recipe):
|
7 |
| - version = "1.1.28" |
8 |
| - url = "http://xmlsoft.org/sources/libxslt-{version}.tar.gz" |
9 |
| - depends = ["libxml2"] |
10 |
| - patches = ["fix-dlopen.patch"] |
| 8 | + version = '1.1.32' |
| 9 | + url = 'http://xmlsoft.org/sources/libxslt-{version}.tar.gz' |
| 10 | + depends = ['libxml2'] |
| 11 | + patches = ['fix-dlopen.patch'] |
11 | 12 |
|
12 | 13 | call_hostpython_via_targetpython = False
|
13 | 14 |
|
14 | 15 | def should_build(self, arch):
|
15 |
| - super(LibxsltRecipe, self).should_build(arch) |
16 |
| - return not exists(join(self.ctx.get_libs_dir(arch.arch), "libxslt.a")) |
| 16 | + return not exists( |
| 17 | + join(self.get_build_dir(arch.arch), |
| 18 | + 'libxslt', '.libs', 'libxslt.a')) |
17 | 19 |
|
18 | 20 | def build_arch(self, arch):
|
19 | 21 | super(LibxsltRecipe, self).build_arch(arch)
|
20 | 22 | env = self.get_recipe_env(arch)
|
21 |
| - with current_directory(self.get_build_dir(arch.arch)): |
| 23 | + build_dir = self.get_build_dir(arch.arch) |
| 24 | + with current_directory(build_dir): |
22 | 25 | # If the build is done with /bin/sh things blow up,
|
23 | 26 | # try really hard to use bash
|
24 |
| - env["CC"] += " -I%s" % self.get_build_dir(arch.arch) |
25 |
| - libxml = Recipe.get_recipe( |
26 |
| - 'libxml2', self.ctx).get_build_dir(arch.arch) |
27 |
| - shprint( |
28 |
| - sh.Command("./configure"), |
29 |
| - "--build=i686-pc-linux-gnu", |
30 |
| - "--host=arm-linux-eabi", |
31 |
| - "--without-plugins", |
32 |
| - "--without-debug", |
33 |
| - "--without-python", |
34 |
| - "--without-crypto", |
35 |
| - "--with-libxml-src=%s" % libxml, |
36 |
| - _env=env, |
37 |
| - ) |
| 27 | + libxml2_recipe = Recipe.get_recipe('libxml2', self.ctx) |
| 28 | + libxml2_build_dir = libxml2_recipe.get_build_dir(arch.arch) |
| 29 | + build_arch = shprint(sh.gcc, '-dumpmachine').stdout.decode( |
| 30 | + 'utf-8').split('\n')[0] |
| 31 | + |
| 32 | + if not exists('configure'): |
| 33 | + shprint(sh.Command('./autogen.sh'), _env=env) |
| 34 | + shprint(sh.Command('autoreconf'), '-vif', _env=env) |
| 35 | + shprint(sh.Command('./configure'), |
| 36 | + '--build=' + build_arch, |
| 37 | + '--host=' + arch.command_prefix, |
| 38 | + '--target=' + arch.command_prefix, |
| 39 | + '--without-plugins', |
| 40 | + '--without-debug', |
| 41 | + '--without-python', |
| 42 | + '--without-crypto', |
| 43 | + '--with-libxml-src=' + libxml2_build_dir, |
| 44 | + '--disable-shared', |
| 45 | + _env=env) |
38 | 46 | shprint(sh.make, "V=1", _env=env)
|
39 |
| - shutil.copyfile( |
40 |
| - "libxslt/.libs/libxslt.a", |
41 |
| - join(self.ctx.get_libs_dir(arch.arch), "libxslt.a"), |
42 |
| - ) |
43 |
| - shutil.copyfile( |
44 |
| - "libexslt/.libs/libexslt.a", |
45 |
| - join(self.ctx.get_libs_dir(arch.arch), "libexslt.a"), |
46 |
| - ) |
| 47 | + |
| 48 | + shutil.copyfile('libxslt/.libs/libxslt.a', |
| 49 | + join(self.ctx.libs_dir, 'libxslt.a')) |
| 50 | + shutil.copyfile('libexslt/.libs/libexslt.a', |
| 51 | + join(self.ctx.libs_dir, 'libexslt.a')) |
47 | 52 |
|
48 | 53 | def get_recipe_env(self, arch):
|
49 | 54 | env = super(LibxsltRecipe, self).get_recipe_env(arch)
|
50 |
| - env["CONFIG_SHELL"] = "/bin/bash" |
51 |
| - env["SHELL"] = "/bin/bash" |
52 |
| - env[ |
53 |
| - "CC" |
54 |
| - ] = "arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot={}".format( |
55 |
| - self.ctx.ndk_platform |
56 |
| - ) |
57 |
| - |
58 |
| - env["LDSHARED"] = "%s -nostartfiles -shared -fPIC" % env["CC"] |
| 55 | + env['CONFIG_SHELL'] = '/bin/bash' |
| 56 | + env['SHELL'] = '/bin/bash' |
| 57 | + |
| 58 | + libxml2_recipe = Recipe.get_recipe('libxml2', self.ctx) |
| 59 | + libxml2_build_dir = libxml2_recipe.get_build_dir(arch.arch) |
| 60 | + libxml2_libs_dir = join(libxml2_build_dir, '.libs') |
| 61 | + |
| 62 | + env['CFLAGS'] = ' '.join([ |
| 63 | + env['CFLAGS'], |
| 64 | + '-I' + libxml2_build_dir, |
| 65 | + '-I' + join(libxml2_build_dir, 'include', 'libxml'), |
| 66 | + '-I' + self.get_build_dir(arch.arch), |
| 67 | + ]) |
| 68 | + env['LDFLAGS'] += ' -L' + libxml2_libs_dir |
| 69 | + env['LIBS'] = '-lxml2 -lz -lm' |
| 70 | + |
59 | 71 | return env
|
60 | 72 |
|
61 | 73 |
|
|
0 commit comments