From 973c8f082f4965bbeaa8ea4ee4537082d90a5352 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 28 Jul 2025 15:36:53 +0800 Subject: [PATCH] Add php-src git version support --- src/SPC/command/DownloadCommand.php | 9 +++------ src/SPC/store/source/PhpSource.php | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index dfa4c9ee..ddcb50ae 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -108,12 +108,9 @@ class DownloadCommand extends BaseCommand // Define PHP major version $ver = $this->php_major_ver = $this->getOption('with-php'); define('SPC_BUILD_PHP_VERSION', $ver); - // match x.y - preg_match('/^\d+\.\d+$/', $ver, $matches); - if (!$matches) { - // match x.y.z - preg_match('/^\d+\.\d+\.\d+$/', $ver, $matches); - if (!$matches) { + if ($ver !== 'git' && !preg_match('/^\d+\.\d+$/', $ver)) { + // If not git, we need to check the version format + if (!preg_match('/^\d+\.\d+(\.\d+)?$/', $ver)) { logger()->error("bad version arg: {$ver}, x.y or x.y.z required!"); return static::FAILURE; } diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index 2a6ae268..e877169d 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -22,6 +22,8 @@ class PhpSource extends CustomSourceBase $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.4'; if ($major === '8.5') { Downloader::downloadSource('php-src', ['type' => 'url', 'url' => 'https://downloads.php.net/~edorian/php-8.5.0alpha2.tar.xz'], $force); + } elseif ($major === 'git') { + Downloader::downloadSource('php-src', ['type' => 'git', 'url' => 'https://github.com/php/php-src.git', 'rev' => 'master'], $force); } else { Downloader::downloadSource('php-src', self::getLatestPHPInfo($major), $force); }