Compare commits

...

20 Commits

Author SHA1 Message Date
crazywhalecc
e4201a28ca Add 'imagick' and 'intl' to standalone array 2026-05-08 23:11:48 +08:00
crazywhalecc
1b30c98fbd Make glfw standalone though 2026-05-08 22:51:49 +08:00
crazywhalecc
61747f6f4e Add frameworks for glfw 2026-05-08 22:51:17 +08:00
crazywhalecc
c374163a05 Fix windows mpir build 2026-05-08 22:37:05 +08:00
crazywhalecc
ee21199ebb Remove hosted binary temporarily 2026-05-08 22:33:06 +08:00
crazywhalecc
01607a06c9 Add spx compatible command arg 2026-05-08 22:32:50 +08:00
crazywhalecc
fd4bf90a70 Add standalone list 2026-05-08 22:23:14 +08:00
crazywhalecc
73bf9ff93f Add libzstd.lib for windows builds 2026-05-08 22:13:50 +08:00
crazywhalecc
dcf1c5942c Add macOS test, conflicts 2026-05-08 22:12:06 +08:00
crazywhalecc
4695f846f5 Add macOS test 2026-05-08 21:23:29 +08:00
crazywhalecc
37b5f89ee1 Add extra build flags for specific extensions 2026-05-08 21:07:49 +08:00
crazywhalecc
5e40982e85 Use windows-latest 2026-05-08 20:58:33 +08:00
crazywhalecc
1d1f58f3a1 Disable parallel downloading 2026-05-08 20:55:23 +08:00
crazywhalecc
be039802c0 Add exclude for gen-ext-test-matrix 2026-05-08 20:54:41 +08:00
crazywhalecc
5529e66a61 Add dom deps for xmlreader 2026-05-08 19:33:19 +08:00
crazywhalecc
641ad8becf Add patch for PHP 8.2 compatibility in imap extension 2026-05-08 19:27:11 +08:00
crazywhalecc
a19c4470bb Fix frameworks in unix cmake executor wrongly used by linux 2026-05-08 19:11:31 +08:00
crazywhalecc
143ae4b8c4 Use -i instead of -I (-I used by hardcoded INI) 2026-05-08 19:08:00 +08:00
crazywhalecc
a980b0a1df Use -i instead of -I (-I used by hardcoded INI) 2026-05-08 19:07:39 +08:00
crazywhalecc
a8a851659f Fix memcache build on PHP 8.5 2026-05-08 19:07:06 +08:00
26 changed files with 168 additions and 42 deletions

View File

@@ -1,5 +1,4 @@
ncurses:
binary: hosted
metadata:
license-files:
- COPYING

View File

@@ -348,6 +348,7 @@ ext-xmlreader:
type: php-extension
depends:
- ext-xml
- ext-dom
php-extension:
arg-type: enable
build-with-php: true

View File

@@ -5,7 +5,6 @@ brotli:
type: ghtagtar
repo: google/brotli
match: 'v1\.\d.*'
binary: hosted
metadata:
license-files: [LICENSE]
license: MIT

View File

@@ -8,7 +8,6 @@ bzip2:
type: filelist
url: 'https://sourceware.org/pub/bzip2/'
regex: '/href="(?<file>bzip2-(?<version>[^"]+)\.tar\.gz)"/'
binary: hosted
metadata:
license-files: ['@/bzip2.txt']
license: bzip2-1.0.6

View File

@@ -1,6 +1,12 @@
glfw:
type: library
artifact: glfw
frameworks:
- Cocoa
- CoreFoundation
- CoreVideo
- IOKit
- QuartzCore
headers:
- GLFW/glfw3.h
- GLFW/glfw3native.h

View File

@@ -10,7 +10,6 @@ libcares:
type: filelist
url: 'https://c-ares.org/download/'
regex: '/href="\/download\/(?<file>c-ares-(?<version>[^"]+)\.tar\.gz)"/'
binary: hosted
metadata:
license-files: [LICENSE.md]
headers@unix:

View File

@@ -5,7 +5,6 @@ libedit:
type: filelist
url: 'https://thrysoee.dk/editline/'
regex: '/href="(?<file>libedit-(?<version>[^"]+)\.tar\.gz)"/'
binary: hosted
metadata:
license-files: [COPYING]
license: BSD-3-Clause

