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
|
|
|
|
|
*/
|
2025-03-27 11:12:19 +07:00
|
|
|
public function getUnixConfigureArg(bool $shared = false): string
|
2024-12-05 10:30:38 +08:00
|
|
|
{
|
|
|
|
|
if ($this->builder->getPHPVersionID() >= 80400) {
|
2025-05-21 20:03:21 +07:00
|
|
|
$libfiles = $this->getLibFilesString();
|
|
|
|
|
$libfiles = str_replace(BUILD_LIB_PATH . '/lib', '-l', $libfiles);
|
|
|
|
|
$libfiles = str_replace('.a', '', $libfiles);
|
|
|
|
|
return '--with-pgsql' . ($shared ? '=shared' : '') .
|
|
|
|
|
' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH .
|
|
|
|
|
' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' ' . $libfiles . '"';
|
2024-12-05 10:30:38 +08:00
|
|
|
}
|
2025-05-21 14:10:56 +07:00
|
|
|
return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH;
|
2024-12-05 10:30:38 +08:00
|
|
|
}
|
2025-03-24 05:47:00 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws WrongUsageException
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
2025-05-21 12:01:00 +07:00
|
|
|
public function getWindowsConfigureArg(bool $shared = false): string
|
2025-03-24 05:47:00 +01:00
|
|
|
{
|
|
|
|
|
if ($this->builder->getPHPVersionID() >= 80400) {
|
|
|
|
|
return '--with-pgsql';
|
|
|
|
|
}
|
|
|
|
|
return '--with-pgsql=' . BUILD_ROOT_PATH;
|
|
|
|
|
}
|
2023-07-28 23:47:22 +08:00
|
|
|
}
|