mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
add with-suggested-libs and with-suggested-exts
This commit is contained in:
parent
39754cde59
commit
1e898d271d
@ -23,11 +23,11 @@ class BuildCliCommand extends BuildCommand
|
|||||||
{
|
{
|
||||||
$this->addArgument('extensions', InputArgument::REQUIRED, 'The extensions will be compiled, comma separated');
|
$this->addArgument('extensions', InputArgument::REQUIRED, 'The extensions will be compiled, comma separated');
|
||||||
$this->addOption('with-libs', null, InputOption::VALUE_REQUIRED, 'add additional libraries, comma separated', '');
|
$this->addOption('with-libs', null, InputOption::VALUE_REQUIRED, 'add additional libraries, comma separated', '');
|
||||||
$this->addOption('build-micro', null, null, 'build micro');
|
$this->addOption('build-micro', null, null, 'Build micro SAPI');
|
||||||
$this->addOption('build-cli', null, null, 'build cli');
|
$this->addOption('build-cli', null, null, 'Build cli SAPI');
|
||||||
$this->addOption('build-fpm', null, null, 'build fpm');
|
$this->addOption('build-fpm', null, null, 'Build fpm SAPI');
|
||||||
$this->addOption('build-embed', null, null, 'build embed');
|
$this->addOption('build-embed', null, null, 'Build embed SAPI');
|
||||||
$this->addOption('build-all', null, null, 'build cli, micro, fpm, embed');
|
$this->addOption('build-all', null, null, 'Build all SAPI');
|
||||||
$this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions');
|
$this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions');
|
||||||
$this->addOption('enable-zts', null, null, 'enable ZTS support');
|
$this->addOption('enable-zts', null, null, 'enable ZTS support');
|
||||||
$this->addOption('disable-opcache-jit', null, null, 'disable opcache jit');
|
$this->addOption('disable-opcache-jit', null, null, 'disable opcache jit');
|
||||||
@ -61,8 +61,9 @@ class BuildCliCommand extends BuildCommand
|
|||||||
try {
|
try {
|
||||||
// create builder
|
// create builder
|
||||||
$builder = BuilderProvider::makeBuilderByInput($this->input);
|
$builder = BuilderProvider::makeBuilderByInput($this->input);
|
||||||
// calculate dependencies
|
$include_suggest_ext = $this->getOption('with-suggested-exts');
|
||||||
[$extensions, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps($extensions, $libraries);
|
$include_suggest_lib = $this->getOption('with-suggested-libs');
|
||||||
|
[$extensions, $libraries, $not_included] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
||||||
|
|
||||||
// print info
|
// print info
|
||||||
$indent_texts = [
|
$indent_texts = [
|
||||||
|
|||||||
@ -15,8 +15,6 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
use function Laravel\Prompts\table;
|
|
||||||
|
|
||||||
#[AsCommand('dev:extensions', 'Helper command that lists available extension details', ['list-ext'])]
|
#[AsCommand('dev:extensions', 'Helper command that lists available extension details', ['list-ext'])]
|
||||||
class AllExtCommand extends BaseCommand
|
class AllExtCommand extends BaseCommand
|
||||||
{
|
{
|
||||||
@ -88,7 +86,8 @@ class AllExtCommand extends BaseCommand
|
|||||||
if ($data === []) {
|
if ($data === []) {
|
||||||
$style->warning('Unknown extension selected: ' . implode(',', $extensions));
|
$style->warning('Unknown extension selected: ' . implode(',', $extensions));
|
||||||
} else {
|
} else {
|
||||||
table($columns, $data);
|
$func = PHP_OS_FAMILY === 'Windows' ? [$style, 'table'] : '\Laravel\Prompts\table';
|
||||||
|
call_user_func($func, $columns, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return static::SUCCESS;
|
return static::SUCCESS;
|
||||||
|
|||||||
@ -14,6 +14,20 @@ use SPC\store\Config;
|
|||||||
*/
|
*/
|
||||||
class DependencyUtil
|
class DependencyUtil
|
||||||
{
|
{
|
||||||
|
public static function getExtsAndLibs(array $exts, array $additional_libs = [], bool $include_suggested_exts = false, bool $include_suggested_libs = false): array
|
||||||
|
{
|
||||||
|
if (!$include_suggested_exts && !$include_suggested_libs) {
|
||||||
|
return self::getExtLibsByDeps($exts, $additional_libs);
|
||||||
|
}
|
||||||
|
if ($include_suggested_exts && $include_suggested_libs) {
|
||||||
|
return self::getAllExtLibsByDeps($exts, $additional_libs);
|
||||||
|
}
|
||||||
|
if (!$include_suggested_exts) {
|
||||||
|
return self::getExtLibsByDeps($exts, $additional_libs);
|
||||||
|
}
|
||||||
|
return self::getAllExtLibsByDeps($exts, $additional_libs, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the dependent lib list according to the required ext list, and sort according to the dependency
|
* Obtain the dependent lib list according to the required ext list, and sort according to the dependency
|
||||||
*
|
*
|
||||||
@ -24,7 +38,7 @@ class DependencyUtil
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
*/
|
*/
|
||||||
public static function getExtLibsByDeps(array $exts, array $additional_libs = []): array
|
public static function getExtLibsByDeps(array $exts, array $additional_libs = [], bool $include_suggested_exts = false): array
|
||||||
{
|
{
|
||||||
$sorted = [];
|
$sorted = [];
|
||||||
$visited = [];
|
$visited = [];
|
||||||
@ -99,7 +113,7 @@ class DependencyUtil
|
|||||||
return $final;
|
return $final;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllExtLibsByDeps(array $exts): array
|
public static function getAllExtLibsByDeps(array $exts, array $additional_libs = [], bool $include_suggested_libs = true): array
|
||||||
{
|
{
|
||||||
$sorted = [];
|
$sorted = [];
|
||||||
$visited = [];
|
$visited = [];
|
||||||
@ -109,12 +123,13 @@ class DependencyUtil
|
|||||||
self::visitExtAllDeps($ext, $visited, $sorted);
|
self::visitExtAllDeps($ext, $visited, $sorted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$libs = [];
|
$libs = $additional_libs;
|
||||||
foreach ($sorted as $ext) {
|
foreach ($sorted as $ext) {
|
||||||
if (!in_array($ext, $exts)) {
|
if (!in_array($ext, $exts)) {
|
||||||
$not_included_exts[] = $ext;
|
$not_included_exts[] = $ext;
|
||||||
}
|
}
|
||||||
foreach (array_merge(Config::getExt($ext, 'lib-depends', []), Config::getExt($ext, 'lib-suggests', [])) as $dep) {
|
$total = $include_suggested_libs ? array_merge(Config::getExt($ext, 'lib-depends', []), Config::getExt($ext, 'lib-suggests', [])) : Config::getExt($ext, 'lib-depends', []);
|
||||||
|
foreach ($total as $dep) {
|
||||||
if (!in_array($dep, $libs)) {
|
if (!in_array($dep, $libs)) {
|
||||||
$libs[] = $dep;
|
$libs[] = $dep;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user