mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
support for php-src switching by downloading different php version (like it was before, essentially)
This commit is contained in:
parent
51ef5e61be
commit
ce7829fd13
@ -134,10 +134,6 @@ class BuildPHPCommand extends BuildCommand
|
|||||||
// Use version-specific php-src
|
// Use version-specific php-src
|
||||||
f_putenv("SPC_PHP_SRC_NAME={$version_specific_name}");
|
f_putenv("SPC_PHP_SRC_NAME={$version_specific_name}");
|
||||||
logger()->info("Building with PHP {$php_version} (using {$version_specific_name})");
|
logger()->info("Building with PHP {$php_version} (using {$version_specific_name})");
|
||||||
} elseif (isset($lock_content['php-src'])) {
|
|
||||||
// Fall back to regular php-src
|
|
||||||
f_putenv('SPC_PHP_SRC_NAME=php-src');
|
|
||||||
logger()->warning("php-src-{$php_version} not found, using default php-src");
|
|
||||||
} else {
|
} else {
|
||||||
logger()->error('No php-src found in downloads. Please run download command first.');
|
logger()->error('No php-src found in downloads. Please run download command first.');
|
||||||
return static::FAILURE;
|
return static::FAILURE;
|
||||||
@ -147,7 +143,6 @@ class BuildPHPCommand extends BuildCommand
|
|||||||
return static::FAILURE;
|
return static::FAILURE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No version specified, use default php-src
|
|
||||||
f_putenv('SPC_PHP_SRC_NAME=php-src');
|
f_putenv('SPC_PHP_SRC_NAME=php-src');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -280,8 +280,9 @@ class DownloadCommand extends BaseCommand
|
|||||||
logger()->warning("Pre-built content not found for {$source}, fallback to source download");
|
logger()->warning("Pre-built content not found for {$source}, fallback to source download");
|
||||||
}
|
}
|
||||||
logger()->info("[{$ni}/{$cnt}] Downloading source {$source}");
|
logger()->info("[{$ni}/{$cnt}] Downloading source {$source}");
|
||||||
|
$force_download = $force_all || in_array($source, $force_list) || str_starts_with($source, 'php-src-') && in_array('php-src', $force_list);
|
||||||
try {
|
try {
|
||||||
Downloader::downloadSource($source, $config, $force_all || in_array($source, $force_list));
|
Downloader::downloadSource($source, $config, $force_download);
|
||||||
} catch (SPCException $e) {
|
} catch (SPCException $e) {
|
||||||
// if `--no-alt` option is set, we will not download alternative sources
|
// if `--no-alt` option is set, we will not download alternative sources
|
||||||
if ($this->getOption('no-alt')) {
|
if ($this->getOption('no-alt')) {
|
||||||
@ -299,7 +300,7 @@ class DownloadCommand extends BaseCommand
|
|||||||
logger()->notice("Trying to download alternative sources for {$source}");
|
logger()->notice("Trying to download alternative sources for {$source}");
|
||||||
$alt_config = array_merge($config, $alt_sources);
|
$alt_config = array_merge($config, $alt_sources);
|
||||||
}
|
}
|
||||||
Downloader::downloadSource($source, $alt_config, $force_all || in_array($source, $force_list));
|
Downloader::downloadSource($source, $alt_config, $force_download);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ namespace SPC\store\source;
|
|||||||
use JetBrains\PhpStorm\ArrayShape;
|
use JetBrains\PhpStorm\ArrayShape;
|
||||||
use SPC\exception\DownloaderException;
|
use SPC\exception\DownloaderException;
|
||||||
use SPC\store\Downloader;
|
use SPC\store\Downloader;
|
||||||
|
use SPC\store\LockFile;
|
||||||
|
|
||||||
class PhpSource extends CustomSourceBase
|
class PhpSource extends CustomSourceBase
|
||||||
{
|
{
|
||||||
@ -28,6 +29,10 @@ class PhpSource extends CustomSourceBase
|
|||||||
} else {
|
} else {
|
||||||
Downloader::downloadSource($source_name, $this->getLatestPHPInfo($major), $force);
|
Downloader::downloadSource($source_name, $this->getLatestPHPInfo($major), $force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($source_name !== 'php-src') {
|
||||||
|
LockFile::put('php-src', LockFile::get($source_name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(array $lock, ?array $config = null): ?array
|
public function update(array $lock, ?array $config = null): ?array
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user