mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
Add ext-pgsql,ext-pdo_pgsql
This commit is contained in:
parent
74865025bd
commit
f85f29e628
@ -187,6 +187,21 @@ ext-pdo_odbc:
|
||||
- ext-odbc
|
||||
php-extension:
|
||||
arg-type: custom
|
||||
ext-pdo_pgsql:
|
||||
type: php-extension
|
||||
depends@unix:
|
||||
- ext-pdo
|
||||
- ext-pgsql
|
||||
- postgresql
|
||||
php-extension:
|
||||
arg-type@unix: with-path
|
||||
arg-type@windows: '--with-pdo-pgsql=yes'
|
||||
ext-pgsql:
|
||||
type: php-extension
|
||||
depends@unix:
|
||||
- postgresql
|
||||
php-extension:
|
||||
arg-type: custom
|
||||
ext-phar:
|
||||
type: php-extension
|
||||
depends:
|
||||
|
||||
48
src/Package/Extension/pgsql.php
Normal file
48
src/Package/Extension/pgsql.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Extension;
|
||||
|
||||
use Package\Target\php;
|
||||
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
|
||||
use StaticPHP\Attribute\Package\Extension;
|
||||
use StaticPHP\Package\PackageBuilder;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
use StaticPHP\Package\PhpExtensionPackage;
|
||||
use StaticPHP\Util\SPCConfigUtil;
|
||||
|
||||
#[Extension('pgsql')]
|
||||
class pgsql extends PhpExtensionPackage
|
||||
{
|
||||
#[CustomPhpConfigureArg('Darwin')]
|
||||
#[CustomPhpConfigureArg('Linux')]
|
||||
public function getUnixConfigureArg(bool $shared, PackageBuilder $builder, PackageInstaller $installer): string
|
||||
{
|
||||
if (php::getPHPVersionID() >= 80400) {
|
||||
$libfiles = new SPCConfigUtil(['libs_only_deps' => true, 'absolute_libs' => true])->getPackageDepsConfig('postgresql', array_keys($installer->getResolvedPackages()), $builder->getOption('with-suggests'))['libs'];
|
||||
$libfiles = str_replace("{$builder->getLibDir()}/lib", '-l', $libfiles);
|
||||
$libfiles = str_replace('.a', '', $libfiles);
|
||||
return '--with-pgsql' . ($shared ? '=shared' : '') .
|
||||
' PGSQL_CFLAGS=-I' . $builder->getIncludeDir() .
|
||||
' PGSQL_LIBS="-L' . $builder->getLibDir() . ' ' . $libfiles . '"';
|
||||
}
|
||||
return '--with-pgsql=' . ($shared ? 'shared,' : '') . $builder->getBuildRootPath();
|
||||
}
|
||||
|
||||
#[CustomPhpConfigureArg('Windows')]
|
||||
public function getWindowsConfigureArg(bool $shared, PackageBuilder $builder): string
|
||||
{
|
||||
if (php::getPHPVersionID() >= 80400) {
|
||||
return '--with-pgsql';
|
||||
}
|
||||
return "--with-pgsql={$builder->getBuildRootPath()}";
|
||||
}
|
||||
|
||||
public function getSharedExtensionEnv(): array
|
||||
{
|
||||
$parent = parent::getSharedExtensionEnv();
|
||||
$parent['CFLAGS'] .= ' -std=c17 -Wno-int-conversion';
|
||||
return $parent;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user