mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-20 05:44:52 +08:00
Add ext-protobuf
This commit is contained in:
parent
63d28bdc01
commit
067749ab1b
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user