View File

@@ -5,7 +5,6 @@ libiconv:
type: filelist
url: 'https://ftp.gnu.org/gnu/libiconv/'
regex: '/href="(?<file>libiconv-(?<version>[^"]+)\.tar\.gz)"/'
binary: hosted
metadata:
license-files: [COPYING.LIB]
license: LGPL-2.0-or-later

View File

@@ -6,7 +6,6 @@ libpng:
repo: pnggroup/libpng
match: v1\.6\.\d+
query: '?per_page=150'
binary: hosted
metadata:
license-files: [LICENSE]
license: PNG

View File

@@ -6,7 +6,6 @@ libsodium:
repo: jedisct1/libsodium
match: 'libsodium-(?!1\.0\.21)\d+(\.\d+)*\.tar\.gz'
prefer-stable: true
binary: hosted
metadata:
license-files: [LICENSE]
pkg-configs:

View File

@@ -6,7 +6,6 @@ libssh2:
repo: libssh2/libssh2
match: libssh2.+\.tar\.gz
prefer-stable: true
binary: hosted
metadata:
license-files: [COPYING]
license: BSD-3-Clause

View File

@@ -5,7 +5,6 @@ libunistring:
type: filelist
url: 'https://ftp.gnu.org/gnu/libunistring/'
regex: '/href="(?<file>libunistring-(?<version>[^"]+)\.tar\.gz)"/'
binary: hosted
metadata:
license-files: [COPYING.LIB]
license: LGPL-3.0-or-later

View File

@@ -10,7 +10,6 @@ openssl:
type: filelist
url: 'https://www.openssl.org/source/'
regex: '/href="(?<file>openssl-(?<version>3\.[^"]+)\.tar\.gz)"/'
binary: hosted
metadata:
license-files: [LICENSE.txt]
license: OpenSSL

View File

@@ -6,7 +6,6 @@ xz:
repo: tukaani-project/xz
match: xz.+\.tar\.xz
prefer-stable: true
binary: hosted
metadata:
license-files: [COPYING]
license: 0BSD

View File

@@ -5,7 +5,6 @@ zlib:
type: ghrel
repo: madler/zlib
match: zlib.+\.tar\.gz
binary: hosted
metadata:
license-files: ['@/zlib.txt']
license: Zlib-Custom

View File

@@ -19,3 +19,4 @@ zstd:
- libzstd.a
static-libs@windows:
- zstd.lib
- libzstd.lib

View File

@@ -36,7 +36,7 @@ spc download [artifacts] [options]
| `--binary-only` | | Only download binary artifacts |
| `--parallel=<n>` | `-P` | Number of parallel downloads (default: `1`) |
| `--retry=<n>` | `-R` | Number of retries on failure (default: `0`) |
| `--ignore-cache=<list>` | | Force re-download the specified artifacts |
| `--ignore-cache=<list>` | `-i` | Force re-download the specified artifacts |
| `--no-alt` | | Do not use alternative mirror URLs |
| `--no-shallow-clone` | | Do not clone git repositories shallowly |
| `--custom-url=<src:url>` | `-U` | Override the download URL for a source |

View File

