2023-04-15 18:45:11 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
2023-11-05 17:48:20 +08:00
|
|
|
use SPC\exception\RuntimeException;
|
2023-04-15 18:45:11 +08:00
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('mbregex')]
|
|
|
|
|
class mbregex extends Extension
|
|
|
|
|
{
|
2024-02-04 15:28:09 +08:00
|
|
|
public function getDistName(): string
|
|
|
|
|
{
|
|
|
|
|
return 'mbstring';
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:48:20 +08:00
|
|
|
public function getConfigureArg(): string
|
2023-04-15 18:45:11 +08:00
|
|
|
{
|
2023-11-05 17:48:20 +08:00
|
|
|
return '';
|
2023-04-15 18:45:11 +08:00
|
|
|
}
|
2023-07-27 18:46:37 +08:00
|
|
|
|
2023-11-05 17:48:20 +08:00
|
|
|
/**
|
|
|
|
|
* mbregex is not an extension, we need to overwrite the default check.
|
|
|
|
|
*/
|
2024-01-10 21:08:25 +08:00
|
|
|
public function runCliCheckUnix(): void
|
2023-07-27 18:46:37 +08:00
|
|
|
{
|
2025-02-16 02:30:08 +09:00
|
|
|
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "mbstring" | grep regex', false);
|
2023-11-05 17:48:20 +08:00
|
|
|
if ($ret !== 0) {
|
|
|
|
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
|
|
|
|
|
}
|
2023-07-27 18:46:37 +08:00
|
|
|
}
|
2024-02-23 11:41:35 +08:00
|
|
|
|
|
|
|
|
public function runCliCheckWindows(): void
|
|
|
|
|
{
|
2025-02-06 23:59:02 +09:00
|
|
|
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "mbstring"', false);
|
2024-02-23 11:41:35 +08:00
|
|
|
if ($ret !== 0) {
|
|
|
|
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !');
|
|
|
|
|
}
|
|
|
|
|
$out = implode("\n", $out);
|
|
|
|
|
if (!str_contains($out, 'regex')) {
|
|
|
|
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-15 18:45:11 +08:00
|
|
|
}
|