mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 14:25:41 +08:00
build static and shared at the same time
This commit is contained in:
@@ -122,9 +122,9 @@ abstract class BuilderBase
|
|||||||
*
|
*
|
||||||
* @return Extension[]
|
* @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 $this->exts;
|
||||||
}
|
}
|
||||||
return array_filter($this->exts, fn ($ext) => !$ext->isBuildShared());
|
return array_filter($this->exts, fn ($ext) => !$ext->isBuildShared());
|
||||||
@@ -173,18 +173,20 @@ abstract class BuilderBase
|
|||||||
* @throws \Throwable|WrongUsageException
|
* @throws \Throwable|WrongUsageException
|
||||||
* @internal
|
* @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();
|
CustomExt::loadCustomExt();
|
||||||
// judge ext
|
// judge ext
|
||||||
foreach ($extensions as $ext) {
|
foreach ($static_extensions as $ext) {
|
||||||
// if extension does not support static && no shared build, throw exception
|
// if extension does not support static build, throw exception
|
||||||
if (!in_array('static', Config::getExtTarget($ext)) && !in_array($ext, $shared_build_extensions)) {
|
if (!in_array('static', Config::getExtTarget($ext))) {
|
||||||
throw new WrongUsageException('Extension [' . $ext . '] does not support static build !');
|
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)) {
|
foreach ($shared_extensions as $ext) {
|
||||||
throw new WrongUsageException('Extension [' . $ext . '] does not support shared build !');
|
// 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');
|
$this->emitPatchPoint('before-php-extract');
|
||||||
@@ -196,17 +198,18 @@ abstract class BuilderBase
|
|||||||
$this->emitPatchPoint('after-micro-extract');
|
$this->emitPatchPoint('after-micro-extract');
|
||||||
}
|
}
|
||||||
$this->emitPatchPoint('before-exts-extract');
|
$this->emitPatchPoint('before-exts-extract');
|
||||||
SourceManager::initSource(exts: $extensions);
|
SourceManager::initSource(exts: $static_extensions);
|
||||||
$this->emitPatchPoint('after-exts-extract');
|
$this->emitPatchPoint('after-exts-extract');
|
||||||
foreach ($extensions as $extension) {
|
foreach ([...$static_extensions, ...$shared_extensions] as $extension) {
|
||||||
$class = CustomExt::getExtClass($extension);
|
$class = CustomExt::getExtClass($extension);
|
||||||
/** @var Extension $ext */
|
/** @var Extension $ext */
|
||||||
$ext = new $class($extension, $this);
|
$ext = new $class($extension, $this);
|
||||||
if (in_array($extension, $shared_build_extensions)) {
|
if (in_array($extension, $static_extensions)) {
|
||||||
$ext->setBuildShared();
|
|
||||||
} else {
|
|
||||||
$ext->setBuildStatic();
|
$ext->setBuildStatic();
|
||||||
}
|
}
|
||||||
|
if (in_array($extension, $shared_extensions)) {
|
||||||
|
$ext->setBuildShared();
|
||||||
|
}
|
||||||
$this->addExt($ext);
|
$this->addExt($ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +220,7 @@ abstract class BuilderBase
|
|||||||
foreach ($this->getExts() as $ext) {
|
foreach ($this->getExts() as $ext) {
|
||||||
$ext->checkDependency();
|
$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)
|
// 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' : '';
|
$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) : '';
|
$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.
|
// 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
|
// compile libraries
|
||||||
$builder->proveLibs($libraries);
|
$builder->proveLibs($libraries);
|
||||||
// check extensions
|
// check extensions
|
||||||
$builder->proveExts($extensions, shared_build_extensions: $shared_extensions);
|
$builder->proveExts($extensions, shared_extensions: $shared_extensions);
|
||||||
// validate libs and extensions
|
// validate libs and extensions
|
||||||
$builder->validateLibsAndExts();
|
$builder->validateLibsAndExts();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ namespace SPC\command\dev;
|
|||||||
|
|
||||||
use SPC\builder\BuilderProvider;
|
use SPC\builder\BuilderProvider;
|
||||||
use SPC\command\BaseCommand;
|
use SPC\command\BaseCommand;
|
||||||
use SPC\store\Config;
|
|
||||||
use Symfony\Component\Console\Attribute\AsCommand;
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
@@ -31,8 +30,7 @@ class ExtVerCommand extends BaseCommand
|
|||||||
// Get lib object
|
// Get lib object
|
||||||
$builder = BuilderProvider::makeBuilderByInput($this->input);
|
$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
|
// Check whether lib is extracted
|
||||||
// if (!is_dir(SOURCE_PATH . '/' . $this->getArgument('library'))) {
|
// if (!is_dir(SOURCE_PATH . '/' . $this->getArgument('library'))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user