Add ext-uv

This commit is contained in:
crazywhalecc 2026-03-17 13:04:19 +08:00
parent 22c5403e98
commit 2327f32e41
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 54 additions and 0 deletions

18
config/pkg/ext/ext-uv.yml Normal file
View File

@ -0,0 +1,18 @@
ext-uv:
type: php-extension
artifact:
source:
type: pecl
name: uv
prefer-stable: false
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- libuv
- ext-sockets
php-extension:
support:
Windows: wip
BSD: wip
arg-type: with-path

View File

@ -0,0 +1,36 @@
<?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\Package\Validate;
use StaticPHP\Exception\ValidationException;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
#[Extension('uv')]
class uv extends PhpExtensionPackage
{
#[Validate]
public function validate(): void
{
if (php::getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new ValidationException('The latest uv extension requires PHP 8.0 or later');
}
}
#[BeforeStage('ext-uv', [PhpExtensionPackage::class, 'makeForUnix'])]
public function patchBeforeSharedMake(PhpExtensionPackage $pkg): bool
{
if (SystemTarget::getTargetOS() !== 'Linux' || SystemTarget::getTargetArch() !== 'aarch64') {
return false;
}
FileSystem::replaceFileRegex("{$pkg->getSourceDir()}/Makefile", '/^(LDFLAGS =.*)$/m', '$1 -luv -ldl -lrt -pthread');
return true;
}
}