mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 21:04:52 +08:00
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?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
|
|
{
|
|
FileSystem::replaceFileRegex(
|
|
SOURCE_PATH . '/php-src/configure',
|
|
'/-lncurses/',
|
|
$this->getLibFilesString()
|
|
);
|
|
return true;
|
|
}
|
|
|
|
public function getUnixConfigureArg(bool $shared = false): string
|
|
{
|
|
return '--without-libedit --with-readline=' . BUILD_ROOT_PATH;
|
|
}
|
|
|
|
public function patchBeforeSharedConfigure(): bool
|
|
{
|
|
FileSystem::replaceFileStr($this->source_dir . '/configure',
|
|
'test "$PHP_LIBEDIT" = "no" && PHP_LIBEDIT=yes',
|
|
''
|
|
);
|
|
return true;
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|