extra dependencies for extensions

This commit is contained in:
DubbleClick
2025-05-22 12:27:41 +07:00
parent 310be957b6
commit 3713ae8c93
5 changed files with 56 additions and 19 deletions

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -12,6 +12,6 @@ class xdebug extends Extension
{
protected function isZendExtension(): bool
{
return str_contains($this->builder->getExt('zend')->getName(), 'xdebug');
return true;
}
}