2023-04-15 18:45:11 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
2023-08-20 19:51:45 +08:00
|
|
|
use SPC\exception\RuntimeException;
|
2023-04-15 18:45:11 +08:00
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('swow')]
|
|
|
|
|
class swow extends Extension
|
|
|
|
|
{
|
2024-05-21 14:56:54 +08:00
|
|
|
public function validate(): void
|
|
|
|
|
{
|
|
|
|
|
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
|
|
|
|
|
throw new RuntimeException('The latest swow extension requires PHP 8.0 or later');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-30 00:55:43 +08:00
|
|
|
public function getConfigureArg(): string
|
2023-04-15 18:45:11 +08:00
|
|
|
{
|
|
|
|
|
$arg = '--enable-swow';
|
|
|
|
|
$arg .= $this->builder->getLib('openssl') ? ' --enable-swow-ssl' : ' --disable-swow-ssl';
|
|
|
|
|
$arg .= $this->builder->getLib('curl') ? ' --enable-swow-curl' : ' --disable-swow-curl';
|
|
|
|
|
return $arg;
|
|
|
|
|
}
|
2023-07-28 23:47:22 +08:00
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
2023-07-28 23:47:22 +08:00
|
|
|
public function patchBeforeBuildconf(): bool
|
|
|
|
|
{
|
2023-09-30 08:56:37 +02:00
|
|
|
if ($this->builder->getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) {
|
2023-07-28 23:47:22 +08:00
|
|
|
if (PHP_OS_FAMILY === 'Windows') {
|
|
|
|
|
f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && mklink /D swow swow-src\ext');
|
|
|
|
|
} else {
|
|
|
|
|
f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && ln -s swow-src/ext swow');
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-04-15 18:45:11 +08:00
|
|
|
}
|