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;
|
2024-12-05 10:30:38 +08:00
|
|
|
use SPC\exception\RuntimeException;
|
|
|
|
|
use SPC\exception\WrongUsageException;
|
2023-07-28 23:47:22 +08:00
|
|
|
use SPC\store\FileSystem;
|
|
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('pgsql')]
|
|
|
|
|
class pgsql extends Extension
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
2024-12-05 10:30:38 +08:00
|
|
|
* @throws RuntimeException
|
|
|
|
|
* @throws WrongUsageException
|
2023-07-28 23:47:22 +08:00
|
|
|
*/
|
|
|
|
|
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',
|
|
|
|
|
'/-lpq/',
|
|
|
|
|
$this->getLibFilesString()
|
|
|
|
|
);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2024-12-05 10:30:38 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws WrongUsageException
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
|
|
|
|
public function getUnixConfigureArg(): string
|
|
|
|
|
{
|
|
|
|
|
if ($this->builder->getPHPVersionID() >= 80400) {
|
2024-12-09 21:38:28 +08:00
|
|
|
return '--with-pgsql PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon"';
|
2024-12-05 10:30:38 +08:00
|
|
|
}
|
|
|
|
|
return '--with-pgsql=' . BUILD_ROOT_PATH;
|
|
|
|
|
}
|
2025-03-24 05:47:00 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws WrongUsageException
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
|
|
|
|
public function getWindowsConfigureArg(): string
|
|
|
|
|
{
|
|
|
|
|
if ($this->builder->getPHPVersionID() >= 80400) {
|
|
|
|
|
return '--with-pgsql';
|
|
|
|
|
}
|
|
|
|
|
return '--with-pgsql=' . BUILD_ROOT_PATH;
|
|
|
|
|
}
|
2023-07-28 23:47:22 +08:00
|
|
|
}
|