Skip to content

Commit 956c87a

Browse files
committed
add memcache support
1 parent 778b0ea commit 956c87a

File tree

4 files changed

+72
-10
lines changed

4 files changed

+72
-10
lines changed

config/ext.json

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@
163163
"onig"
164164
]
165165
},
166+
"memcache": {
167+
"type": "external",
168+
"source": "ext-memcache",
169+
"arg-type": "custom",
170+
"lib-depends": [
171+
"zlib"
172+
],
173+
"ext-depends": [
174+
"session"
175+
]
176+
},
166177
"mongodb": {
167178
"type": "external",
168179
"source": "mongodb",
@@ -220,13 +231,6 @@
220231
"postgresql"
221232
]
222233
},
223-
"pgsql": {
224-
"type": "builtin",
225-
"arg-type": "with-prefix",
226-
"lib-depends": [
227-
"postgresql"
228-
]
229-
},
230234
"pdo_sqlite": {
231235
"type": "builtin",
232236
"arg-type": "with",
@@ -238,6 +242,13 @@
238242
"sqlite"
239243
]
240244
},
245+
"pgsql": {
246+
"type": "builtin",
247+
"arg-type": "with-prefix",
248+
"lib-depends": [
249+
"postgresql"
250+
]
251+
},
241252
"phar": {
242253
"type": "builtin",
243254
"ext-depends": [

config/source.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
"path": "LICENSE"
6262
}
6363
},
64+
"ext-memcache": {
65+
"type": "url",
66+
"url": "https://pecl.php.net/get/memcache",
67+
"path": "php-src/ext/memcache",
68+
"filename": "memcache.tgz",
69+
"license": {
70+
"type": "file",
71+
"path": "LICENSE"
72+
}
73+
},
6474
"ext-ssh2": {
6575
"type": "url",
6676
"url": "https://pecl.php.net/get/ssh2",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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('memcache')]
11+
class memcache extends Extension
12+
{
13+
public function getUnixConfigureArg(): string
14+
{
15+
return '--enable-memcache --with-zlib-dir=' . BUILD_ROOT_PATH;
16+
}
17+
}

src/SPC/store/SourcePatcher.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,33 @@ public static function patchPHPBuildconf(BuilderBase $builder): void
4848
file_put_contents(SOURCE_PATH . '/php-src/ext/curl/config.m4', $file1 . "\n" . $files . "\n" . $file2);
4949
}
5050

51-
// if ($builder->getExt('pdo_sqlite')) {
52-
// FileSystem::replaceFile()
53-
// }
51+
if ($builder->getExt('memcache')) {
52+
FileSystem::replaceFile(
53+
SOURCE_PATH . '/php-src/ext/memcache/config9.m4',
54+
REPLACE_FILE_STR,
55+
'if test -d $abs_srcdir/src ; then',
56+
'if test -d $abs_srcdir/main ; then'
57+
);
58+
FileSystem::replaceFile(
59+
SOURCE_PATH . '/php-src/ext/memcache/config9.m4',
60+
REPLACE_FILE_STR,
61+
'export CPPFLAGS="$CPPFLAGS $INCLUDES"',
62+
'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"'
63+
);
64+
// add for in-tree building
65+
file_put_contents(
66+
SOURCE_PATH . '/php-src/ext/memcache/php_memcache.h',
67+
<<<'EOF'
68+
#ifndef PHP_MEMCACHE_H
69+
#define PHP_MEMCACHE_H
70+
71+
extern zend_module_entry memcache_module_entry;
72+
#define phpext_memcache_ptr &memcache_module_entry
73+
74+
#endif
75+
EOF
76+
);
77+
}
5478
}
5579

5680
public static function patchSwow(): bool

0 commit comments

Comments
 (0)