Merge pull request #745 from crazywhalecc/feat/lz4

add lz4 extension
This commit is contained in:
Marc 2025-06-06 13:28:54 +07:00 committed by GitHub
commit 856db3df08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 71 additions and 11 deletions

View File

@ -323,6 +323,18 @@
"openssl"
]
},
"lz4": {
"support": {
"Windows": "wip",
"BSD": "wip"
},
"type": "external",
"source": "ext-lz4",
"arg-type": "custom",
"lib-depends": [
"liblz4"
]
},
"libxml": {
"support": {
"BSD": "wip"

View File

@ -161,6 +161,17 @@
]
}
},
"ext-lz4": {
"type": "ghtagtar",
"repo": "kjdev/php-ext-lz4",
"path": "php-src/ext/lz4",
"license": {
"type": "file",
"path": [
"LICENSE"
]
}
},
"ext-memcache": {
"type": "url",
"url": "https://pecl.php.net/get/memcache",

View File

@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('lz4')]
class lz4 extends Extension
{
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-lz4' . ($shared ? '=shared' : '') . ' --with-lz4-includedir=' . BUILD_ROOT_PATH;
}
public function getWindowsConfigureArg(): string
{
return '--enable-lz4';
}
}

View File

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
assert(function_exists('lz4_compress'));
assert(function_exists('lz4_uncompress'));
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
$compressed = lz4_compress($input);
assert(is_string($compressed));
assert(strlen($compressed) < strlen($input));
$uncompressed = lz4_uncompress($compressed);
assert(is_string($uncompressed));
assert($uncompressed === $input);

View File

@ -13,22 +13,22 @@ declare(strict_types=1);
// test php version (8.1 ~ 8.4 available, multiple for matrix)
$test_php_version = [
'8.1',
'8.2',
'8.3',
// '8.1',
// '8.2',
// '8.3',
'8.4',
];
// test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available)
$test_os = [
// 'macos-13',
// 'macos-14',
// 'macos-15',
'macos-13',
'macos-14',
'macos-15',
'ubuntu-latest',
// 'ubuntu-22.04',
// 'ubuntu-24.04',
// 'ubuntu-22.04-arm',
// 'ubuntu-24.04-arm',
'ubuntu-22.04',
'ubuntu-24.04',
'ubuntu-22.04-arm',
'ubuntu-24.04-arm',
// 'windows-latest',
];
@ -45,7 +45,7 @@ $prefer_pre_built = false;
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'xsl,simplexml,xlswriter',
'Linux', 'Darwin' => 'lz4',
'Windows' => 'xlswriter,openssl',
};