|
1 |
| -import os |
2 |
| -import sh |
3 | 1 | from os.path import join
|
4 |
| -from pythonforandroid.recipe import CompiledComponentsPythonRecipe |
5 |
| -from pythonforandroid.toolchain import shprint, info |
| 2 | +from pythonforandroid.recipe import CppCompiledComponentsPythonRecipe |
6 | 3 |
|
7 | 4 |
|
8 |
| -class PyICURecipe(CompiledComponentsPythonRecipe): |
| 5 | +class PyICURecipe(CppCompiledComponentsPythonRecipe): |
9 | 6 | version = '1.9.2'
|
10 |
| - url = 'https://pypi.python.org/packages/source/P/PyICU/PyICU-{version}.tar.gz' |
| 7 | + url = ('https://pypi.python.org/packages/source/P/PyICU/' |
| 8 | + 'PyICU-{version}.tar.gz') |
11 | 9 | depends = ["icu"]
|
12 |
| - patches = ['locale.patch', 'icu.patch'] |
| 10 | + patches = ['locale.patch'] |
13 | 11 |
|
14 | 12 | def get_recipe_env(self, arch):
|
15 | 13 | env = super(PyICURecipe, self).get_recipe_env(arch)
|
16 | 14 |
|
17 | 15 | icu_include = join(
|
18 | 16 | self.ctx.get_python_install_dir(), "include", "icu")
|
19 | 17 |
|
20 |
| - env["CC"] += " -I"+icu_include |
21 |
| - |
22 |
| - include = ( |
23 |
| - " -I{ndk}/sources/cxx-stl/gnu-libstdc++/{version}/include/" |
24 |
| - " -I{ndk}/sources/cxx-stl/gnu-libstdc++/{version}/libs/" |
25 |
| - "{arch}/include") |
26 |
| - include = include.format(ndk=self.ctx.ndk_dir, |
27 |
| - version=env["TOOLCHAIN_VERSION"], |
28 |
| - arch=arch.arch) |
29 |
| - env["CC"] += include |
30 |
| - |
31 |
| - lib = "{ndk}/sources/cxx-stl/gnu-libstdc++/{version}/libs/{arch}" |
32 |
| - lib = lib.format(ndk=self.ctx.ndk_dir, |
33 |
| - version=env["TOOLCHAIN_VERSION"], |
34 |
| - arch=arch.arch) |
35 |
| - env["LDFLAGS"] += " -lgnustl_shared -L"+lib |
36 |
| - |
37 |
| - build_dir = self.get_build_dir(arch.arch) |
38 |
| - env["LDFLAGS"] += " -L"+build_dir |
39 |
| - return env |
40 |
| - |
41 |
| - def build_arch(self, arch): |
42 |
| - build_dir = self.get_build_dir(arch.arch) |
43 |
| - |
44 |
| - info("create links to icu libs") |
45 |
| - lib_dir = join(self.ctx.get_python_install_dir(), "lib") |
46 |
| - icu_libs = [f for f in os.listdir(lib_dir) if f.startswith("libicu")] |
| 18 | + icu_recipe = self.get_recipe('icu', self.ctx) |
| 19 | + icu_link_libs = icu_recipe.built_libraries.keys() |
| 20 | + env["PYICU_LIBRARIES"] = ":".join(lib[3:-3] for lib in icu_link_libs) |
| 21 | + env["CPPFLAGS"] += " -I" + icu_include |
| 22 | + env["LDFLAGS"] += " -L" + join( |
| 23 | + icu_recipe.get_build_dir(arch.arch), "icu_build", "lib" |
| 24 | + ) |
47 | 25 |
|
48 |
| - for l in icu_libs: |
49 |
| - raw = l.rsplit(".", 1)[0] |
50 |
| - try: |
51 |
| - shprint(sh.ln, "-s", join(lib_dir, l), join(build_dir, raw)) |
52 |
| - except Exception: |
53 |
| - pass |
54 |
| - |
55 |
| - super(PyICURecipe, self).build_arch(arch) |
| 26 | + return env |
56 | 27 |
|
57 | 28 |
|
58 | 29 | recipe = PyICURecipe()
|
0 commit comments