Add extension simdjson support (#402)

* add extension simdjson support

* add extension simdjson tests

* fix windows build for simdjson
This commit is contained in:
Jerry Ma 2024-04-02 16:57:59 +08:00 committed by GitHub
parent 9fd56987ef
commit c77dc1af6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 51 additions and 2 deletions

View File

@ -382,6 +382,11 @@
"shmop": { "shmop": {
"type": "builtin" "type": "builtin"
}, },
"simdjson": {
"type": "external",
"source": "ext-simdjson",
"cpp-extension": true
},
"simplexml": { "simplexml": {
"type": "builtin", "type": "builtin",
"arg-type": "custom", "arg-type": "custom",

View File

@ -100,6 +100,16 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"ext-simdjson": {
"type": "url",
"url": "https://pecl.php.net/get/simdjson",
"path": "php-src/ext/simdjson",
"filename": "simdjson.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-snappy": { "ext-snappy": {
"type": "git", "type": "git",
"path": "php-src/ext/snappy", "path": "php-src/ext/snappy",

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('simdjson')]
class simdjson extends Extension
{
public function patchBeforeBuildconf(): bool
{
$php_ver = $this->builder->getPHPVersionID();
FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/ext/simdjson/config.m4',
'/php_version=(`.*`)$/m',
'php_version=' . strval($php_ver)
);
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/simdjson/config.m4',
'if test -z "$PHP_CONFIG"; then',
'if false; then'
);
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/simdjson/config.w32',
"'yes',",
'PHP_SIMDJSON_SHARED,'
);
return true;
}
}

View File

@ -13,8 +13,8 @@ declare(strict_types=1);
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) { $extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'ds', 'Linux', 'Darwin' => 'ds,simdjson',
'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,ds', 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,ds,simdjson',
}; };
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).