2023-07-25 21:44:53 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
2023-08-20 19:51:45 +08:00
|
|
|
use SPC\exception\FileSystemException;
|
2023-07-28 23:47:22 +08:00
|
|
|
use SPC\store\FileSystem;
|
2023-07-25 21:44:53 +08:00
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('memcache')]
|
|
|
|
|
class memcache extends Extension
|
|
|
|
|
{
|
2025-03-27 11:12:19 +07:00
|
|
|
public function getUnixConfigureArg(bool $shared = false): string
|
2023-07-25 21:44:53 +08:00
|
|
|
{
|
|
|
|
|
return '--enable-memcache --with-zlib-dir=' . BUILD_ROOT_PATH;
|
|
|
|
|
}
|
2023-07-28 23:47:22 +08:00
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
*/
|
2023-07-28 23:47:22 +08:00
|
|
|
public function patchBeforeBuildconf(): bool
|
|
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
FileSystem::replaceFileStr(
|
2023-07-28 23:47:22 +08:00
|
|
|
SOURCE_PATH . '/php-src/ext/memcache/config9.m4',
|
|
|
|
|
'if test -d $abs_srcdir/src ; then',
|
|
|
|
|
'if test -d $abs_srcdir/main ; then'
|
|
|
|
|
);
|
2023-08-20 19:51:45 +08:00
|
|
|
FileSystem::replaceFileStr(
|
2023-07-28 23:47:22 +08:00
|
|
|
SOURCE_PATH . '/php-src/ext/memcache/config9.m4',
|
|
|
|
|
'export CPPFLAGS="$CPPFLAGS $INCLUDES"',
|
|
|
|
|
'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"'
|
|
|
|
|
);
|
|
|
|
|
// add for in-tree building
|
|
|
|
|
file_put_contents(
|
|
|
|
|
SOURCE_PATH . '/php-src/ext/memcache/php_memcache.h',
|
|
|
|
|
<<<'EOF'
|
|
|
|
|
#ifndef PHP_MEMCACHE_H
|
|
|
|
|
#define PHP_MEMCACHE_H
|
|
|
|
|
|
|
|
|
|
extern zend_module_entry memcache_module_entry;
|
|
|
|
|
#define phpext_memcache_ptr &memcache_module_entry
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
EOF
|
|
|
|
|
);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-07-25 21:44:53 +08:00
|
|
|
}
|