mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-20 23:35:37 +08:00
Add ext-protobuf
This commit is contained in:
9
config/pkg/ext/ext-protobuf.yml
Normal file
9
config/pkg/ext/ext-protobuf.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
ext-protobuf:
|
||||||
|
type: php-extension
|
||||||
|
artifact:
|
||||||
|
source:
|
||||||
|
type: pecl
|
||||||
|
name: protobuf
|
||||||
|
metadata:
|
||||||
|
license-files: [LICENSE]
|
||||||
|
license: BSD-3-Clause
|
||||||
28
src/Package/Extension/protobuf.php
Normal file
28
src/Package/Extension/protobuf.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Package\Extension;
|
||||||
|
|
||||||
|
use Package\Target\php;
|
||||||
|
use StaticPHP\Attribute\Package\Extension;
|
||||||
|
use StaticPHP\Attribute\Package\Validate;
|
||||||
|
use StaticPHP\Exception\ValidationException;
|
||||||
|
use StaticPHP\Package\PackageInstaller;
|
||||||
|
|
||||||
|
#[Extension('protobuf')]
|
||||||
|
class protobuf
|
||||||
|
{
|
||||||
|
#[Validate]
|
||||||
|
public function validate(PackageInstaller $installer): void
|
||||||
|
{
|
||||||
|
if (php::getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
|
||||||
|
throw new ValidationException('The latest protobuf extension requires PHP 8.0 or later');
|
||||||
|
}
|
||||||
|
$grpc = $installer->getPhpExtensionPackage('ext-grpc');
|
||||||
|
// protobuf conflicts with grpc
|
||||||
|
if ($grpc?->isBuildStatic()) {
|
||||||
|
throw new ValidationException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user