|
| 1 | +from pythonforandroid.recipe import PyProjectRecipe, Recipe |
| 2 | + |
| 3 | + |
| 4 | +class GrpcioRecipe(PyProjectRecipe): |
| 5 | + version = '1.64.0' |
| 6 | + url = 'https://files.pythonhosted.org/packages/source/g/grpcio/grpcio-{version}.tar.gz' |
| 7 | + depends = ["setuptools", "librt", "libpthread"] |
| 8 | + patches = [ |
| 9 | + "comment-getserverbyport-r-args.patch", |
| 10 | + "remove-android-log-write.patch", |
| 11 | + "use-ndk-zlib-and-openssl-recipe-include.patch" |
| 12 | + ] |
| 13 | + |
| 14 | + def get_recipe_env(self, arch, **kwargs): |
| 15 | + env = super().get_recipe_env(arch, **kwargs) |
| 16 | + env["NDKPLATFORM"] = "NOTNONE" |
| 17 | + env["GRPC_PYTHON_BUILD_SYSTEM_OPENSSL"] = "1" |
| 18 | + env["GRPC_PYTHON_BUILD_SYSTEM_ZLIB"] = "1" |
| 19 | + env["ZLIB_INCLUDE"] = self.ctx.ndk.sysroot_include_dir |
| 20 | + # replace -I with a space |
| 21 | + openssl_recipe = Recipe.get_recipe('openssl', self.ctx) |
| 22 | + env["SSL_INCLUDE"] = openssl_recipe.include_flags(arch).strip().replace("-I", "") |
| 23 | + env["CFLAGS"] += " -U__ANDROID_API__" |
| 24 | + env["CFLAGS"] += " -D__ANDROID_API__={}".format(self.ctx.ndk_api) |
| 25 | + # turn off c++11 warning error of "invalid suffix on literal" |
| 26 | + env["CFLAGS"] += " -Wno-reserved-user-defined-literal" |
| 27 | + env["PLATFORM"] = "android" |
| 28 | + env["LDFLAGS"] += " -llog -landroid" |
| 29 | + env["LDFLAGS"] += openssl_recipe.link_flags(arch) |
| 30 | + return env |
| 31 | + |
| 32 | + |
| 33 | +recipe = GrpcioRecipe() |
0 commit comments