mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
build static and shared at the same time
This commit is contained in:
parent
0beb97648a
commit
acdec64144
@ -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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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'))) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user