Skip to content

Commit 856db3d

Browse files
authored
Merge pull request #745 from crazywhalecc/feat/lz4
add lz4 extension
2 parents ab4e0bc + 80f63e6 commit 856db3d

File tree

5 files changed

+71
-11
lines changed

5 files changed

+71
-11
lines changed

config/ext.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,18 @@
323323
"openssl"
324324
]
325325
},
326+
"lz4": {
327+
"support": {
328+
"Windows": "wip",
329+
"BSD": "wip"
330+
},
331+
"type": "external",
332+
"source": "ext-lz4",
333+
"arg-type": "custom",
334+
"lib-depends": [
335+
"liblz4"
336+
]
337+
},
326338
"libxml": {
327339
"support": {
328340
"BSD": "wip"

config/source.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,17 @@
161161
]
162162
}
163163
},
164+
"ext-lz4": {
165+
"type": "ghtagtar",
166+
"repo": "kjdev/php-ext-lz4",
167+
"path": "php-src/ext/lz4",
168+
"license": {
169+
"type": "file",
170+
"path": [
171+
"LICENSE"
172+
]
173+
}
174+
},
164175
"ext-memcache": {
165176
"type": "url",
166177
"url": "https://pecl.php.net/get/memcache",

src/SPC/builder/extension/lz4.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\extension;
6+
7+
use SPC\builder\Extension;
8+
use SPC\util\CustomExt;
9+
10+
#[CustomExt('lz4')]
11+
class lz4 extends Extension
12+
{
13+
public function getUnixConfigureArg(bool $shared = false): string
14+
{
15+
return '--enable-lz4' . ($shared ? '=shared' : '') . ' --with-lz4-includedir=' . BUILD_ROOT_PATH;
16+
}
17+
18+
public function getWindowsConfigureArg(): string
19+
{
20+
return '--enable-lz4';
21+
}
22+
}

src/globals/ext-tests/lz4.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
assert(function_exists('lz4_compress'));
6+
assert(function_exists('lz4_uncompress'));
7+
8+
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
9+
$compressed = lz4_compress($input);
10+
assert(is_string($compressed));
11+
assert(strlen($compressed) < strlen($input));
12+
13+
$uncompressed = lz4_uncompress($compressed);
14+
assert(is_string($uncompressed));
15+
assert($uncompressed === $input);

src/globals/test-extensions.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@
1313

1414
// test php version (8.1 ~ 8.4 available, multiple for matrix)
1515
$test_php_version = [
16-
'8.1',
17-
'8.2',
18-
'8.3',
16+
// '8.1',
17+
// '8.2',
18+
// '8.3',
1919
'8.4',
2020
];
2121

2222
// test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available)
2323
$test_os = [
24-
// 'macos-13',
25-
// 'macos-14',
26-
// 'macos-15',
24+
'macos-13',
25+
'macos-14',
26+
'macos-15',
2727
'ubuntu-latest',
28-
// 'ubuntu-22.04',
29-
// 'ubuntu-24.04',
30-
// 'ubuntu-22.04-arm',
31-
// 'ubuntu-24.04-arm',
28+
'ubuntu-22.04',
29+
'ubuntu-24.04',
30+
'ubuntu-22.04-arm',
31+
'ubuntu-24.04-arm',
3232
// 'windows-latest',
3333
];
3434

@@ -45,7 +45,7 @@
4545

4646
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
4747
$extensions = match (PHP_OS_FAMILY) {
48-
'Linux', 'Darwin' => 'xsl,simplexml,xlswriter',
48+
'Linux', 'Darwin' => 'lz4',
4949
'Windows' => 'xlswriter,openssl',
5050
};
5151

0 commit comments

Comments
 (0)