Add alt for re2c

This commit is contained in:
crazywhalecc 2025-07-31 01:54:28 +08:00
parent 601444d0a5
commit be857913cd
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 14 additions and 1 deletions

View File

@ -1122,6 +1122,10 @@
"repo": "skvadrik/re2c", "repo": "skvadrik/re2c",
"match": "re2c.+\\.tar\\.xz", "match": "re2c.+\\.tar\\.xz",
"prefer-stable": true, "prefer-stable": true,
"alt": {
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/re2c/re2c-4.3.tar.xz"
},
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE" "path": "LICENSE"

View File

@ -9,6 +9,8 @@ use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\doctor\AsCheckItem; use SPC\doctor\AsCheckItem;
use SPC\doctor\AsFixItem; use SPC\doctor\AsFixItem;
use SPC\doctor\CheckResult; use SPC\doctor\CheckResult;
use SPC\exception\DownloaderException;
use SPC\store\Config;
use SPC\store\Downloader; use SPC\store\Downloader;
use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\ArgvInput;
@ -35,7 +37,14 @@ class Re2cVersionCheck
#[AsFixItem('build-re2c')] #[AsFixItem('build-re2c')]
public function buildRe2c(): bool public function buildRe2c(): bool
{ {
Downloader::downloadSource('re2c'); try {
Downloader::downloadSource('re2c');
} catch (DownloaderException) {
logger()->warning('Failed to download re2c version, trying alternative');
$alt = Config::getSource('re2c');
$alt = [...$alt, ...$alt['alt'] ?? []];
Downloader::downloadSource('re2c', $alt);
}
$builder = BuilderProvider::makeBuilderByInput(new ArgvInput([])); $builder = BuilderProvider::makeBuilderByInput(new ArgvInput([]));
$builder->proveLibs(['re2c']); $builder->proveLibs(['re2c']);
$builder->setupLibs(); $builder->setupLibs();