mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-09 01:45:36 +08:00
Add extract source only mode for SourceManager
This commit is contained in:
@@ -174,11 +174,11 @@ abstract class BuilderBase
|
|||||||
{
|
{
|
||||||
CustomExt::loadCustomExt();
|
CustomExt::loadCustomExt();
|
||||||
$this->emitPatchPoint('before-php-extract');
|
$this->emitPatchPoint('before-php-extract');
|
||||||
SourceManager::initSource(sources: ['php-src']);
|
SourceManager::initSource(sources: ['php-src'], source_only: true);
|
||||||
$this->emitPatchPoint('after-php-extract');
|
$this->emitPatchPoint('after-php-extract');
|
||||||
if ($this->getPHPVersionID() >= 80000) {
|
if ($this->getPHPVersionID() >= 80000) {
|
||||||
$this->emitPatchPoint('before-micro-extract');
|
$this->emitPatchPoint('before-micro-extract');
|
||||||
SourceManager::initSource(sources: ['micro']);
|
SourceManager::initSource(sources: ['micro'], source_only: true);
|
||||||
$this->emitPatchPoint('after-micro-extract');
|
$this->emitPatchPoint('after-micro-extract');
|
||||||
}
|
}
|
||||||
$this->emitPatchPoint('before-exts-extract');
|
$this->emitPatchPoint('before-exts-extract');
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ abstract class LibraryBase
|
|||||||
// extract first if not exists
|
// extract first if not exists
|
||||||
if (!is_dir($this->source_dir)) {
|
if (!is_dir($this->source_dir)) {
|
||||||
$this->getBuilder()->emitPatchPoint('before-library[ ' . static::NAME . ']-extract');
|
$this->getBuilder()->emitPatchPoint('before-library[ ' . static::NAME . ']-extract');
|
||||||
SourceManager::initSource(libs: [static::NAME]);
|
SourceManager::initSource(libs: [static::NAME], source_only: true);
|
||||||
$this->getBuilder()->emitPatchPoint('after-library[ ' . static::NAME . ']-extract');
|
$this->getBuilder()->emitPatchPoint('after-library[ ' . static::NAME . ']-extract');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class ExtractCommand extends BaseCommand
|
|||||||
public function configure(): void
|
public function configure(): void
|
||||||
{
|
{
|
||||||
$this->addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated');
|
$this->addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated');
|
||||||
|
$this->addOption('source-only', null, null, 'Only check the source exist, do not check the lib and ext');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +35,7 @@ class ExtractCommand extends BaseCommand
|
|||||||
$this->output->writeln('<error>sources cannot be empty, at least contain one !</error>');
|
$this->output->writeln('<error>sources cannot be empty, at least contain one !</error>');
|
||||||
return static::FAILURE;
|
return static::FAILURE;
|
||||||
}
|
}
|
||||||
SourceManager::initSource(sources: $sources);
|
SourceManager::initSource(sources: $sources, source_only: $this->getOption('source-only'));
|
||||||
logger()->info('Extract done !');
|
logger()->info('Extract done !');
|
||||||
return static::SUCCESS;
|
return static::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class SourceManager
|
|||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public static function initSource(?array $sources = null, ?array $libs = null, ?array $exts = null): void
|
public static function initSource(?array $sources = null, ?array $libs = null, ?array $exts = null, bool $source_only = false): void
|
||||||
{
|
{
|
||||||
if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) {
|
if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) {
|
||||||
throw new WrongUsageException('Download lock file "downloads/.lock.json" not found, maybe you need to download sources first ?');
|
throw new WrongUsageException('Download lock file "downloads/.lock.json" not found, maybe you need to download sources first ?');
|
||||||
@@ -56,7 +56,7 @@ class SourceManager
|
|||||||
}
|
}
|
||||||
// check source downloaded
|
// check source downloaded
|
||||||
$pre_built_name = Downloader::getPreBuiltLockName($source);
|
$pre_built_name = Downloader::getPreBuiltLockName($source);
|
||||||
if (!isset($lock[$pre_built_name])) {
|
if ($source_only || !isset($lock[$pre_built_name])) {
|
||||||
if (!isset($lock[$source])) {
|
if (!isset($lock[$source])) {
|
||||||
throw new WrongUsageException("Source [{$source}] not downloaded or not locked, you should download it first !");
|
throw new WrongUsageException("Source [{$source}] not downloaded or not locked, you should download it first !");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user