mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 21:04:52 +08:00
68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
use SPC\builder\Extension;
|
|
use SPC\exception\FileSystemException;
|
|
use SPC\exception\RuntimeException;
|
|
use SPC\exception\WrongUsageException;
|
|
use SPC\store\FileSystem;
|
|
use SPC\util\CustomExt;
|
|
|
|
#[CustomExt('pgsql')]
|
|
class pgsql extends Extension
|
|
{
|
|
/**
|
|
* @throws FileSystemException
|
|
* @throws RuntimeException
|
|
* @throws WrongUsageException
|
|
*/
|
|
public function patchBeforeConfigure(): bool
|
|
{
|
|
FileSystem::replaceFileRegex(
|
|
SOURCE_PATH . '/php-src/configure',
|
|
'/-lpq/',
|
|
$this->getLibFilesString()
|
|
);
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @throws WrongUsageException
|
|
* @throws RuntimeException
|
|
*/
|
|
public function getUnixConfigureArg(bool $shared = false): string
|
|
{
|
|
if ($this->builder->getPHPVersionID() >= 80400) {
|
|
$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 . '"';
|
|
}
|
|
return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH;
|
|
}
|
|
|
|
/**
|
|
* @throws WrongUsageException
|
|
* @throws RuntimeException
|
|
*/
|
|
public function getWindowsConfigureArg(bool $shared = false): string
|
|
{
|
|
if ($this->builder->getPHPVersionID() >= 80400) {
|
|
return '--with-pgsql';
|
|
}
|
|
return '--with-pgsql=' . BUILD_ROOT_PATH;
|
|
}
|
|
|
|
protected function getExtraEnv(): array
|
|
{
|
|
return [
|
|
'CFLAGS' => '-Wno-int-conversion -Wno-implicit-function-declaration',
|
|
];
|
|
}
|
|
}
|