mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-12 11:25:35 +08:00
fix(pgsql): link secur32 and crypt32 on windows
- libpq authenticates through SSPI and the static libcrypto behind it reads the system cert store; php.exe failed to link with unresolved Cert* and SSPI symbols when the openssl extension is not in the build
This commit is contained in:
@@ -5,11 +5,15 @@ declare(strict_types=1);
|
||||
namespace Package\Extension;
|
||||
|
||||
use Package\Target\php;
|
||||
use StaticPHP\Attribute\Package\BeforeStage;
|
||||
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
|
||||
use StaticPHP\Attribute\Package\Extension;
|
||||
use StaticPHP\Attribute\PatchDescription;
|
||||
use StaticPHP\Package\PackageBuilder;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
use StaticPHP\Package\PhpExtensionPackage;
|
||||
use StaticPHP\Package\TargetPackage;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
use StaticPHP\Util\SPCConfigUtil;
|
||||
|
||||
#[Extension('pgsql')]
|
||||
@@ -39,6 +43,27 @@ class pgsql extends PhpExtensionPackage
|
||||
return "--with-pgsql={$builder->getBuildRootPath()}";
|
||||
}
|
||||
|
||||
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-pgsql')]
|
||||
#[PatchDescription('Link the Win32 system libraries the static libpq needs')]
|
||||
public function patchConfigW32ForWindows(TargetPackage $package): void
|
||||
{
|
||||
$config = "{$package->getSourceDir()}\\ext\\pgsql\\config.w32";
|
||||
|
||||
if (str_contains(FileSystem::readFile($config), 'LIBS_PGSQL')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// libpq uses SSPI for Windows auth (secur32) and the static libcrypto behind it
|
||||
// reads the system cert store (crypt32). Nothing else puts these on the link line
|
||||
// when the openssl extension itself is not part of the build.
|
||||
FileSystem::replaceFileStr(
|
||||
$config,
|
||||
'EXTENSION("pgsql", "pgsql.c", PHP_PGSQL_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");',
|
||||
'EXTENSION("pgsql", "pgsql.c", PHP_PGSQL_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");' . "\n\t\t" .
|
||||
'ADD_FLAG("LIBS_PGSQL", "secur32.lib crypt32.lib");'
|
||||
);
|
||||
}
|
||||
|
||||
public function getSharedExtensionEnv(): array
|
||||
{
|
||||
$parent = parent::getSharedExtensionEnv();
|
||||
|
||||
Reference in New Issue
Block a user