@@ -22,23 +22,23 @@ spc download [artifacts] [options]
### 选项
| 选项 | 缩写 | 说明 |
|---|---|---|
| 选项 | 缩写 | 说明 |
|---|------|---|
| `--for-extensions=<list>` | `-e` | 按扩展名下载其所需的制品 |
| `--for-libs=<list>` | `-l` | 按库名下载其所需的制品 |
| `--for-packages=<list>` | | 按包名下载其所需的制品 |
| `--without-suggests` | | 使用 `--for-extensions` 时跳过建议包 |
| `--clean` | | 下载前删除旧的下载缓存 |
| `--with-php=<ver>` | | PHP 版本,格式为 `major.minor`(默认 `8.4`|
| `--for-packages=<list>` | | 按包名下载其所需的制品 |
| `--without-suggests` | | 使用 `--for-extensions` 时跳过建议包 |
| `--clean` | | 下载前删除旧的下载缓存 |
| `--with-php=<ver>` | | PHP 版本,格式为 `major.minor`(默认 `8.4`|
| `--prefer-binary` | `-p` | 优先使用预编译二进制 |
| `--prefer-source` | | 优先使用源码包 |
| `--source-only` | | 仅下载源码制品 |
| `--binary-only` | | 仅下载二进制制品 |
| `--prefer-source` | | 优先使用源码包 |
| `--source-only` | | 仅下载源码制品 |
| `--binary-only` | | 仅下载二进制制品 |
| `--parallel=<n>` | `-P` | 并行下载数(默认 `1`|
| `--retry=<n>` | `-R` | 失败重试次数(默认 `0`|
| `--ignore-cache=<list>` | | 强制重新下载指定制品 |
| `--no-alt` | | 不使用镜像站 |
| `--no-shallow-clone` | | 不使用浅层克隆 |
| `--ignore-cache=<list>` | `-i` | 强制重新下载指定制品 |
| `--no-alt` | | 不使用镜像站 |
| `--no-shallow-clone` | | 不使用浅层克隆 |
| `--custom-url=<src:url>` | `-U` | 覆盖指定源的下载地址 |
| `--custom-git=<src:branch:url>` | `-G` | 覆盖为自定义 git 仓库 |
| `--custom-local=<src:path>` | `-L` | 使用本地路径作为制品来源 |

View File

@@ -9,6 +9,7 @@ use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\Package\Validate;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Exception\WrongUsageException;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Package\PackageInstaller;
@@ -26,6 +27,19 @@ class imap extends PhpExtensionPackage
}
}
#[BeforeStage('php', [php::class, 'makeCliForUnix'], 'ext-imap')]
#[PatchDescription('Fix imap zend_zval_value_name() call for PHP 8.2 compatibility')]
public function patchBeforeMake(): void
{
// zend_zval_value_name() was introduced in PHP 8.3; PHP 8.2 imap backported the call but not the declaration
// replace with the equivalent PHP 8.2-compatible function
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/php_imap.c",
'zend_zval_value_name(data)',
'zend_zval_type_name(data)'
);
}
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-imap')]
public function patchBeforeBuildconf(PackageInstaller $installer): void
{

View File

@@ -17,6 +17,20 @@ class memcache extends PhpExtensionPackage
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-memcache')]
public function patchBeforeBuildconf(): bool
{
// PHP 8.5 moved php_smart_string*.h from ext/standard/ to Zend/
foreach (['src/memcache_pool.h', 'src/memcache_pool.c', 'src/memcache_session.c', 'src/memcache_ascii_protocol.c', 'src/memcache_binary_protocol.c'] as $file) {
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/{$file}",
'#include "ext/standard/php_smart_string_public.h"',
'#include "Zend/zend_smart_string_public.h"',
);
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/{$file}",
'#include "ext/standard/php_smart_string.h"',
'#include "Zend/zend_smart_string.h"',
);
}
if (!$this->isBuildStatic()) {
return false;
}

View File

@@ -8,15 +8,16 @@ use Package\Target\php;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Package\PackageInstaller;
#[Extension('zlib')]
class zlib
{
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function unixConfigureArg(PackageBuilder $builder): string
public function unixConfigureArg(PackageBuilder $builder, PackageInstaller $installer): string
{
$zlib_dir = php::getPHPVersionID() >= 80400 ? '' : ' --with-zlib-dir=' . $builder->getBuildRootPath();
return '--with-zlib' . $zlib_dir;
$zlib_dir = (php::getPHPVersionID() >= 80400 && !$installer->getPhpExtensionPackage('spx')) ? '' : " --with-zlib-dir={$builder->getBuildRootPath()}";
return "--with-zlib{$zlib_dir}";
}
}

View File

@@ -33,7 +33,7 @@ class mpir
{
$vs_ver_dir = ApplicationContext::get('mpir_vs_ver_dir');
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}\\lib_mpir_gc")
->exec('msbuild lib_mpir_gc.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64');
->exec('msbuild lib_mpir_gc.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0');
FileSystem::createDir($lib->getLibDir());
FileSystem::createDir($lib->getIncludeDir());
FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\lib_mpir_gc\\x64\\Release\\mpir_a.lib", "{$lib->getLibDir()}\\mpir_a.lib");

View File

@@ -26,6 +26,7 @@ class zstd
)
->build();
FileSystem::copy($package->getLibDir() . '\zstd_static.lib', $package->getLibDir() . '/zstd.lib');
FileSystem::copy($package->getLibDir() . '\zstd_static.lib', $package->getLibDir() . '/libzstd.lib');
}
#[BuildFor('Linux')]

