2024-06-04 12:24:52 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
2025-08-06 20:43:23 +08:00
|
|
|
use SPC\exception\ValidationException;
|
2025-06-20 15:25:07 +07:00
|
|
|
use SPC\store\FileSystem;
|
2024-06-04 12:24:52 +08:00
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('uv')]
|
|
|
|
|
class uv extends Extension
|
|
|
|
|
{
|
|
|
|
|
public function validate(): void
|
|
|
|
|
{
|
|
|
|
|
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
|
2025-08-06 20:43:23 +08:00
|
|
|
throw new ValidationException('The latest uv extension requires PHP 8.0 or later');
|
2024-06-04 12:24:52 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-06-19 22:06:11 +07:00
|
|
|
|
2025-06-20 15:25:07 +07:00
|
|
|
public function patchBeforeSharedMake(): bool
|
2025-06-19 22:06:11 +07:00
|
|
|
{
|
2025-06-25 14:32:00 +07:00
|
|
|
parent::patchBeforeSharedMake();
|
2025-06-20 15:58:42 +07:00
|
|
|
if (PHP_OS_FAMILY !== 'Linux' || arch2gnu(php_uname('m')) !== 'aarch64') {
|
2025-06-20 15:25:07 +07:00
|
|
|
return false;
|
|
|
|
|
}
|
2025-06-20 15:57:16 +07:00
|
|
|
FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/^(LDFLAGS =.*)$/m', '$1 -luv -ldl -lrt -pthread');
|
2025-06-20 15:25:07 +07:00
|
|
|
return true;
|
2025-06-19 22:06:11 +07:00
|
|
|
}
|
2024-06-04 12:24:52 +08:00
|
|
|
}
|