mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
Add ext-memcache
This commit is contained in:
parent
cbfeefc808
commit
f35f133115
14
config/pkg/ext/ext-memcache.yml
Normal file
14
config/pkg/ext/ext-memcache.yml
Normal file
@ -0,0 +1,14 @@
|
||||
ext-memcache:
|
||||
type: php-extension
|
||||
artifact:
|
||||
source:
|
||||
type: pecl
|
||||
name: memcache
|
||||
metadata:
|
||||
license-files: [LICENSE]
|
||||
license: PHP-3.0
|
||||
depends:
|
||||
- ext-zlib
|
||||
- ext-session
|
||||
php-extension:
|
||||
arg-type: '--enable-memcache@shared_suffix@ --with-zlib-dir=@build_root_path@'
|
||||
75
src/Package/Extension/memcache.php
Normal file
75
src/Package/Extension/memcache.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Extension;
|
||||
|
||||
use Package\Target\php;
|
||||
use StaticPHP\Attribute\Package\BeforeStage;
|
||||
use StaticPHP\Attribute\Package\Extension;
|
||||
use StaticPHP\Attribute\PatchDescription;
|
||||
use StaticPHP\Package\PhpExtensionPackage;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Extension('memcache')]
|
||||
class memcache extends PhpExtensionPackage
|
||||
{
|
||||
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-memcache')]
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
if (!$this->isBuildStatic()) {
|
||||
return false;
|
||||
}
|
||||
FileSystem::replaceFileStr(
|
||||
"{$this->getSourceDir()}/config9.m4",
|
||||
'if test -d $abs_srcdir/src ; then',
|
||||
'if test -d $abs_srcdir/main ; then'
|
||||
);
|
||||
FileSystem::replaceFileStr(
|
||||
"{$this->getSourceDir()}/config9.m4",
|
||||
'export CPPFLAGS="$CPPFLAGS $INCLUDES"',
|
||||
'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"'
|
||||
);
|
||||
// add for in-tree building
|
||||
file_put_contents(
|
||||
"{$this->getSourceDir()}/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;
|
||||
}
|
||||
|
||||
#[BeforeStage('ext-memcache', [self::class, 'configureForUnix'])]
|
||||
#[PatchDescription('Fix memcache extension compile error when building as shared')]
|
||||
public function patchBeforeSharedConfigure(): bool
|
||||
{
|
||||
if (!$this->isBuildShared()) {
|
||||
return false;
|
||||
}
|
||||
FileSystem::replaceFileStr(
|
||||
"{$this->getSourceDir()}/config9.m4",
|
||||
'if test -d $abs_srcdir/main ; then',
|
||||
'if test -d $abs_srcdir/src ; then',
|
||||
);
|
||||
FileSystem::replaceFileStr(
|
||||
"{$this->getSourceDir()}/config9.m4",
|
||||
'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"',
|
||||
'export CPPFLAGS="$CPPFLAGS $INCLUDES"',
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getSharedExtensionEnv(): array
|
||||
{
|
||||
$parent = parent::getSharedExtensionEnv();
|
||||
$parent['CFLAGS'] .= ' -std=c17';
|
||||
return $parent;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user