mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 15:25:41 +08:00
Merge branch 'main' into ext/gettext
# Conflicts: # config/ext.json # src/globals/test-extensions.php
This commit is contained in:
@@ -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 = [
|
||||
@@ -76,12 +77,23 @@ class BuildCliCommand extends BuildCommand
|
||||
if (!empty($this->input->getOption('with-hardcoded-ini'))) {
|
||||
$indent_texts['Hardcoded INI'] = $this->input->getOption('with-hardcoded-ini');
|
||||
}
|
||||
$this->printFormatInfo($indent_texts);
|
||||
if ($this->input->getOption('disable-opcache-jit')) {
|
||||
$indent_texts['Opcache JIT'] = 'disabled';
|
||||
}
|
||||
try {
|
||||
$ver = $builder->getPHPVersion();
|
||||
$indent_texts['PHP Version'] = $ver;
|
||||
} catch (\Throwable) {
|
||||
if (($ver = $builder->getPHPVersionFromArchive()) !== false) {
|
||||
$indent_texts['PHP Version'] = $ver;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($not_included)) {
|
||||
logger()->warning('Some extensions will be enabled due to dependencies: ' . implode(',', $not_included));
|
||||
$indent_texts['Extra Exts (' . count($not_included) . ')'] = implode(', ', $not_included);
|
||||
}
|
||||
logger()->info('Build will start after 2s ...');
|
||||
$this->printFormatInfo($indent_texts);
|
||||
logger()->notice('Build will start after 2s ...');
|
||||
sleep(2);
|
||||
|
||||
if ($this->input->getOption('with-clean')) {
|
||||
|
||||
@@ -60,7 +60,7 @@ class BuildLibsCommand extends BuildCommand
|
||||
// 只编译 library 的情况下,标记
|
||||
$builder->setLibsOnly();
|
||||
// 编译和检查库完整
|
||||
$libraries = DependencyUtil::getLibsByDeps($libraries);
|
||||
$libraries = DependencyUtil::getLibs($libraries);
|
||||
$builder->buildLibs($libraries);
|
||||
|
||||
$time = round(microtime(true) - START_TIME, 3);
|
||||
|
||||
@@ -214,7 +214,7 @@ class DownloadCommand extends BaseCommand
|
||||
*/
|
||||
private function calculateSourcesByExt(array $extensions, bool $include_suggests = true): array
|
||||
{
|
||||
[$extensions, $libraries] = $include_suggests ? DependencyUtil::getAllExtLibsByDeps($extensions) : DependencyUtil::getExtLibsByDeps($extensions);
|
||||
[$extensions, $libraries] = $include_suggests ? DependencyUtil::getExtsAndLibs($extensions, [], true, true) : DependencyUtil::getExtsAndLibs($extensions);
|
||||
$sources = [];
|
||||
foreach ($extensions as $extension) {
|
||||
if (Config::getExt($extension, 'type') === 'external') {
|
||||
|
||||
@@ -22,8 +22,8 @@ class DumpLicenseCommand extends BaseCommand
|
||||
{
|
||||
$this->addOption('for-extensions', null, InputOption::VALUE_REQUIRED, 'Dump by extensions and related libraries', null);
|
||||
$this->addOption('without-php', null, InputOption::VALUE_NONE, 'Dump without php-src');
|
||||
$this->addOption('by-libs', null, InputOption::VALUE_REQUIRED, 'Dump by libraries', null);
|
||||
$this->addOption('by-sources', null, InputOption::VALUE_REQUIRED, 'Dump by original sources (source.json)', null);
|
||||
$this->addOption('for-libs', null, InputOption::VALUE_REQUIRED, 'Dump by libraries', null);
|
||||
$this->addOption('for-sources', null, InputOption::VALUE_REQUIRED, 'Dump by original sources (source.json)', null);
|
||||
$this->addOption('dump-dir', null, InputOption::VALUE_REQUIRED, 'Change dump directory', BUILD_ROOT_PATH . '/license');
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class DumpLicenseCommand extends BaseCommand
|
||||
// 从参数中获取要编译的 extensions,并转换为数组
|
||||
$extensions = array_map('trim', array_filter(explode(',', $this->getOption('for-extensions'))));
|
||||
// 根据提供的扩展列表获取依赖库列表并编译
|
||||
[$extensions, $libraries] = DependencyUtil::getExtLibsByDeps($extensions);
|
||||
[$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions);
|
||||
$dumper->addExts($extensions);
|
||||
$dumper->addLibs($libraries);
|
||||
if (!$this->getOption('without-php')) {
|
||||
@@ -52,22 +52,22 @@ class DumpLicenseCommand extends BaseCommand
|
||||
$this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir'));
|
||||
return static::SUCCESS;
|
||||
}
|
||||
if ($this->getOption('by-libs') !== null) {
|
||||
$libraries = array_map('trim', array_filter(explode(',', $this->getOption('by-libs'))));
|
||||
$libraries = DependencyUtil::getLibsByDeps($libraries);
|
||||
if ($this->getOption('for-libs') !== null) {
|
||||
$libraries = array_map('trim', array_filter(explode(',', $this->getOption('for-libs'))));
|
||||
$libraries = DependencyUtil::getLibs($libraries);
|
||||
$dumper->addLibs($libraries);
|
||||
$dumper->dump($this->getOption('dump-dir'));
|
||||
$this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir'));
|
||||
return static::SUCCESS;
|
||||
}
|
||||
if ($this->getOption('by-sources') !== null) {
|
||||
$sources = array_map('trim', array_filter(explode(',', $this->getOption('by-sources'))));
|
||||
if ($this->getOption('for-sources') !== null) {
|
||||
$sources = array_map('trim', array_filter(explode(',', $this->getOption('for-sources'))));
|
||||
$dumper->addSources($sources);
|
||||
$dumper->dump($this->getOption('dump-dir'));
|
||||
$this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir'));
|
||||
return static::SUCCESS;
|
||||
}
|
||||
$this->output->writeln('You must use one of "--for-extensions=", "--by-libs=", "--by-sources=" to dump');
|
||||
$this->output->writeln('You must use one of "--for-extensions=", "--for-libs=", "--for-sources=" to dump');
|
||||
return static::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -61,7 +59,7 @@ class AllExtCommand extends BaseCommand
|
||||
}
|
||||
|
||||
try {
|
||||
[, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps([$extension]);
|
||||
[, $libraries, $not_included] = DependencyUtil::getExtsAndLibs([$extension]);
|
||||
} catch (WrongUsageException) {
|
||||
$libraries = $not_included = [];
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user