Add ext-ffi

This commit is contained in:
crazywhalecc 2026-03-09 15:13:07 +08:00
parent b226887bd2
commit cf2e1d9819
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
3 changed files with 36 additions and 11 deletions

View File

@ -36,6 +36,13 @@ ext-dom:
arg-type@windows: with
ext-exif:
type: php-extension
ext-ffi:
type: php-extension
depends@unix:
- libffi
php-extension:
arg-type@unix: '--with-ffi=@shared_suffix@ --enable-zend-signals'
arg-type@windows: with
ext-mbregex:
type: php-extension
depends:

View File

@ -7,7 +7,6 @@ namespace Package\Artifact;
use Package\Target\php;
use StaticPHP\Attribute\Artifact\AfterSourceExtract;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
use StaticPHP\Util\SourcePatcher;
@ -52,16 +51,6 @@ class php_src
}
}
#[AfterSourceExtract('php-src')]
#[PatchDescription('Patch FFI extension on CentOS 7 with -O3 optimization (strncmp issue)')]
public function patchFfiCentos7FixO3strncmp(): void
{
spc_skip_if(!($ver = SystemTarget::getLibcVersion()) || version_compare($ver, '2.17', '>'));
$ver_id = php::getPHPVersionID(return_null_if_failed: true);
spc_skip_if($ver_id === null || $ver_id < 80316);
SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src');
}
#[AfterSourceExtract('php-src')]
#[PatchDescription('Add LICENSE file to IMAP extension if missing')]
public function patchImapLicense(): void

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\SourcePatcher;
use StaticPHP\Util\System\LinuxUtil;
#[Extension('ffi')]
class ffi extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-ffi')]
#[PatchDescription('Patch FFI extension on CentOS 7 with -O3 optimization (strncmp issue)')]
public function patchBeforeBuildconf(): void
{
spc_skip_if(!($ver = SystemTarget::getLibcVersion()) || version_compare($ver, '2.17', '>'));
$ver_id = php::getPHPVersionID(return_null_if_failed: true);
spc_skip_if($ver_id === null || $ver_id < 80316);
spc_skip_if(LinuxUtil::getOSRelease()['dist'] !== 'centos');
SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src');
}
}