2023-04-30 14:22:59 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
2024-02-14 00:49:58 +08:00
|
|
|
use SPC\builder\macos\MacOSBuilder;
|
2023-07-28 23:47:22 +08:00
|
|
|
use SPC\exception\FileSystemException;
|
|
|
|
|
use SPC\store\FileSystem;
|
2023-04-30 14:22:59 +08:00
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('event')]
|
|
|
|
|
class event extends Extension
|
|
|
|
|
{
|
2025-03-27 11:12:19 +07:00
|
|
|
public function getUnixConfigureArg(bool $shared = false): string
|
2023-04-30 14:22:59 +08:00
|
|
|
{
|
|
|
|
|
$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;
|
|
|
|
|
}
|
2023-07-28 23:47:22 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
*/
|
|
|
|
|
public function patchBeforeConfigure(): bool
|
|
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString());
|
2023-07-28 23:47:22 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
2024-02-14 00:49:58 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
*/
|
|
|
|
|
public function patchBeforeMake(): bool
|
|
|
|
|
{
|
|
|
|
|
// Prevent event extension compile error on macOS
|
|
|
|
|
if ($this->builder instanceof MacOSBuilder) {
|
|
|
|
|
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', '');
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-04-30 14:22:59 +08:00
|
|
|
}
|