31 lines
853 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
2025-06-20 15:25:07 +07:00
use SPC\builder\linux\SystemUtil;
use SPC\store\FileSystem;
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') {
throw new \RuntimeException('The latest uv extension requires PHP 8.0 or later');
}
}
2025-06-20 15:25:07 +07:00
public function patchBeforeSharedMake(): bool
{
2025-06-20 15:27:28 +07:00
if (PHP_OS_FAMILY !== 'Linux' || php_uname('m') !== 'aarch64' || SystemUtil::getLibcVersionIfExists() > '2.17') {
2025-06-20 15:25:07 +07:00
return false;
}
FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/^(LDFLAGS =.*)$/', '$1 -luv -ldl -lrt -pthread');
return true;
}
}