Add extension amqp

This commit is contained in:
crazywhalecc 2026-02-06 16:33:34 +08:00
parent d8d9f389ba
commit 95f34fbbc3
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,18 @@
ext-amqp:
type: php-extension
artifact:
source:
type: url
url: 'https://pecl.php.net/get/amqp'
extract: php-src/ext/amqp
filename: amqp.tgz
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- librabbitmq
depends@windows:
- ext-openssl
php-extension:
arg-type: '--with-amqp@shared_suffix@ --with-librabbitmq-dir=@build_root_path@'
arg-type@windows: '--with-amqp'

View File

@ -0,0 +1,26 @@
<?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\Util\FileSystem;
#[Extension('amqp')]
class amqp
{
#[BeforeStage('php', [php::class, 'makeForWindows'], 'ext-amqp')]
#[PatchDescription('Remove #warning directives from amqp headers to prevent build failures on Windows')]
public function patchBeforeMake(): bool
{
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp.h', '/^#warning.*/m', '');
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_framing.h', '/^#warning.*/m', '');
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_ssl_socket.h', '/^#warning.*/m', '');
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_tcp_socket.h', '/^#warning.*/m', '');
return true;
}
}