|
1 | | -import glob |
2 | | -from logging import info |
| 1 | +from pythonforandroid.recipe import PyProjectRecipe, Recipe |
3 | 2 |
|
4 | | -import sh |
5 | | -from pythonforandroid.logger import shprint |
6 | | -from pythonforandroid.recipe import CppCompiledComponentsPythonRecipe |
7 | | -from pythonforandroid.util import current_directory |
8 | 3 |
|
9 | | - |
10 | | -class GrpcioRecipe(CppCompiledComponentsPythonRecipe): |
| 4 | +class GrpcioRecipe(PyProjectRecipe): |
11 | 5 | version = '1.64.0' |
12 | 6 | url = 'https://files.pythonhosted.org/packages/source/g/grpcio/grpcio-{version}.tar.gz' |
13 | 7 | depends = ["setuptools", "librt", "libpthread"] |
14 | 8 | patches = ["comment-getserverbyport-r-args.patch", "remove-android-log-write.patch"] |
15 | 9 |
|
16 | 10 | def get_recipe_env(self, arch, **kwargs): |
17 | 11 | env = super().get_recipe_env(arch, **kwargs) |
18 | | - env['NDKPLATFORM'] = "NOTNONE" |
19 | | - env['GRPC_PYTHON_BUILD_WITH_CYTHON'] = '1' |
| 12 | + env["NDKPLATFORM"] = "NOTNONE" |
| 13 | + env["GRPC_PYTHON_BUILD_SYSTEM_OPENSSL"] = "1" |
| 14 | + env["GRPC_PYTHON_BUILD_SYSTEM_ZLIB"] = "1" |
| 15 | + env["ZLIB_INCLUDE"] = self.ctx.ndk.sysroot_include_dir |
| 16 | + # replace -I with a space |
| 17 | + openssl_recipe = Recipe.get_recipe('openssl', self.ctx) |
| 18 | + env["SSL_INCLUDE"] = openssl_recipe.include_flags(arch).strip().replace("-I", "") |
20 | 19 | env["CFLAGS"] += " -U__ANDROID_API__" |
21 | 20 | env["CFLAGS"] += " -D__ANDROID_API__={}".format(self.ctx.ndk_api) |
22 | | - |
23 | 21 | # turn off c++11 warning error of "invalid suffix on literal" |
24 | 22 | env["CFLAGS"] += " -Wno-reserved-user-defined-literal" |
25 | | - env['PLATFORM'] = 'android' |
| 23 | + env["PLATFORM"] = "android" |
26 | 24 | env["LDFLAGS"] += " -llog -landroid" |
27 | 25 | return env |
28 | 26 |
|
29 | | - def build_compiled_components(self, arch): |
30 | | - info('Building compiled components in {}'.format(self.name)) |
31 | | - |
32 | | - env = self.get_recipe_env(arch) |
33 | | - hostpython = sh.Command(self.hostpython_location) |
34 | | - with current_directory(self.get_build_dir(arch.arch)): |
35 | | - if self.install_in_hostpython: |
36 | | - shprint(hostpython, 'setup.py', 'clean', '--all', _env=env) |
37 | | - shprint(hostpython, 'setup.py', self.build_cmd, '-v', |
38 | | - _env=env, *self.setup_extra_args) |
39 | | - |
40 | | - # grpcio creates a build directory and names it `pyb` |
41 | | - build_dir = glob.glob('pyb/lib.*')[0] |
42 | | - shprint(sh.find, build_dir, '-name', '"*.o"', '-exec', |
43 | | - env['STRIP'], '{}', ';', _env=env) |
44 | | - |
45 | 27 |
|
46 | 28 | recipe = GrpcioRecipe() |
0 commit comments