mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-08 01:15:37 +08:00
extra dependencies for extensions
This commit is contained in:
@@ -313,6 +313,7 @@ class Extension
|
||||
*/
|
||||
public function buildShared(): void
|
||||
{
|
||||
logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
|
||||
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
|
||||
logger()->info('extension ' . $this->getName() . ' already built, skipping');
|
||||
return;
|
||||
@@ -322,7 +323,10 @@ class Extension
|
||||
if ($dependencyExt === null) {
|
||||
throw new RuntimeException("extension {$this->name} requires shared extension {$name}");
|
||||
}
|
||||
$dependencyExt->buildShared();
|
||||
if ($dependencyExt->isBuildShared()) {
|
||||
logger()->info('extension ' . $this->getName() . ' requires shared extension ' . $name);
|
||||
$dependencyExt->buildShared();
|
||||
}
|
||||
}
|
||||
match (PHP_OS_FAMILY) {
|
||||
'Darwin', 'Linux' => $this->buildUnixShared(),
|
||||
@@ -341,11 +345,25 @@ class Extension
|
||||
*/
|
||||
public function buildUnixShared(): void
|
||||
{
|
||||
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()]);
|
||||
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true);
|
||||
$sharedLibs = '';
|
||||
$staticLibs = '';
|
||||
foreach (explode('-l', $config['libs']) as $lib) {
|
||||
$lib = trim($lib);
|
||||
if ($lib === '') {
|
||||
continue;
|
||||
}
|
||||
$static_lib = 'lib' . $lib . '.a';
|
||||
if (file_exists(BUILD_LIB_PATH . '/' . $static_lib)) {
|
||||
$staticLibs .= ' -l' . $lib;
|
||||
} else {
|
||||
$sharedLibs .= ' -l' . $lib;
|
||||
}
|
||||
}
|
||||
$env = [
|
||||
'CFLAGS' => $config['cflags'],
|
||||
'LDFLAGS' => $config['ldflags'],
|
||||
'LIBS' => $config['libs'],
|
||||
'LDFLAGS' => $config['ldflags'] . ' -Wl,--allow-multiple-definition',
|
||||
'LIBS' => '-Wl,-Bstatic ' . $staticLibs . ' -Wl,-Bdynamic ' . $sharedLibs,
|
||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
||||
];
|
||||
// prepare configure args
|
||||
|
||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('spx')]
|
||||
@@ -13,17 +12,10 @@ class spx extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
$arg = '--enable-spx';
|
||||
$arg = '--enable-SPX';
|
||||
if ($this->builder->getExt('zlib') === null) {
|
||||
$arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH;
|
||||
}
|
||||
return $arg;
|
||||
}
|
||||
|
||||
public function patchBeforeSharedConfigure(): bool
|
||||
{
|
||||
FileSystem::replaceFileStr($this->source_dir . '/config.m4', 'PHP_ARG_ENABLE(SPX-DEV,', 'PHP_ARG_ENABLE(spx-dev,');
|
||||
FileSystem::replaceFileStr($this->source_dir . '/config.m4', 'PHP_ARG_ENABLE(SPX,', 'PHP_ARG_ENABLE(spx,');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ class xdebug extends Extension
|
||||
{
|
||||
protected function isZendExtension(): bool
|
||||
{
|
||||
return str_contains($this->builder->getExt('zend')->getName(), 'xdebug');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user