• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1%YAML 1.2
2--- |
3  PHP_ARG_ENABLE(grpc, whether to enable grpc support,
4  [  --enable-grpc           Enable grpc support])
5
6  if test "$PHP_GRPC" != "no"; then
7    dnl Write more examples of tests here...
8
9    dnl # --with-grpc -> add include path
10    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include)
11    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/core/ext/upb-generated)
12    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/core/ext/upbdefs-generated)
13    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc)
14    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/abseil-cpp)
15    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/address_sorting/include)
16    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl-with-bazel/src/include)
17    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/re2)
18    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb)
19
20    LIBS="-lpthread $LIBS"
21
22    CFLAGS="-Wall -Werror -Wno-parentheses-equality -Wno-unused-value -std=c11 -g -O2"
23    CXXFLAGS="-std=c++11 -fno-exceptions -fno-rtti -g -O2"
24    GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD"
25    PHP_REQUIRE_CXX()
26    PHP_ADD_LIBRARY(pthread)
27    PHP_ADD_LIBRARY(dl,,GRPC_SHARED_LIBADD)
28    PHP_ADD_LIBRARY(dl)
29
30    case $host in
31      *darwin*)
32        PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD)
33        ;;
34      *)
35        PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD)
36        PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD)
37        PHP_ADD_LIBRARY(rt)
38        ;;
39    esac
40
41    PHP_SUBST(GRPC_SHARED_LIBADD)
42  <%
43    srcs = []
44    srcs.extend(php_config_m4.src)
45    lib_maps = {lib.name: lib for lib in libs}
46    php_deps = php_config_m4.get('deps', [])
47    php_full_deps = []
48    for dep in php_deps:
49      php_full_deps.append(dep)
50      php_full_deps.extend(lib_maps[dep].transitive_deps)
51    for dep in set(php_full_deps) - set({'z'}):
52      srcs.extend(lib_maps[dep].src)
53    srcs = sorted(set(srcs))
54  %>
55    PHP_NEW_EXTENSION(grpc,
56      % for src in srcs:
57      ${src} ${"\\"}
58      % endfor
59      , $ext_shared, , -fvisibility=hidden ${"\\"}
60      -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN ${"\\"}
61      -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DGRPC_ARES=0 ${"\\"}
62      -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1)
63  <%
64    dirs = sorted(set(src[:src.rfind('/')] for src in srcs))
65  %>
66    % for dir in dirs:
67    PHP_ADD_BUILD_DIR($ext_builddir/${dir})
68    % endfor
69  fi
70