Skip to content

Commit 089b94d

Browse files
committed
add fastlz, libmemcached for linux
1 parent bfba598 commit 089b94d

File tree

10 files changed

+101
-32
lines changed

10 files changed

+101
-32
lines changed

config/ext.json

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,16 @@
330330
"openssl"
331331
]
332332
},
333+
"libxml": {
334+
"support": {
335+
"BSD": "wip"
336+
},
337+
"type": "builtin",
338+
"arg-type": "none",
339+
"target": [
340+
"static"
341+
]
342+
},
333343
"lz4": {
334344
"support": {
335345
"Windows": "wip",
@@ -342,16 +352,6 @@
342352
"liblz4"
343353
]
344354
},
345-
"libxml": {
346-
"support": {
347-
"BSD": "wip"
348-
},
349-
"type": "builtin",
350-
"arg-type": "none",
351-
"target": [
352-
"static"
353-
]
354-
},
355355
"mbregex": {
356356
"type": "builtin",
357357
"arg-type": "custom",
@@ -396,8 +396,7 @@
396396
"memcached": {
397397
"support": {
398398
"Windows": "wip",
399-
"BSD": "wip",
400-
"Linux": "no"
399+
"BSD": "wip"
401400
},
402401
"type": "external",
403402
"source": "memcached",
@@ -406,6 +405,10 @@
406405
"lib-depends": [
407406
"libmemcached"
408407
],
408+
"lib-depends-unix": [
409+
"libmemcached",
410+
"fastlz"
411+
],
409412
"ext-depends": [
410413
"session",
411414
"zlib"
@@ -1083,6 +1086,9 @@
10831086
"type": "external",
10841087
"source": "yac",
10851088
"arg-type-unix": "custom",
1089+
"lib-depends-unix": [
1090+
"fastlz"
1091+
],
10861092
"ext-depends-unix": [
10871093
"igbinary"
10881094
]

config/lib.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@
101101
"SystemConfiguration"
102102
]
103103
},
104+
"fastlz": {
105+
"source": "fastlz",
106+
"static-libs-unix": [
107+
"libfastlz.a"
108+
],
109+
"headers": [
110+
"fastlz/fastlz.h"
111+
]
112+
},
104113
"freetype": {
105114
"source": "freetype",
106115
"static-libs-unix": [
@@ -389,7 +398,9 @@
389398
"source": "libmemcached",
390399
"static-libs-unix": [
391400
"libmemcached.a",
392-
"libmemcachedutil.a"
401+
"libmemcachedprotocol.a",
402+
"libmemcachedutil.a",
403+
"libhashkit.a"
393404
]
394405
},
395406
"libpng": {

config/source.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,15 @@
272272
"path": "LICENSE"
273273
}
274274
},
275+
"fastlz": {
276+
"type": "git",
277+
"url": "https://github.com/ariya/FastLZ.git",
278+
"rev": "master",
279+
"license": {
280+
"type": "file",
281+
"path": "LICENSE.MIT"
282+
}
283+
},
275284
"freetype": {
276285
"type": "git",
277286
"rev": "VER-2-13-2",
@@ -528,12 +537,12 @@
528537
}
529538
},
530539
"libmemcached": {
531-
"type": "git",
532-
"url": "https://github.com/static-php/libmemcached-macos.git",
533-
"rev": "master",
540+
"type": "ghtagtar",
541+
"repo": "awesomized/libmemcached",
542+
"match": "1.\\d.\\d",
534543
"license": {
535544
"type": "file",
536-
"path": "COPYING"
545+
"path": "LICENSE"
537546
}
538547
},
539548
"libpng": {

src/SPC/builder/extension/memcached.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ class memcached extends Extension
1212
{
1313
public function getUnixConfigureArg(bool $shared = false): string
1414
{
15-
$rootdir = BUILD_ROOT_PATH;
16-
$zlib_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : "--with-zlib-dir={$rootdir}";
17-
return '--enable-memcached' . ($shared ? '=shared' : '') . " {$zlib_dir} --with-libmemcached-dir={$rootdir} --disable-memcached-sasl --enable-memcached-json";
15+
return '--enable-memcached' . ($shared ? '=shared' : '') . ' ' .
16+
'--with-zlib-dir=' . BUILD_ROOT_PATH . ' ' .
17+
'--with-libmemcached-dir=' . BUILD_ROOT_PATH . ' ' .
18+
'--disable-memcached-sasl ' .
19+
'--enable-memcached-json ' .
20+
'--with-system-fastlz';
1821
}
1922
}

src/SPC/builder/extension/yac.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public function patchBeforeBuildconf(): bool
2121

2222
public function getUnixConfigureArg(bool $shared = false): string
2323
{
24-
return '--enable-yac --enable-igbinary --enable-json';
24+
return '--enable-yac ' . ($shared ? '=shared' : '') . ' --enable-igbinary --enable-json --with-system-fastlz';
2525
}
2626
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\linux\library;
6+
7+
class fastlz extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\fastlz;
10+
11+
public const NAME = 'fastlz';
12+
}

src/SPC/builder/linux/library/libmemcached.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44

55
namespace SPC\builder\linux\library;
66

7-
use SPC\exception\RuntimeException;
7+
use SPC\util\executor\UnixCMakeExecutor;
88

9-
/**
10-
* gmp is a template library class for unix
11-
*/
129
class libmemcached extends LinuxLibraryBase
1310
{
1411
public const NAME = 'libmemcached';
1512

16-
public function build()
13+
public function build(): void
1714
{
18-
throw new RuntimeException('libmemcached is currently not supported on Linux platform');
15+
UnixCMakeExecutor::create($this)->build();
1916
}
2017
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\macos\library;
6+
7+
class fastlz extends MacOSLibraryBase
8+
{
9+
use \SPC\builder\unix\library\fastlz;
10+
11+
public const NAME = 'fastlz';
12+
}

src/SPC/builder/macos/library/libmemcached.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44

55
namespace SPC\builder\macos\library;
66

7-
use SPC\util\executor\UnixAutoconfExecutor;
7+
use SPC\util\executor\UnixCMakeExecutor;
88

9-
/**
10-
* gmp is a template library class for unix
11-
*/
129
class libmemcached extends MacOSLibraryBase
1310
{
1411
public const NAME = 'libmemcached';
1512

1613
public function build(): void
1714
{
18-
UnixAutoconfExecutor::create($this)->configure('--disable-sasl')->exec("sed -ie 's/-Werror//g' ./Makefile")->make();
15+
UnixCMakeExecutor::create($this)->build();
1916
}
2017
}
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\unix\library;
6+
7+
trait fastlz
8+
{
9+
protected function build(): void
10+
{
11+
shell()->cd($this->source_dir)->initializeEnv($this)
12+
->exec((getenv('CC') ?? 'cc') . ' -c -O3 -fPIC fastlz.c -o fastlz.o')
13+
->exec((getenv('AR') ?? 'ar') . ' rcs libfastlz.a fastlz.o');
14+
15+
if (!copy($this->source_dir . '/fastlz.h', BUILD_INCLUDE_PATH . '/fastlz.h')) {
16+
throw new \RuntimeException('Failed to copy fastlz.h');
17+
}
18+
if (!copy($this->source_dir . '/libfastlz.a', BUILD_LIB_PATH . '/libfastlz.a')) {
19+
throw new \RuntimeException('Failed to copy libfastlz.a');
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)