Skip to content

Commit

Permalink
Add extension simdjson support (#402)
Browse files Browse the repository at this point in the history
* add extension simdjson support

* add extension simdjson tests

* fix windows build for simdjson
  • Loading branch information
crazywhalecc committed Apr 2, 2024
1 parent 9fd5698 commit c77dc1a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config/ext.json
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@
"shmop": {
"type": "builtin"
},
"simdjson": {
"type": "external",
"source": "ext-simdjson",
"cpp-extension": true
},
"simplexml": {
"type": "builtin",
"arg-type": "custom",
Expand Down
10 changes: 10 additions & 0 deletions config/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@
"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": {
"type": "git",
"path": "php-src/ext/snappy",
Expand Down
34 changes: 34 additions & 0 deletions src/SPC/builder/extension/simdjson.php
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 2 additions & 2 deletions src/globals/test-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'ds',
'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,ds',
'Linux', 'Darwin' => 'ds,simdjson',
'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`).
Expand Down

0 comments on commit c77dc1a

Please sign in to comment.