-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3023 from kengoon/grpcio-recipe
recipes: add new `grpcio` recipe
- Loading branch information
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from pythonforandroid.recipe import PyProjectRecipe, Recipe | ||
|
||
|
||
class GrpcioRecipe(PyProjectRecipe): | ||
version = '1.64.0' | ||
url = 'https://files.pythonhosted.org/packages/source/g/grpcio/grpcio-{version}.tar.gz' | ||
depends = ["setuptools", "librt", "libpthread"] | ||
patches = [ | ||
"comment-getserverbyport-r-args.patch", | ||
"remove-android-log-write.patch", | ||
"use-ndk-zlib-and-openssl-recipe-include.patch" | ||
] | ||
|
||
def get_recipe_env(self, arch, **kwargs): | ||
env = super().get_recipe_env(arch, **kwargs) | ||
env["NDKPLATFORM"] = "NOTNONE" | ||
env["GRPC_PYTHON_BUILD_SYSTEM_OPENSSL"] = "1" | ||
env["GRPC_PYTHON_BUILD_SYSTEM_ZLIB"] = "1" | ||
env["ZLIB_INCLUDE"] = self.ctx.ndk.sysroot_include_dir | ||
# replace -I with a space | ||
openssl_recipe = Recipe.get_recipe('openssl', self.ctx) | ||
env["SSL_INCLUDE"] = openssl_recipe.include_flags(arch).strip().replace("-I", "") | ||
env["CFLAGS"] += " -U__ANDROID_API__" | ||
env["CFLAGS"] += " -D__ANDROID_API__={}".format(self.ctx.ndk_api) | ||
# turn off c++11 warning error of "invalid suffix on literal" | ||
env["CFLAGS"] += " -Wno-reserved-user-defined-literal" | ||
env["PLATFORM"] = "android" | ||
env["LDFLAGS"] += " -llog -landroid" | ||
env["LDFLAGS"] += openssl_recipe.link_flags(arch) | ||
return env | ||
|
||
|
||
recipe = GrpcioRecipe() |
17 changes: 17 additions & 0 deletions
17
pythonforandroid/recipes/grpcio/comment-getserverbyport-r-args.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Index: ares_config.h | ||
IDEA additional info: | ||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||
<+>UTF-8 | ||
=================================================================== | ||
diff --git a/third_party/cares/config_android/ares_config.h b/third_party/cares/config_android/ares_config.h | ||
--- a/third_party/cares/config_android/ares_config.h | ||
+++ b/third_party/cares/config_android/ares_config.h (date 1716777985227) | ||
@@ -43,7 +43,7 @@ | ||
#define GETNAMEINFO_TYPE_ARG7 int | ||
|
||
/* Specifies the number of arguments to getservbyport_r */ | ||
-#define GETSERVBYPORT_R_ARGS | ||
+//#define GETSERVBYPORT_R_ARGS | ||
|
||
/* Define to 1 if you have AF_INET6. */ | ||
#define HAVE_AF_INET6 |
36 changes: 36 additions & 0 deletions
36
pythonforandroid/recipes/grpcio/remove-android-log-write.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Index: log.cc | ||
IDEA additional info: | ||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||
<+>UTF-8 | ||
=================================================================== | ||
diff --git a/src/core/lib/gpr/android/log.cc b/src/core/lib/gpr/android/log.cc | ||
--- a/src/core/lib/gpr/android/log.cc | ||
+++ b/src/core/lib/gpr/android/log.cc (date 1716778822204) | ||
@@ -30,18 +30,6 @@ | ||
|
||
#include "src/core/lib/gprpp/crash.h" | ||
|
||
-static android_LogPriority severity_to_log_priority(gpr_log_severity severity) { | ||
- switch (severity) { | ||
- case GPR_LOG_SEVERITY_DEBUG: | ||
- return ANDROID_LOG_DEBUG; | ||
- case GPR_LOG_SEVERITY_INFO: | ||
- return ANDROID_LOG_INFO; | ||
- case GPR_LOG_SEVERITY_ERROR: | ||
- return ANDROID_LOG_ERROR; | ||
- } | ||
- return ANDROID_LOG_DEFAULT; | ||
-} | ||
- | ||
void gpr_log(const char* file, int line, gpr_log_severity severity, | ||
const char* format, ...) { | ||
// Avoid message construction if gpr_log_message won't log | ||
@@ -70,8 +58,6 @@ | ||
|
||
asprintf(&output, "%s:%d] %s", display_file, args->line, args->message); | ||
|
||
- __android_log_write(severity_to_log_priority(args->severity), "GRPC", output); | ||
- | ||
// allocated by asprintf => use free, not gpr_free | ||
free(output); | ||
} |
16 changes: 16 additions & 0 deletions
16
pythonforandroid/recipes/grpcio/use-ndk-zlib-and-openssl-recipe-include.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- a/setup.py 2024-05-31 11:20:56.824695569 +0100 | ||
+++ b/setup.py 2024-05-31 23:13:40.324392463 +0100 | ||
@@ -299,11 +299,11 @@ | ||
lambda x: "third_party/boringssl" not in x, CORE_C_FILES | ||
) | ||
CORE_C_FILES = filter(lambda x: "src/boringssl" not in x, CORE_C_FILES) | ||
- SSL_INCLUDE = (os.path.join("/usr", "include", "openssl"),) | ||
+ SSL_INCLUDE = tuple(os.environ["SSL_INCLUDE"].split(" ")) | ||
|
||
if BUILD_WITH_SYSTEM_ZLIB: | ||
CORE_C_FILES = filter(lambda x: "third_party/zlib" not in x, CORE_C_FILES) | ||
- ZLIB_INCLUDE = (os.path.join("/usr", "include"),) | ||
+ ZLIB_INCLUDE = tuple(os.environ["ZLIB_INCLUDE"].split(" ")) | ||
|
||
if BUILD_WITH_SYSTEM_CARES: | ||
CORE_C_FILES = filter(lambda x: "third_party/cares" not in x, CORE_C_FILES) |