static-php-cli/src/StaticPHP/Command/BuildLibsCommand.php

43 lines
1.6 KiB
PHP
Raw Normal View History

2025-11-30 15:35:04 +08:00
<?php
declare(strict_types=1);
namespace StaticPHP\Command;
use StaticPHP\Artifact\DownloaderOptions;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Util\V2CompatLayer;
2025-11-30 15:35:04 +08:00
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
2025-11-30 15:35:04 +08:00
2026-02-02 15:35:59 +08:00
#[AsCommand('build:libs', 'Build specified library packages')]
2025-11-30 15:35:04 +08:00
class BuildLibsCommand extends BaseCommand
{
2026-02-02 15:35:59 +08:00
public function configure(): void
2025-11-30 15:35:04 +08:00
{
$this->addArgument('libraries', InputArgument::REQUIRED, 'The library packages will be compiled, comma separated');
// Builder options
$this->getDefinition()->addOptions([
new InputOption('with-suggests', ['L', 'E'], null, 'Resolve and install suggested packages as well'),
new InputOption('with-packages', null, InputOption::VALUE_REQUIRED, 'add additional packages to install/build, comma separated', ''),
new InputOption('no-download', null, null, 'Skip downloading artifacts (use existing cached files)'),
...V2CompatLayer::getLegacyBuildOptions(),
]);
// Downloader options (with 'dl-' prefix to avoid conflicts)
$this->getDefinition()->addOptions(DownloaderOptions::getConsoleOptions('dl'));
2025-11-30 15:35:04 +08:00
}
public function handle(): int
{
$libs = parse_comma_list($this->input->getArgument('libraries'));
$installer = new PackageInstaller($this->input->getOptions());
2025-11-30 15:35:04 +08:00
foreach ($libs as $lib) {
$installer->addBuildPackage($lib);
}
$installer->run();
return static::SUCCESS;
}
}