Fix pgsql with PHP 8.4 embed missing libs bug

This commit is contained in:
crazywhalecc 2024-12-05 10:30:38 +08:00 committed by Jerry Ma
parent a8a071de1a
commit 05b602d38c
2 changed files with 26 additions and 1 deletions

View File

@ -30,7 +30,7 @@ use Symfony\Component\Console\Application;
*/ */
final class ConsoleApplication extends Application final class ConsoleApplication extends Application
{ {
public const VERSION = '2.4.0'; public const VERSION = '2.4.1';
public function __construct() public function __construct()
{ {

View File

@ -6,6 +6,8 @@ namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\FileSystemException; use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
@ -13,10 +15,21 @@ use SPC\util\CustomExt;
class pgsql extends Extension class pgsql extends Extension
{ {
/** /**
* @return bool
* @throws FileSystemException * @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/ */
public function patchBeforeConfigure(): bool public function patchBeforeConfigure(): bool
{ {
if ($this->builder->getPHPVersionID() >= 80400) {
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/configure',
'LIBS="-lpq',
'LIBS="-lpq -lpgport -lpgcommon'
);
return true;
}
FileSystem::replaceFileRegex( FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/configure', SOURCE_PATH . '/php-src/configure',
'/-lpq/', '/-lpq/',
@ -24,4 +37,16 @@ class pgsql extends Extension
); );
return true; return true;
} }
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function getUnixConfigureArg(): string
{
if ($this->builder->getPHPVersionID() >= 80400) {
return '--with-pgsql=' . BUILD_ROOT_PATH . ' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon"';
}
return '--with-pgsql=' . BUILD_ROOT_PATH;
}
} }