From c77dc1af6c38298b5db62e7ed2386e4effd40475 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 2 Apr 2024 16:57:59 +0800 Subject: [PATCH] Add extension simdjson support (#402) * add extension simdjson support * add extension simdjson tests * fix windows build for simdjson --- config/ext.json | 5 ++++ config/source.json | 10 ++++++++ src/SPC/builder/extension/simdjson.php | 34 ++++++++++++++++++++++++++ src/globals/test-extensions.php | 4 +-- 4 files changed, 51 insertions(+), 2 deletions(-) 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..71796ebee --- /dev/null +++ b/src/SPC/builder/extension/simdjson.php @@ -0,0 +1,34 @@ +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; + } +} 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`).