2023-07-28 23:47:22 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
|
|
|
|
use SPC\exception\FileSystemException;
|
|
|
|
|
use SPC\store\FileSystem;
|
|
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('readline')]
|
|
|
|
|
class readline extends Extension
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
*/
|
|
|
|
|
public function patchBeforeConfigure(): bool
|
|
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
FileSystem::replaceFileRegex(
|
2023-07-28 23:47:22 +08:00
|
|
|
SOURCE_PATH . '/php-src/configure',
|
|
|
|
|
'/-lncurses/',
|
|
|
|
|
$this->getLibFilesString()
|
|
|
|
|
);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2025-05-20 08:24:28 +07:00
|
|
|
|
|
|
|
|
public function getUnixConfigureArg(bool $shared = false): string
|
|
|
|
|
{
|
2025-05-21 14:29:49 +07:00
|
|
|
return '--without-libedit --with-readline=' . BUILD_ROOT_PATH;
|
2025-05-20 08:24:28 +07:00
|
|
|
}
|
2025-05-20 20:00:37 +07:00
|
|
|
|
|
|
|
|
public function buildUnixShared(): void
|
|
|
|
|
{
|
|
|
|
|
if (!file_exists(BUILD_BIN_PATH . '/php') || !file_exists(BUILD_INCLUDE_PATH . '/php/sapi/cli/cli.h')) {
|
|
|
|
|
logger()->warning('CLI mode is not enabled, skipping readline build');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
parent::buildUnixShared();
|
|
|
|
|
}
|
2023-07-28 23:47:22 +08:00
|
|
|
}
|