mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
fix #19871
This commit is contained in:
parent
896cf889e4
commit
f0c39c1770
@ -7,6 +7,7 @@ namespace SPC\builder\extension;
|
||||
use SPC\builder\Extension;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
#[CustomExt('readline')]
|
||||
class readline extends Extension
|
||||
@ -34,4 +35,32 @@ class readline extends Extension
|
||||
}
|
||||
parent::buildUnixShared();
|
||||
}
|
||||
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
if (SPCTarget::getTargetOS() === 'Linux' && SPCTarget::isStatic() && $this->builder->getOption('build-cli')) {
|
||||
FileSystem::replaceFileStr(
|
||||
SOURCE_PATH . '/php-src/ext/readline/readline_cli.c',
|
||||
"/*\n#ifdef COMPILE_DL_READLINE",
|
||||
"#ifdef COMPILE_DL_READLINE\n/*"
|
||||
);
|
||||
FileSystem::replaceFileRegex(
|
||||
SOURCE_PATH . '/php-src/ext/readline/readline_cli.c',
|
||||
'/\/\*#else\s+?#define GET_SHELL_CB\(cb\) \(cb\) = php_cli_get_shell_callbacks\(\)\s+#endif\*\//s',
|
||||
"#else\n#define GET_SHELL_CB(cb) (cb) = php_cli_get_shell_callbacks()\n#endif"
|
||||
);
|
||||
} else {
|
||||
FileSystem::replaceFileStr(
|
||||
SOURCE_PATH . '/php-src/ext/readline/readline_cli.c',
|
||||
"#ifdef COMPILE_DL_READLINE\n/*",
|
||||
"/*\n#ifdef COMPILE_DL_READLINE"
|
||||
);
|
||||
FileSystem::replaceFileRegex(
|
||||
SOURCE_PATH . '/php-src/ext/readline/readline_cli.c',
|
||||
'/#else\s+?#define GET_SHELL_CB\(cb\) \(cb\) = php_cli_get_shell_callbacks\(\)\s+#endif/s',
|
||||
"/*#else\n#define GET_SHELL_CB(cb) (cb) = php_cli_get_shell_callbacks()\n#endif*/"
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user