Add ext-event

This commit is contained in:
crazywhalecc 2026-03-09 14:45:36 +08:00
parent 8cc5877f3c
commit a678d908d5
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,19 @@
ext-event:
type: php-extension
artifact:
source:
type: url
url: 'https://bitbucket.org/osmanov/pecl-event/get/3.1.4.tar.gz'
extract: php-src/ext/event
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- libevent
- ext-openssl
suggests:
- ext-sockets
php-extension:
support:
Windows: wip
arg-type: custom

View File

@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
#[Extension('event')]
class event extends PhpExtensionPackage
{
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(PackageInstaller $installer): string
{
$arg = "--with-event-core --with-event-extra --with-event-libevent-dir={$this->getBuilder()->getBuildRootPath()}";
if ($installer->getLibraryPackage('openssl')) {
$arg .= " --with-event-openssl={$this->getBuilder()->getBuildRootPath()}";
}
if ($installer->getPhpExtensionPackage('ext-sockets')) {
$arg .= ' --enable-event-sockets';
} else {
$arg .= ' --disable-event-sockets';
}
return $arg;
}
#[BeforeStage('php', [php::class, 'makeForUnix'], 'ext-event')]
#[PatchDescription('Prevent event extension compile error on macOS')]
public function patchBeforeMake(PackageInstaller $installer): void
{
// Prevent event extension compile error on macOS
if (SystemTarget::getTargetOS() === 'Darwin') {
$php_src = $installer->getTargetPackage('php')->getSourceDir();
FileSystem::replaceFileRegex("{$php_src}/main/php_config.h", '/^#define HAVE_OPENPTY 1$/m', '');
}
}
}