From 72e322a884a9d11e8985caacb500692bf1c42a6c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 2 Apr 2024 16:13:36 +0800 Subject: [PATCH 1/3] add extension simdjson support --- config/ext.json | 5 +++++ config/source.json | 10 +++++++++ src/SPC/builder/extension/simdjson.php | 29 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 src/SPC/builder/extension/simdjson.php diff --git a/config/ext.json b/config/ext.json index 19e33836b..e74f64af1 100644 --- a/config/ext.json +++ b/config/ext.json @@ -382,6 +382,11 @@ "shmop": { "type": "builtin" }, + "simdjson": { + "type": "external", + "source": "ext-simdjson", + "cpp-extension": true + }, "simplexml": { "type": "builtin", "arg-type": "custom", diff --git a/config/source.json b/config/source.json index 6b3ca4141..6ed35f5de 100644 --- a/config/source.json +++ b/config/source.json @@ -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", diff --git a/src/SPC/builder/extension/simdjson.php b/src/SPC/builder/extension/simdjson.php new file mode 100644 index 000000000..3ea1ffc61 --- /dev/null +++ b/src/SPC/builder/extension/simdjson.php @@ -0,0 +1,29 @@ +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' + ); + return true; + } +} From 225104daf6d843a55a6d10f79ba47734f1e2efad Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 2 Apr 2024 16:13:57 +0800 Subject: [PATCH 2/3] add extension simdjson tests --- src/globals/test-extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 9cdaaf606..e2aa441e1 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -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`). From 859f8cd7ef7ecda8d136a0a49e48cd7bf8ca4308 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 2 Apr 2024 16:31:08 +0800 Subject: [PATCH 3/3] fix windows build for simdjson --- src/SPC/builder/extension/simdjson.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SPC/builder/extension/simdjson.php b/src/SPC/builder/extension/simdjson.php index 3ea1ffc61..71796ebee 100644 --- a/src/SPC/builder/extension/simdjson.php +++ b/src/SPC/builder/extension/simdjson.php @@ -24,6 +24,11 @@ public function patchBeforeBuildconf(): bool '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; } }