mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
Merge pull request #689 from crazywhalecc/fix/extract-source-only
Add extract source only mode for SourceManager
This commit is contained in:
commit
d4b263bc9f
@ -174,11 +174,11 @@ abstract class BuilderBase
|
||||
{
|
||||
CustomExt::loadCustomExt();
|
||||
$this->emitPatchPoint('before-php-extract');
|
||||
SourceManager::initSource(sources: ['php-src']);
|
||||
SourceManager::initSource(sources: ['php-src'], source_only: true);
|
||||
$this->emitPatchPoint('after-php-extract');
|
||||
if ($this->getPHPVersionID() >= 80000) {
|
||||
$this->emitPatchPoint('before-micro-extract');
|
||||
SourceManager::initSource(sources: ['micro']);
|
||||
SourceManager::initSource(sources: ['micro'], source_only: true);
|
||||
$this->emitPatchPoint('after-micro-extract');
|
||||
}
|
||||
$this->emitPatchPoint('before-exts-extract');
|
||||
|
||||
@ -222,7 +222,7 @@ abstract class LibraryBase
|
||||
// extract first if not exists
|
||||
if (!is_dir($this->source_dir)) {
|
||||
$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');
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ class ExtractCommand extends BaseCommand
|
||||
public function configure(): void
|
||||
{
|
||||
$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>');
|
||||
return static::FAILURE;
|
||||
}
|
||||
SourceManager::initSource(sources: $sources);
|
||||
SourceManager::initSource(sources: $sources, source_only: $this->getOption('source-only'));
|
||||
logger()->info('Extract done !');
|
||||
return static::SUCCESS;
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ class SourceManager
|
||||
* @throws FileSystemException
|
||||
* @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')) {
|
||||
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
|
||||
$pre_built_name = Downloader::getPreBuiltLockName($source);
|
||||
if (!isset($lock[$pre_built_name])) {
|
||||
if ($source_only || !isset($lock[$pre_built_name])) {
|
||||
if (!isset($lock[$source])) {
|
||||
throw new WrongUsageException("Source [{$source}] not downloaded or not locked, you should download it first !");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user