Skip to content

Commit d44d59d

Browse files
authored
Merge pull request #277292 from shyim/php-grpc-use-system-grpc
phpExtensions.grpc: use shared system grpc
2 parents 1ad46a5 + 4be58c5 commit d44d59d

File tree

3 files changed

+116
-6
lines changed

3 files changed

+116
-6
lines changed

pkgs/development/php-packages/grpc/default.nix

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
{ buildPecl
2-
, zlib
2+
, pkg-config
33
, lib
4+
, grpc
45
}:
56

67
buildPecl {
78
pname = "grpc";
8-
version = "1.56.0";
9+
inherit (grpc) version src;
910

10-
sha256 = "sha256-uzxYMUzExMBDtwv3FipOuuUHg0v1wqAUtn69jXAQnf4=";
11+
sourceRoot = "${grpc.src.name}/src/php/ext/grpc";
1112

12-
doCheck = true;
13-
checkTarget = "test";
13+
patches = [
14+
./use-pkgconfig.patch # https://github.com/grpc/grpc/pull/35404
15+
./skip-darwin-test.patch # https://github.com/grpc/grpc/pull/35403
16+
];
17+
18+
nativeBuildInputs = [ pkg-config ];
19+
buildInputs = [ grpc ];
1420

15-
nativeBuildInputs = [ zlib ];
21+
doCheck = true;
1622

1723
meta = {
1824
description = "A high performance, open source, general RPC framework that puts mobile and HTTP/2 first.";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
From b1fa212d0bc29dcc72107ad67fb99d4ef573942a Mon Sep 17 00:00:00 2001
2+
From: Shyim <[email protected]>
3+
Date: Thu, 28 Dec 2023 10:28:21 +0100
4+
Subject: [PATCH] php: skip epoll1 test on darwin
5+
6+
---
7+
tests/grpc-set-ini.phpt | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/tests/grpc-set-ini.phpt b/tests/grpc-set-ini.phpt
11+
index 55c18ee526e24..b39348ea2e685 100644
12+
--- a/tests/grpc-set-ini.phpt
13+
+++ b/tests/grpc-set-ini.phpt
14+
@@ -1,7 +1,7 @@
15+
--TEST--
16+
Ensure ini settings are handled
17+
--SKIPIF--
18+
-<?php if (!extension_loaded("grpc")) print "skip"; ?>
19+
+<?php if (!extension_loaded("grpc") || PHP_OS === "Darwin") print "skip"; ?>
20+
--INI--
21+
grpc.enable_fork_support = 1
22+
grpc.poll_strategy = epoll1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
From 24b4e273bd503760a485e92ca418e4699767ec51 Mon Sep 17 00:00:00 2001
2+
From: Shyim <[email protected]>
3+
Date: Thu, 28 Dec 2023 10:38:42 +0100
4+
Subject: [PATCH] [php]: add with-grpc-dir to configure and add pkg-config
5+
support
6+
7+
---
8+
config.m4 | 48 +++++++++++++++++++++++++-------------
9+
1 file changed, 32 insertions(+), 16 deletions(-)
10+
11+
diff --git a/config.m4 b/config.m4
12+
index 5600df34ccfa3..c2186a41d21f5 100755
13+
--- a/config.m4
14+
+++ b/config.m4
15+
@@ -7,35 +7,51 @@ PHP_ARG_ENABLE(coverage, whether to include code coverage symbols,
16+
PHP_ARG_ENABLE(tests, whether to compile helper methods for tests,
17+
[ --enable-tests Enable tests methods], no, no)
18+
19+
+PHP_ARG_WITH(grpc-dir, for grpc,
20+
+[ --with-grpc-dir[=DIR] Set the path to grpc install prefix.], yes)
21+
+
22+
dnl Check whether to enable tests
23+
if test "$PHP_TESTS" != "no"; then
24+
CPPFLAGS="$CPPFLAGS -DGRPC_PHP_DEBUG"
25+
fi
26+
27+
if test "$PHP_GRPC" != "no"; then
28+
- dnl Write more examples of tests here...
29+
-
30+
- dnl # --with-grpc -> check with-path
31+
- SEARCH_PATH="/usr/local /usr" # you might want to change this
32+
- SEARCH_FOR="include/grpc/grpc.h" # you most likely want to change this
33+
- if test -r $PHP_GRPC/$SEARCH_FOR; then # path given as parameter
34+
- GRPC_DIR=$PHP_GRPC
35+
- else # search default path list
36+
+ AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
37+
+
38+
+ if test "$PHP_GRPC_DIR" = "yes" -a -x $PKG_CONFIG; then
39+
+ AC_MSG_CHECKING([for grpc using pkg-config])
40+
+
41+
+ if ! $PKG_CONFIG --exists grpc ; then
42+
+ AC_MSG_ERROR([grpc not found])
43+
+ fi
44+
+
45+
+ GRPC_VERSION=`$PKG_CONFIG grpc --modversion`
46+
+ AC_MSG_RESULT([found version $GRPC_VERSION])
47+
+
48+
+ PHP_GRPC_LIBS=`$PKG_CONFIG grpc --libs`
49+
+ PHP_GRPC_INCS=`$PKG_CONFIG grpc --cflags`
50+
+
51+
+ PHP_EVAL_LIBLINE($PHP_GRPC_LIBS, AMQP_SHARED_LIBADD)
52+
+ PHP_EVAL_INCLINE($PHP_GRPC_INCS)
53+
+ else
54+
AC_MSG_CHECKING([for grpc files in default path])
55+
+
56+
+ SEARCH_PATH="$PHP_GRPC_DIR /usr/local /usr"
57+
+
58+
for i in $SEARCH_PATH ; do
59+
- if test -r $i/$SEARCH_FOR; then
60+
+ if test -r $i/include/grpc/grpc.h; then
61+
GRPC_DIR=$i
62+
AC_MSG_RESULT(found in $i)
63+
fi
64+
done
65+
- fi
66+
- if test -z "$GRPC_DIR"; then
67+
- AC_MSG_RESULT([not found])
68+
- AC_MSG_ERROR([Please reinstall the grpc distribution])
69+
- fi
70+
71+
- dnl # --with-grpc -> add include path
72+
- PHP_ADD_INCLUDE($GRPC_DIR/include)
73+
+ if test -z "$GRPC_DIR"; then
74+
+ AC_MSG_RESULT([not found])
75+
+ AC_MSG_ERROR([Please reinstall the grpc distribution])
76+
+ fi
77+
+
78+
+ PHP_ADD_INCLUDE($GRPC_DIR/include)
79+
+ fi
80+
81+
LIBS="-lpthread $LIBS"
82+

0 commit comments

Comments
 (0)