Merge pull request #689 from crazywhalecc/fix/extract-source-only

Add extract source only mode for SourceManager
This commit is contained in:
Jerry Ma 2025-03-31 21:56:51 +08:00 committed by GitHub
commit d4b263bc9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 6 deletions

View File

@ -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');

View File

@ -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');
}

View File

@ -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;
}

View File

@ -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 !");
}