diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 0f329e62..865139bb 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -122,9 +122,9 @@ abstract class BuilderBase * * @return Extension[] */ - public function getExts(bool $including_dynamic = true): array + public function getExts(bool $including_shared = true): array { - if ($including_dynamic) { + if ($including_shared) { return $this->exts; } return array_filter($this->exts, fn ($ext) => !$ext->isBuildShared()); @@ -173,18 +173,20 @@ abstract class BuilderBase * @throws \Throwable|WrongUsageException * @internal */ - public function proveExts(array $extensions, bool $skip_check_deps = false, array $shared_build_extensions = []): void + public function proveExts(array $static_extensions, array $shared_extensions = [], bool $skip_check_deps = false): void { CustomExt::loadCustomExt(); // judge ext - foreach ($extensions as $ext) { - // if extension does not support static && no shared build, throw exception - if (!in_array('static', Config::getExtTarget($ext)) && !in_array($ext, $shared_build_extensions)) { - throw new WrongUsageException('Extension [' . $ext . '] does not support static build !'); + foreach ($static_extensions as $ext) { + // if extension does not support static build, throw exception + if (!in_array('static', Config::getExtTarget($ext))) { + throw new WrongUsageException('Extension [' . $ext . '] does not support static build!'); } - // if extension does not support shared && no static build, throw exception - if (!in_array('shared', Config::getExtTarget($ext)) && !in_array($ext, $shared_build_extensions)) { - throw new WrongUsageException('Extension [' . $ext . '] does not support shared build !'); + } + foreach ($shared_extensions as $ext) { + // if extension does not support shared build, throw exception + if (!in_array('shared', Config::getExtTarget($ext)) && !in_array($ext, $shared_extensions)) { + throw new WrongUsageException('Extension [' . $ext . '] does not support shared build!'); } } $this->emitPatchPoint('before-php-extract'); @@ -196,17 +198,18 @@ abstract class BuilderBase $this->emitPatchPoint('after-micro-extract'); } $this->emitPatchPoint('before-exts-extract'); - SourceManager::initSource(exts: $extensions); + SourceManager::initSource(exts: $static_extensions); $this->emitPatchPoint('after-exts-extract'); - foreach ($extensions as $extension) { + foreach ([...$static_extensions, ...$shared_extensions] as $extension) { $class = CustomExt::getExtClass($extension); /** @var Extension $ext */ $ext = new $class($extension, $this); - if (in_array($extension, $shared_build_extensions)) { - $ext->setBuildShared(); - } else { + if (in_array($extension, $static_extensions)) { $ext->setBuildStatic(); } + if (in_array($extension, $shared_extensions)) { + $ext->setBuildShared(); + } $this->addExt($ext); } @@ -217,7 +220,7 @@ abstract class BuilderBase foreach ($this->getExts() as $ext) { $ext->checkDependency(); } - $this->ext_list = $extensions; + $this->ext_list = [...$static_extensions, ...$shared_extensions]; } /** diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 3531c891..3c04a298 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -49,9 +49,7 @@ class swoole extends Extension // additional feature: c-ares, brotli, nghttp2 (can be disabled, but we enable it by default in config to support full network feature) $arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : ''; - if (!$this->isBuildShared()) { - $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; - } + $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; $arg .= $this->builder->getLib('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : ''; // additional feature: swoole-pgsql, it should depend on lib [postgresql], but it will lack of CFLAGS etc. diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index f781c0e5..c5fa6c9e 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -171,7 +171,7 @@ class BuildPHPCommand extends BuildCommand // compile libraries $builder->proveLibs($libraries); // check extensions - $builder->proveExts($extensions, shared_build_extensions: $shared_extensions); + $builder->proveExts($extensions, shared_extensions: $shared_extensions); // validate libs and extensions $builder->validateLibsAndExts(); diff --git a/src/SPC/command/dev/ExtVerCommand.php b/src/SPC/command/dev/ExtVerCommand.php index 0f08fa9a..3154a6bb 100644 --- a/src/SPC/command/dev/ExtVerCommand.php +++ b/src/SPC/command/dev/ExtVerCommand.php @@ -6,7 +6,6 @@ namespace SPC\command\dev; use SPC\builder\BuilderProvider; use SPC\command\BaseCommand; -use SPC\store\Config; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -31,8 +30,7 @@ class ExtVerCommand extends BaseCommand // Get lib object $builder = BuilderProvider::makeBuilderByInput($this->input); - $ext_conf = Config::getExt($this->getArgument('extension')); - $builder->proveExts([$this->getArgument('extension')], true); + $builder->proveExts([$this->getArgument('extension')], [], true); // Check whether lib is extracted // if (!is_dir(SOURCE_PATH . '/' . $this->getArgument('library'))) {