From cac3ffc7d7fb34bc05603571d2c2da099efeed6b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Apr 2023 14:22:59 +0800 Subject: [PATCH] add event support --- config/ext.json | 14 +++++++++ config/lib.json | 12 ++++++++ config/source.json | 26 +++++++++++------ src/SPC/builder/extension/event.php | 26 +++++++++++++++++ src/SPC/builder/linux/library/libevent.php | 12 ++++++++ src/SPC/builder/macos/library/libevent.php | 12 ++++++++ src/SPC/builder/unix/library/libevent.php | 33 ++++++++++++++++++++++ src/SPC/store/SourcePatcher.php | 4 +++ 8 files changed, 131 insertions(+), 8 deletions(-) create mode 100644 src/SPC/builder/extension/event.php create mode 100644 src/SPC/builder/linux/library/libevent.php create mode 100644 src/SPC/builder/macos/library/libevent.php create mode 100644 src/SPC/builder/unix/library/libevent.php diff --git a/config/ext.json b/config/ext.json index a48c8542..1ef704a2 100644 --- a/config/ext.json +++ b/config/ext.json @@ -35,6 +35,20 @@ "zlib" ] }, + "event": { + "type": "external", + "source": "ext-event", + "arg-type": "custom", + "lib-depends": [ + "libevent" + ], + "ext-depends": [ + "openssl" + ], + "ext-suggests": [ + "sockets" + ] + }, "exif": { "type": "builtin" }, diff --git a/config/lib.json b/config/lib.json index 3f5d3a0b..e79a1036 100644 --- a/config/lib.json +++ b/config/lib.json @@ -102,6 +102,18 @@ "libavif.a" ] }, + "libevent": { + "source": "libevent", + "static-libs-unix": [ + "libevent.a", + "libevent_core.a", + "libevent_extra.a", + "libevent_openssl.a" + ], + "lib-depends": [ + "openssl" + ] + }, "libffi": { "source": "libffi", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 481bfc85..86eeaf86 100644 --- a/config/source.json +++ b/config/source.json @@ -32,6 +32,15 @@ "path": "COPYING" } }, + "ext-event": { + "type": "url", + "url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz", + "path": "php-src/ext/event", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-zstd": { "type": "git", "path": "php-src/ext/zstd", @@ -78,6 +87,15 @@ "path": "LICENSE" } }, + "libevent": { + "type": "ghrel", + "repo": "libevent/libevent", + "match": "libevent.+\\.tar\\.gz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "libffi": { "type": "ghrel", "repo": "libffi/libffi", @@ -139,14 +157,6 @@ "path": "COPYING" } }, - "libuv": { - "type": "ghtar", - "repo": "libuv/libuv", - "license": { - "type": "file", - "path": "LICENSE" - } - }, "libwebp": { "type": "ghtagtar", "repo": "webmproject/libwebp", diff --git a/src/SPC/builder/extension/event.php b/src/SPC/builder/extension/event.php new file mode 100644 index 00000000..bee7553c --- /dev/null +++ b/src/SPC/builder/extension/event.php @@ -0,0 +1,26 @@ +builder->getLib('openssl')) { + $arg .= ' --with-event-openssl=' . BUILD_ROOT_PATH; + } + if ($this->builder->getExt('sockets')) { + $arg .= ' --enable-event-sockets'; + } else { + $arg .= ' --disable-event-sockets'; + } + return $arg; + } +} diff --git a/src/SPC/builder/linux/library/libevent.php b/src/SPC/builder/linux/library/libevent.php new file mode 100644 index 00000000..19a0925f --- /dev/null +++ b/src/SPC/builder/linux/library/libevent.php @@ -0,0 +1,12 @@ +source_dir . '/build'); + // Start build + shell()->cd($this->source_dir . '/build') + ->exec( + "{$this->builder->configure_env} cmake " . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DEVENT__LIBRARY_TYPE=STATIC ' . + '-DEVENT__DISABLE_BENCHMARK=ON ' . + '-DEVENT__DISABLE_THREAD_SUPPORT=ON ' . + '-DEVENT__DISABLE_TESTS=ON ' . + '-DEVENT__DISABLE_SAMPLES=ON ' . + '..' + ) + ->exec("cmake --build . -j {$this->builder->concurrency}") + ->exec('make install'); + // patch pkgconfig + } +} diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index e47ecd77..42698e81 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -79,6 +79,9 @@ class SourcePatcher if ($pdo_sqlite = $builder->getExt('pdo_sqlite')) { $patch[] = ['pdo_sqlite linking', '/sqlite3_column_table_name=yes/', 'sqlite3_column_table_name=no']; } + if ($event = $builder->getExt('event')) { + $patch[] = ['event check', '/-levent_openssl/', $event->getLibFilesString()]; + } $patch[] = ['disable capstone', '/have_capstone="yes"/', 'have_capstone="no"']; foreach ($patch as $item) { logger()->info('Patching configure: ' . $item[0]); @@ -208,5 +211,6 @@ class SourcePatcher FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_STRLCPY 1$/m', ''); FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_STRLCAT 1$/m', ''); } + FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_OPENPTY 1$/m', ''); } }