add lz4, igbinary support for redis

This commit is contained in:
crazywhalecc 2023-12-23 13:53:22 +08:00 committed by Jerry Ma
parent 3828ba7c77
commit 6bcda6a5a0
9 changed files with 92 additions and 33 deletions

View File

@ -143,4 +143,4 @@ jobs:
run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php)" --with-php=${{ matrix.php }} --debug
- name: "Run Build Tests (build)"
run: bin/spc build "$(php src/globals/test-extensions.php)" --build-cli --build-micro --build-fpm --debug
run: bin/spc build $(php src/globals/test-extensions.php) --build-cli --build-micro --build-fpm --debug

View File

@ -150,6 +150,10 @@
"icu"
]
},
"igbinary": {
"type": "external",
"source": "igbinary"
},
"ldap": {
"type": "builtin",
"arg-type": "with-prefix",
@ -331,7 +335,11 @@
"source": "redis",
"arg-type": "custom",
"ext-suggests": [
"session"
"session",
"igbinary"
],
"lib-suggests": [
"zstd"
]
},
"session": {

View File

@ -224,12 +224,6 @@
"libturbojpeg.a"
]
},
"libmcrypt": {
"source": "libmcrypt",
"static-libs-unix": [
"libmcrypt.a"
]
},
"libmemcached": {
"source": "libmemcached",
"static-libs-unix": [
@ -368,12 +362,6 @@
"openssl"
]
},
"mcrypt": {
"source": "mcrypt",
"static-libs-unix": [
"libmcrypt.a"
]
},
"ncurses": {
"source": "ncurses",
"static-libs-unix": [
@ -507,6 +495,12 @@
"libiconv"
]
},
"liblz4": {
"source": "liblz4",
"static-libs-unix": [
"liblz4.a"
]
},
"xz": {
"source": "xz",
"static-libs-unix": [

View File

@ -224,12 +224,13 @@
"path": "LICENSE.md"
}
},
"libmcrypt": {
"type": "url",
"url": "https://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz",
"liblz4": {
"type": "ghrel",
"repo": "lz4/lz4",
"match": "lz4-.+\\.tar\\.gz",
"license": {
"type": "file",
"path": "COPYING"
"path": "LICENSE"
}
},
"libmemcached": {
@ -251,8 +252,9 @@
}
},
"libsodium": {
"type": "url",
"url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz",
"type": "ghrel",
"repo": "jedisct1/libsodium",
"match": "libsodium-\\d+(\\.\\d+)*\\.tar\\.gz",
"license": {
"type": "file",
"path": "LICENSE"
@ -310,14 +312,6 @@
"path": "LICENSE"
}
},
"mcrypt": {
"type": "url",
"url": "https://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"memcached": {
"type": "url",
"url": "https://pecl.php.net/get/memcached",
@ -366,6 +360,16 @@
"path": "COPYING"
}
},
"igbinary": {
"type": "url",
"url": "https://pecl.php.net/get/igbinary",
"path": "php-src/ext/igbinary",
"filename": "igbinary.tgz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"onig": {
"type": "ghrel",
"repo": "kkos/oniguruma",

View File

@ -13,14 +13,14 @@ class redis extends Extension
public function getUnixConfigureArg(): string
{
$arg = '--enable-redis';
if (!$this->builder->getExt('session')) {
$arg .= ' --disable-redis-session';
} else {
$arg .= ' --enable-redis-session';
}
$arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session';
$arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
if ($this->builder->getLib('zstd')) {
$arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';
}
if ($this->builder->getLib('liblz4')) {
$arg .= ' --enable-redis-lz4 --with-liblz4="' . BUILD_ROOT_PATH . '"';
}
return $arg;
}
}

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class liblz4 extends LinuxLibraryBase
{
use \SPC\builder\unix\library\liblz4;
public const NAME = 'liblz4';
}

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class liblz4 extends MacOSLibraryBase
{
use \SPC\builder\unix\library\liblz4;
public const NAME = 'liblz4';
}

View File

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\store\FileSystem;
trait liblz4
{
protected function build()
{
shell()->cd($this->source_dir)
->exec("make PREFIX='' clean")
->exec("make -j{$this->builder->concurrency} PREFIX=''")
->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['liblz4.pc']);
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
if (str_starts_with($filename, 'liblz4') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
}
}
}
}

View File

@ -9,4 +9,7 @@ if (PHP_OS_FAMILY === 'Darwin') {
$extensions .= ',sodium';
}
// test redis lz4, igbinary
$extensions .= ',igbinary,zstd --with-libs=liblz4';
echo $extensions;