mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 14:25:41 +08:00
Chore: extension fixes
clickhouse, mongodb, opcache, password-argon2, pgsql, spx
This commit is contained in:
@@ -4,29 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Package\Extension;
|
namespace Package\Extension;
|
||||||
|
|
||||||
use Package\Target\php;
|
|
||||||
use StaticPHP\Attribute\Package\BeforeStage;
|
|
||||||
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
|
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
|
||||||
use StaticPHP\Attribute\Package\Extension;
|
use StaticPHP\Attribute\Package\Extension;
|
||||||
use StaticPHP\Attribute\PatchDescription;
|
|
||||||
use StaticPHP\Package\PackageInstaller;
|
use StaticPHP\Package\PackageInstaller;
|
||||||
use StaticPHP\Package\PhpExtensionPackage;
|
use StaticPHP\Package\PhpExtensionPackage;
|
||||||
use StaticPHP\Util\FileSystem;
|
|
||||||
|
|
||||||
#[Extension('clickhouse')]
|
#[Extension('clickhouse')]
|
||||||
class clickhouse extends PhpExtensionPackage
|
class clickhouse extends PhpExtensionPackage
|
||||||
{
|
{
|
||||||
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-clickhouse')]
|
|
||||||
#[PatchDescription('Replace THIS_DIR=`dirname $0` with PHP_EXT_SRCDIR() in config.m4 so include paths resolve to the ext source dir during PHP main configure (dirname $0 returns "." when run from php-src root).')]
|
|
||||||
public function patchBeforeBuildconfUnix(): void
|
|
||||||
{
|
|
||||||
FileSystem::replaceFileRegex(
|
|
||||||
"{$this->getSourceDir()}/config.m4",
|
|
||||||
'/^(\s*)THIS_DIR=.*/m',
|
|
||||||
'$1THIS_DIR=PHP_EXT_SRCDIR()',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[CustomPhpConfigureArg('Darwin')]
|
#[CustomPhpConfigureArg('Darwin')]
|
||||||
#[CustomPhpConfigureArg('Linux')]
|
#[CustomPhpConfigureArg('Linux')]
|
||||||
public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string
|
public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string
|
||||||
|
|||||||
@@ -16,6 +16,14 @@ use StaticPHP\Util\FileSystem;
|
|||||||
#[Extension('mongodb')]
|
#[Extension('mongodb')]
|
||||||
class mongodb extends PhpExtensionPackage
|
class mongodb extends PhpExtensionPackage
|
||||||
{
|
{
|
||||||
|
#[BeforeStage('php', [php::class, 'configureForUnix'], 'ext-mongodb')]
|
||||||
|
#[PatchDescription('Export PHP_VERSION_ID so mongo-php-driver >= 2.3.3 skips its php-config lookup (in-tree builds have no php-config).')]
|
||||||
|
public function exportPhpVersionIdForUnix(): void
|
||||||
|
{
|
||||||
|
$id = php::getPHPVersionID();
|
||||||
|
f_putenv("PHP_VERSION_ID={$id}");
|
||||||
|
}
|
||||||
|
|
||||||
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-mongodb')]
|
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-mongodb')]
|
||||||
#[PatchDescription('Add /utf-8 flag to CFLAGS_MONGODB for Windows build to fix compilation error on non-English Windows.')]
|
#[PatchDescription('Add /utf-8 flag to CFLAGS_MONGODB for Windows build to fix compilation error on non-English Windows.')]
|
||||||
public function patchBeforeBuild(): void
|
public function patchBeforeBuild(): void
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ class opcache extends PhpExtensionPackage
|
|||||||
) {
|
) {
|
||||||
$opcache_jit = ' --disable-opcache-jit';
|
$opcache_jit = ' --disable-opcache-jit';
|
||||||
}
|
}
|
||||||
return '--enable-opcache' . ($shared ? '=shared' : '') . $opcache_jit;
|
// PHP 8.5+ has opcache built-in
|
||||||
|
if ($phpVersionID < 80500) {
|
||||||
|
return '--enable-opcache' . ($shared ? '=shared' : '') . $opcache_jit;
|
||||||
|
}
|
||||||
|
return trim($opcache_jit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class password_argon2 extends PhpExtensionPackage
|
|||||||
#[CustomPhpConfigureArg('Darwin')]
|
#[CustomPhpConfigureArg('Darwin')]
|
||||||
public function getConfigureArg(PackageInstaller $installer, PackageBuilder $builder): string
|
public function getConfigureArg(PackageInstaller $installer, PackageBuilder $builder): string
|
||||||
{
|
{
|
||||||
if ($installer->getLibraryPackage('openssl') !== null) {
|
if ($installer->getPhpExtensionPackage('openssl')?->isBuildStatic() || $this->isBuildShared()) {
|
||||||
if (php::getPHPVersionID() >= 80500 || (php::getPHPVersionID() >= 80400 && !$builder->getOption('enable-zts'))) {
|
if (php::getPHPVersionID() >= 80500 || (php::getPHPVersionID() >= 80400 && !$builder->getOption('enable-zts'))) {
|
||||||
return '--without-password-argon2'; // use --with-openssl-argon2 in openssl extension instead
|
return '--without-password-argon2'; // use --with-openssl-argon2 in openssl extension instead
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class pgsql extends PhpExtensionPackage
|
|||||||
public function getUnixConfigureArg(bool $shared, PackageBuilder $builder, PackageInstaller $installer): string
|
public function getUnixConfigureArg(bool $shared, PackageBuilder $builder, PackageInstaller $installer): string
|
||||||
{
|
{
|
||||||
if (php::getPHPVersionID() >= 80400) {
|
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 = new SPCConfigUtil(['libs_only_deps' => true, 'absolute_libs' => true])->getPackageDepsConfig('postgresql', array_keys($installer->getResolvedPackages()))['libs'];
|
||||||
$libfiles = str_replace("{$builder->getLibDir()}/lib", '-l', $libfiles);
|
$libfiles = str_replace("{$builder->getLibDir()}/lib", '-l', $libfiles);
|
||||||
$libfiles = str_replace('.a', '', $libfiles);
|
$libfiles = str_replace('.a', '', $libfiles);
|
||||||
return '--with-pgsql' . ($shared ? '=shared' : '') .
|
return '--with-pgsql' . ($shared ? '=shared' : '') .
|
||||||
|
|||||||
@@ -6,14 +6,27 @@ namespace Package\Extension;
|
|||||||
|
|
||||||
use Package\Target\php;
|
use Package\Target\php;
|
||||||
use StaticPHP\Attribute\Package\BeforeStage;
|
use StaticPHP\Attribute\Package\BeforeStage;
|
||||||
|
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
|
||||||
use StaticPHP\Attribute\Package\Extension;
|
use StaticPHP\Attribute\Package\Extension;
|
||||||
use StaticPHP\Attribute\PatchDescription;
|
use StaticPHP\Attribute\PatchDescription;
|
||||||
|
use StaticPHP\Package\PackageInstaller;
|
||||||
use StaticPHP\Package\PhpExtensionPackage;
|
use StaticPHP\Package\PhpExtensionPackage;
|
||||||
use StaticPHP\Util\FileSystem;
|
use StaticPHP\Util\FileSystem;
|
||||||
|
|
||||||
#[Extension('spx')]
|
#[Extension('spx')]
|
||||||
class spx extends PhpExtensionPackage
|
class spx extends PhpExtensionPackage
|
||||||
{
|
{
|
||||||
|
#[CustomPhpConfigureArg('Linux')]
|
||||||
|
#[CustomPhpConfigureArg('Darwin')]
|
||||||
|
public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string
|
||||||
|
{
|
||||||
|
$arg = '--enable-SPX' . ($shared ? '=shared' : '');
|
||||||
|
if ($installer->getLibraryPackage('zlib') !== null) {
|
||||||
|
$arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH;
|
||||||
|
}
|
||||||
|
return $arg;
|
||||||
|
}
|
||||||
|
|
||||||
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-spx')]
|
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-spx')]
|
||||||
#[PatchDescription('Fix spx extension compile error when building as static')]
|
#[PatchDescription('Fix spx extension compile error when building as static')]
|
||||||
public function patchBeforeBuildconf(): bool
|
public function patchBeforeBuildconf(): bool
|
||||||
|
|||||||
Reference in New Issue
Block a user