mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +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->addOption('with-libs', null, InputOption::VALUE_REQUIRED, 'add additional libraries, comma separated', '');
|
||||
$this->addOption('build-micro', null, null, 'build micro');
|
||||
$this->addOption('build-cli', null, null, 'build cli');
|
||||
$this->addOption('build-fpm', null, null, 'build fpm');
|
||||
$this->addOption('build-embed', null, null, 'build embed');
|
||||
$this->addOption('build-all', null, null, 'build cli, micro, fpm, embed');
|
||||
$this->addOption('build-micro', null, null, 'Build micro SAPI');
|
||||
$this->addOption('build-cli', null, null, 'Build cli SAPI');
|
||||
$this->addOption('build-fpm', null, null, 'Build fpm SAPI');
|
||||
$this->addOption('build-embed', null, null, 'Build embed SAPI');
|
||||
$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('enable-zts', null, null, 'enable ZTS support');
|
||||
$this->addOption('disable-opcache-jit', null, null, 'disable opcache jit');
|
||||
@ -61,8 +61,9 @@ class BuildCliCommand extends BuildCommand
|
||||
try {
|
||||
// create builder
|
||||
$builder = BuilderProvider::makeBuilderByInput($this->input);
|
||||
// calculate dependencies
|
||||
[$extensions, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps($extensions, $libraries);
|
||||
$include_suggest_ext = $this->getOption('with-suggested-exts');
|
||||
$include_suggest_lib = $this->getOption('with-suggested-libs');
|
||||
[$extensions, $libraries, $not_included] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
||||
|
||||
// print info
|
||||
$indent_texts = [
|
||||
|
||||
@ -15,8 +15,6 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
use function Laravel\Prompts\table;
|
||||
|
||||
#[AsCommand('dev:extensions', 'Helper command that lists available extension details', ['list-ext'])]
|
||||
class AllExtCommand extends BaseCommand
|
||||
{
|
||||
@ -88,7 +86,8 @@ class AllExtCommand extends BaseCommand
|
||||
if ($data === []) {
|
||||
$style->warning('Unknown extension selected: ' . implode(',', $extensions));
|
||||
} else {
|
||||
table($columns, $data);
|
||||
$func = PHP_OS_FAMILY === 'Windows' ? [$style, 'table'] : '\Laravel\Prompts\table';
|
||||
call_user_func($func, $columns, $data);
|
||||
}
|
||||
|
||||
return static::SUCCESS;
|
||||
|
||||
@ -14,6 +14,20 @@ use SPC\store\Config;
|
||||
*/
|
||||
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
|
||||
*
|
||||
@ -24,7 +38,7 @@ class DependencyUtil
|
||||
* @throws RuntimeException
|
||||
* @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 = [];
|
||||
$visited = [];
|
||||
@ -99,7 +113,7 @@ class DependencyUtil
|
||||
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 = [];
|
||||
$visited = [];
|
||||
@ -109,12 +123,13 @@ class DependencyUtil
|
||||
self::visitExtAllDeps($ext, $visited, $sorted);
|
||||
}
|
||||
}
|
||||
$libs = [];
|
||||
$libs = $additional_libs;
|
||||
foreach ($sorted as $ext) {
|
||||
if (!in_array($ext, $exts)) {
|
||||
$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)) {
|
||||
$libs[] = $dep;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user