Skip to content

Commit

Permalink
Added --with-nghttp2-dir compile option
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Mar 17, 2023
1 parent 41fd3b2 commit 2a1c757
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
42 changes: 26 additions & 16 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ PHP_ARG_WITH([brotli_dir],
[AS_HELP_STRING([[--with-brotli-dir[=DIR]]],
[Include Brotli support])], [no], [no])

PHP_ARG_WITH([nghttp2_dir],
[dir of nghttp2],
[AS_HELP_STRING([[--with-nghttp2-dir[=DIR]]],
[Include nghttp2 support])], [no], [no])

PHP_ARG_WITH([jemalloc_dir],
[dir of jemalloc],
[AS_HELP_STRING([[--with-jemalloc-dir[=DIR]]],
Expand Down Expand Up @@ -478,7 +483,7 @@ EOF
AC_DEFINE(SW_HAVE_ZLIB, 1, [have zlib])
PHP_ADD_LIBRARY(z, 1, SWOOLE_SHARED_LIBADD)
])

if test "$PHP_BROTLI" = "yes"; then
AC_CHECK_LIB(brotlienc, BrotliEncoderCreateInstance, [
AC_CHECK_LIB(brotlidec, BrotliDecoderCreateInstance, [
Expand Down Expand Up @@ -577,20 +582,23 @@ EOF
PHP_ADD_LIBRARY(ssl, 1, SWOOLE_SHARED_LIBADD)
PHP_ADD_LIBRARY(crypto, 1, SWOOLE_SHARED_LIBADD)
fi

if test "$PHP_BROTLI_DIR" != "no"; then
AC_DEFINE(SW_HAVE_BROTLI, 1, [have brotli encoder])
PHP_ADD_INCLUDE("${PHP_BROTLI_DIR}/include")
PHP_ADD_LIBRARY_WITH_PATH(brotli, "${PHP_BROTLI_DIR}/${PHP_LIBDIR}")
fi

if test "$PHP_BROTLI_DIR" != "no"; then
AC_DEFINE(SW_HAVE_COMPRESSION, 1, [have compression])
AC_DEFINE(SW_HAVE_BROTLI, 1, [have brotli encoder])
PHP_ADD_INCLUDE("${PHP_BROTLI_DIR}/include")
PHP_ADD_LIBRARY_WITH_PATH(brotli, "${PHP_BROTLI_DIR}/${PHP_LIBDIR}")
PHP_ADD_LIBRARY_WITH_PATH(brotlienc, "${PHP_BROTLI_DIR}/${PHP_LIBDIR}")
PHP_ADD_LIBRARY_WITH_PATH(brotlidec, "${PHP_BROTLI_DIR}/${PHP_LIBDIR}")
fi

if test "$PHP_NGHTTP2_DIR" != "no"; then
AC_DEFINE(SW_USE_SYSTEM_LIBNGHTTP2, 1, [Use the system libnghttp2])
PHP_ADD_INCLUDE("${PHP_NGHTTP2_DIR}/include")

This comment has been minimized.

Copy link
@remicollet

remicollet Apr 26, 2023

Contributor

This won't work as ext-src/php_swoole_http.h use #include "thirdparty/nghttp2/nghttp2.h", so system headers won't be used.

Please see pr #5038

PHP_ADD_LIBRARY_WITH_PATH(nghttp2, "${PHP_NGHTTP2_DIR}/${PHP_LIBDIR}")
PHP_ADD_LIBRARY(nghttp2, 1, SWOOLE_SHARED_LIBADD)
fi

if test "$PHP_JEMALLOC_DIR" != "no"; then
AC_DEFINE(SW_USE_JEMALLOC, 1, [use jemalloc])
PHP_ADD_INCLUDE("${PHP_JEMALLOC_DIR}/include")
Expand Down Expand Up @@ -735,14 +743,17 @@ EOF
thirdparty/hiredis/read.c \
thirdparty/hiredis/sds.c"

swoole_source_file="$swoole_source_file \
thirdparty/nghttp2/nghttp2_hd.c \
thirdparty/nghttp2/nghttp2_rcbuf.c \
thirdparty/nghttp2/nghttp2_helper.c \
thirdparty/nghttp2/nghttp2_buf.c \
thirdparty/nghttp2/nghttp2_mem.c \
thirdparty/nghttp2/nghttp2_hd_huffman.c \
thirdparty/nghttp2/nghttp2_hd_huffman_data.c"
if test "$PHP_NGHTTP2_DIR" = "no"; then
swoole_source_file="$swoole_source_file \
thirdparty/nghttp2/nghttp2_hd.c \
thirdparty/nghttp2/nghttp2_rcbuf.c \
thirdparty/nghttp2/nghttp2_helper.c \
thirdparty/nghttp2/nghttp2_buf.c \
thirdparty/nghttp2/nghttp2_mem.c \
thirdparty/nghttp2/nghttp2_hd_huffman.c \
thirdparty/nghttp2/nghttp2_hd_huffman_data.c"
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/nghttp2)
fi

SW_ASM_DIR="thirdparty/boost/asm/"
SW_USE_ASM_CONTEXT="yes"
Expand Down Expand Up @@ -887,7 +898,6 @@ EOF
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/boost)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/boost/asm)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/hiredis)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/nghttp2)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php/sockets)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php/standard)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php/curl)
Expand Down
1 change: 0 additions & 1 deletion src/core/base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ static void bug_report_message_init() {

#ifdef SW_USE_OPENSSL
SwooleG.bug_report_message += swoole_ssl_get_version_message();

#endif
}

Expand Down
4 changes: 2 additions & 2 deletions tests/swoole_http2_server/nghttp2_big_data.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (strpos(`nghttp --version 2>&1`, 'nghttp2') === false) {
require __DIR__ . '/../include/bootstrap.php';
$pm = new ProcessManager;
$pm->parentFunc = function ($pid) use ($pm) {
$file = __DIR__ . '/../../benchmark/post.big.data';
$file = TEST_IMAGE;
if (Assert::assert(!empty($res = `nghttp -d {$file} https://127.0.0.1:{$pm->getFreePort()}/ > /dev/stdout 2>/dev/null`))) {
Assert::same(md5($res), md5_file($file));
}
Expand All @@ -31,7 +31,7 @@ $pm->childFunc = function () use ($pm) {
$pm->wakeup();
});
$http->on("request", function (Swoole\Http\Request $request, Swoole\Http\Response $response) {
$response->end($request->rawcontent());
$response->end($request->getContent());
});
$http->start();
};
Expand Down

0 comments on commit 2a1c757

Please sign in to comment.