don't run extra logic in zig-cc script if there's no version string in SPC_TARGET

This commit is contained in:
DubbleClick 2025-07-03 14:46:07 +07:00
parent 3444e308fd
commit e5c5b77a9a
2 changed files with 16 additions and 12 deletions

View File

@ -28,18 +28,20 @@ done
[[ -n "$SPC_TARGET" ]] && TARGET="-target $SPC_TARGET" || TARGET=""
output=$(zig cc $TARGET $COMPILER_EXTRA "${PARSED_ARGS[@]}" 2>&1)
status=$?
if [[ "$SPC_TARGET" =~ \.[0-9]+\.[0-9]+ ]]; then
output=$(zig cc $TARGET $COMPILER_EXTRA "${PARSED_ARGS[@]}" 2>&1)
status=$?
if [[ $status -eq 0 ]]; then
echo "$output"
exit 0
fi
if [[ $status -eq 0 ]]; then
echo "$output"
exit 0
fi
if echo "$output" | grep -qE "version '.*' in target triple"; then
filtered_output=$(echo "$output" | grep -vE "version '.*' in target triple")
echo "$filtered_output"
exit 0
if echo "$output" | grep -qE "version '.*' in target triple"; then
filtered_output=$(echo "$output" | grep -vE "version '.*' in target triple")
echo "$filtered_output"
exit 0
fi
fi
exec zig cc $TARGET $COMPILER_EXTRA "${PARSED_ARGS[@]}"

View File

@ -7,6 +7,7 @@ namespace SPC\store\source;
use JetBrains\PhpStorm\ArrayShape;
use SPC\exception\DownloaderException;
use SPC\exception\FileSystemException;
use SPC\exception\WrongUsageException;
use SPC\store\Downloader;
class PhpSource extends CustomSourceBase
@ -16,11 +17,12 @@ class PhpSource extends CustomSourceBase
/**
* @throws DownloaderException
* @throws FileSystemException
* @throws WrongUsageException
*/
public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_SOURCE): void
{
$major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.3';
Downloader::downloadSource('php-src', self::getLatestPHPInfo($major), $force);
Downloader::downloadSource('php-src', $this->getLatestPHPInfo($major), $force);
}
/**
@ -34,7 +36,7 @@ class PhpSource extends CustomSourceBase
// 查找最新的小版本号
$info = json_decode(Downloader::curlExec(
url: "https://www.php.net/releases/index.php?json&version={$major_version}",
retries: intval(getenv('SPC_DOWNLOAD_RETRIES') ?: 0)
retries: (int) getenv('SPC_DOWNLOAD_RETRIES')
), true);
if (!isset($info['version'])) {
throw new DownloaderException("Version {$major_version} not found.");