add event support

This commit is contained in:
crazywhalecc 2023-04-30 14:22:59 +08:00
parent 893fa5bfd6
commit cac3ffc7d7
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
8 changed files with 131 additions and 8 deletions

View File

@ -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"
},

View File

@ -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": [

View File

@ -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",

View File

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('event')]
class event extends Extension
{
public function getUnixConfigureArg(): string
{
$arg = '--with-event-core --with-event-extra --with-event-libevent-dir=' . BUILD_ROOT_PATH;
if ($this->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;
}
}

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libevent extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libevent;
public const NAME = 'libevent';
}

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class libevent extends MacOSLibraryBase
{
use \SPC\builder\unix\library\libevent;
public const NAME = 'libevent';
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\store\FileSystem;
trait libevent
{
protected function build()
{
// CMake needs a clean build directory
FileSystem::resetDir($this->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
}
}

View File

@ -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', '');
}
}