View File

@@ -48,6 +48,7 @@ class DownloaderOptions
$shortU = $prefix ? null : 'U';
$shortG = $prefix ? null : 'G';
$shortL = $prefix ? null : 'L';
$shortI = $prefix ? null : 'i';
return [
// php version option
@@ -62,7 +63,7 @@ class DownloaderOptions
// download behavior options
new InputOption("{$p}parallel", $shortP, InputOption::VALUE_REQUIRED, 'Number of parallel downloads (default 1)', '1'),
new InputOption("{$p}retry", $shortR, InputOption::VALUE_REQUIRED, 'Number of download retries on failure (default 0)', '0'),
new InputOption("{$p}ignore-cache", null, InputOption::VALUE_OPTIONAL, 'Ignore some caches when downloading, comma separated, e.g "php-src,curl,openssl"', false),
new InputOption("{$p}ignore-cache", $shortI, InputOption::VALUE_OPTIONAL, 'Ignore some caches when downloading, comma separated, e.g "php-src,curl,openssl"', false),
new InputOption("{$p}no-alt", null, null, 'Do not use alternative mirror download artifacts for sources'),
new InputOption("{$p}no-shallow-clone", null, null, 'Do not clone shallowly repositories when downloading sources'),

View File

@@ -11,11 +11,46 @@ use Symfony\Component\Console\Attribute\AsCommand;
#[AsCommand('dev:gen-ext-test-matrix', 'Generate GitHub Actions extension test matrix JSON', [], true)]
class GenExtTestMatrixCommand extends BaseCommand
{
private const BUILD_TARGETS = '--build-cli --build-cgi --build-micro --dl-parallel=10';
private const string BUILD_TARGETS = '--build-cli --build-cgi --build-micro';
private const OS_RUNNERS = [
private const array OS_RUNNERS = [
'linux' => ['arch' => 'x86_64', 'runner' => 'ubuntu-latest', 'os_key' => 'Linux'],
'windows' => ['arch' => 'x86_64', 'runner' => 'windows-2025', 'os_key' => 'Windows'],
'windows' => ['arch' => 'x86_64', 'runner' => 'windows-latest', 'os_key' => 'Windows'],
'macos' => ['arch' => 'aarch64', 'runner' => 'macos-15', 'os_key' => 'Darwin'],
];
/**
* Extensions excluded from specific OS matrix entries.
*/
private const array OS_EXCLUDE = [
'linux' => ['glfw'],
];
/**
* Extra build flags appended when a matrix entry contains any of the listed extensions.
* Key: extension display name (without ext- prefix). Value: extra flags string.
*/
private const array EXTRA_BUILD_FLAGS = [
'parallel' => '--enable-zts',
];
/**
* Pairs of extensions that cannot be built together in the same matrix entry.
*/
private const array CONFLICTS = [
['grpc', 'protobuf'],
['swow', 'swoole'],
];
/**
* Extensions that must always appear alone in their own matrix entry.
* Use display names (without ext- prefix).
*/
private const array STANDALONE = [
'grpc',
'glfw',
'imagick',
'intl',
];
protected bool $no_motd = true;
@@ -52,8 +87,9 @@ class GenExtTestMatrixCommand extends BaseCommand
$os_key = $os_info['os_key'];
// Filter by OS support
$os_regular = array_filter($all_regular, fn ($c) => $this->supportsOS($c, $os_key));
$os_virtual = array_filter($all_virtual, fn ($c) => $this->supportsOS($c, $os_key));
$os_exclude = array_fill_keys(array_map(fn ($n) => 'ext-' . $n, self::OS_EXCLUDE[$os] ?? []), true);
$os_regular = array_filter($all_regular, fn ($c, $k) => $this->supportsOS($c, $os_key) && !isset($os_exclude[$k]), ARRAY_FILTER_USE_BOTH);
$os_virtual = array_filter($all_virtual, fn ($c, $k) => $this->supportsOS($c, $os_key) && !isset($os_exclude[$k]), ARRAY_FILTER_USE_BOTH);
// Pool: all ext-* names available on this OS (regular + virtual)
$pool_set = array_fill_keys(
@@ -99,33 +135,41 @@ class GenExtTestMatrixCommand extends BaseCommand
$covered = [];
$groups = [];
$orphans = [];
$standalone_set = array_fill_keys(self::STANDALONE, true);
foreach (array_merge($roots, $non_roots) as $ext) {
if (isset($covered[$ext])) {
continue;
}
$chain = $this->dfsCollect($ext, $ext_deps, $pool_set, $covered);
if (count($chain) === 1 && empty($ext_deps[$ext])) {
$orphans[] = $this->displayName($ext);
$display = $this->displayName($ext);
if (isset($standalone_set[$display])) {
// Always emit standalone extensions as their own single entry
$groups[] = $display;
} elseif (count($chain) === 1 && empty($ext_deps[$ext])) {
$orphans[] = $display;
} else {
$groups[] = implode(',', array_map($this->displayName(...), $chain));
}
}
// All orphans become a single batched matrix entry
// Batch orphans, splitting conflicting extensions into separate entries
if (!empty($orphans)) {
sort($orphans);
$groups[] = implode(',', $orphans);
foreach ($this->splitOrphansByConflicts($orphans) as $batch) {
$groups[] = implode(',', $batch);
}
}
sort($groups);
foreach ($groups as $group) {
$extra = $this->extraBuildFlags($group);
$entries[] = [
'runner' => $os_info['runner'],
'os' => $os,
'arch' => $os_info['arch'],
'extension' => $group,
'build-args' => '"' . $group . '" ' . self::BUILD_TARGETS,
'build-args' => '"' . $group . '" ' . self::BUILD_TARGETS . ($extra !== '' ? ' ' . $extra : ''),
];
}
}
@@ -164,6 +208,62 @@ class GenExtTestMatrixCommand extends BaseCommand
return str_starts_with($pkg_name, 'ext-') ? substr($pkg_name, 4) : $pkg_name;
}
/**
* Split orphans into batches such that no two conflicting extensions share a batch.
* Uses a greedy graph-coloring approach.
*
* @param string[] $orphans display names, pre-sorted
* @return string[][] array of batches, each batch is an array of display names
*/
private function splitOrphansByConflicts(array $orphans): array
{
$adjacency = [];
foreach (self::CONFLICTS as [$a, $b]) {
$adjacency[$a][$b] = true;
$adjacency[$b][$a] = true;
}
$batches = [];
foreach ($orphans as $ext) {
$placed = false;
foreach ($batches as &$batch) {
$conflict = false;
foreach ($batch as $member) {
if (isset($adjacency[$ext][$member])) {
$conflict = true;
break;
}
}
if (!$conflict) {
$batch[] = $ext;
$placed = true;
break;
}
}
unset($batch);
if (!$placed) {
$batches[] = [$ext];
}
}
return $batches;
}
/**
* Returns any extra build flags required for an extension group string.
* Checks whether any extension in the comma-separated group matches EXTRA_BUILD_FLAGS.
*/
private function extraBuildFlags(string $group): string
{
$names = explode(',', $group);
$flags = [];
foreach (self::EXTRA_BUILD_FLAGS as $ext => $extra) {
if (in_array($ext, $names, true)) {
$flags[] = $extra;
}
}
return implode(' ', $flags);
}
/**
* Resolve the value of a platform-specific array field, applying the suffix fallback chain.
*

View File

@@ -230,7 +230,7 @@ class UnixCMakeExecutor extends Executor
// EXE linker flags: base system libs + framework flags for target packages
$exeLinkerFlags = SystemTarget::getRuntimeLibs();
if ($this->package instanceof TargetPackage) {
if ($this->package instanceof TargetPackage && SystemTarget::getTargetOS() === 'Darwin') {
$resolvedNames = array_keys($this->installer->getResolvedPackages());
$resolvedNames[] = $this->package->getName();
$fwFlags = new SPCConfigUtil()->getFrameworksString($resolvedNames);