Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c5efcc0
Fix wrongly using msys2 tar.exe
crazywhalecc Mar 20, 2026
3c9e868
Add spc-debug script on Windows
crazywhalecc Mar 20, 2026
46132ee
Fix doctor lock path on Windows
crazywhalecc Mar 20, 2026
1d2916f
Add brotli
crazywhalecc Mar 20, 2026
0c389d9
Add zlib
crazywhalecc Mar 20, 2026
464ddeb
Fix file copy operation to handle identical source and destination paths
crazywhalecc Mar 20, 2026
b21d571
Add onig
crazywhalecc Mar 20, 2026
9f3e353
Add bzip2
crazywhalecc Mar 20, 2026
03cd7e1
Add brotli libs
crazywhalecc Mar 20, 2026
d7d41f4
Add openssl
crazywhalecc Mar 20, 2026
94c579a
Add libssh2
crazywhalecc Mar 20, 2026
19bfb6b
Add zstd
crazywhalecc Mar 20, 2026
d1ec473
Allow set current working dir
crazywhalecc Mar 20, 2026
1213cb5
Refactor WindowsUtil to cache Visual Studio search results and add CM…
crazywhalecc Mar 20, 2026
eff7037
Add ngtcp2, remove suggested libs
crazywhalecc Mar 20, 2026
893f640
Add nghttp3
crazywhalecc Mar 20, 2026
9286166
Add nghttp2
crazywhalecc Mar 20, 2026
7df8616
Add libxml2
crazywhalecc Mar 20, 2026
f6e00c6
Refactor LibraryPackage to skip pkg-config and static-bin checks on W…
crazywhalecc Mar 20, 2026
deb9794
Add libiconv-win
crazywhalecc Mar 20, 2026
327bb8b
Add curl
crazywhalecc Mar 20, 2026
bd73b4a
phpstan
crazywhalecc Mar 20, 2026
230be2e
Add libpng
crazywhalecc Mar 21, 2026
5ff973e
Add freetype
crazywhalecc Mar 21, 2026
5207676
Add gmssl
crazywhalecc Mar 21, 2026
bf4d227
Add error handling for missing vswhere.exe in WindowsUtil
crazywhalecc Mar 21, 2026
75dd01a
Enhance package download logic to handle binary-only packages and imp…
crazywhalecc Mar 21, 2026
43d8c9d
Add icu (replace old icu-static-win)
crazywhalecc Mar 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions bin/spc-debug.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$PHP_Exec = ".\runtime\php.exe"

if (-not(Test-Path $PHP_Exec)) {
$PHP_Exec = Get-Command php.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
if (-not $PHP_Exec) {
Write-Host "Error: PHP not found, you need to install PHP on your system or use 'bin/setup-runtime'." -ForegroundColor Red
exit 1
}
}

& "$PHP_Exec" -d xdebug.mode=debug -d xdebug.client_host=127.0.0.1 -d xdebug.client_port=9003 -d xdebug.start_with_request=yes ("bin/spc") @args
exit $LASTEXITCODE
4 changes: 4 additions & 0 deletions config/pkg/lib/brotli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ brotli:
- libbrotlicommon
- libbrotlidec
- libbrotlienc
static-libs@windows:
- brotlicommon.lib
- brotlidec.lib
- brotlienc.lib
3 changes: 3 additions & 0 deletions config/pkg/lib/bzip2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ bzip2:
- bzlib.h
static-libs@unix:
- libbz2.a
static-libs@windows:
- libbz2.lib
- libbz2_a.lib
1 change: 1 addition & 0 deletions config/pkg/lib/freetype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ freetype:
depends:
- zlib
suggests:
- libpng
- bzip2
- brotli
headers@unix:
Expand Down
11 changes: 10 additions & 1 deletion config/pkg/lib/icu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ icu:
repo: unicode-org/icu
match: icu4c.+-src\.tgz
prefer-stable: true
binary:
windows-x86_64: { type: url, url: 'https://dl.static-php.dev/static-php-cli/deps/icu-static-windows-x64/icu-static-windows-x64.zip', extract: hosted }
metadata:
license-files: [LICENSE]
license-files: ['@/icu.txt']
license: ICU
headers@windows:
- unicode
lang: cpp
pkg-configs:
- icu-uc
- icu-i18n
- icu-io
static-libs@windows:
- icudt.lib
- icuin.lib
- icuio.lib
- icuuc.lib
13 changes: 13 additions & 0 deletions config/pkg/lib/libiconv-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
libiconv-win:
type: library
artifact:
source:
type: git
rev: master
url: 'https://github.com/static-php/libiconv-win.git'
metadata:
license-files: [source/COPYING]
license: GPL-3.0-or-later
static-libs@windows:
- libiconv.lib
- libiconv_a.lib
3 changes: 3 additions & 0 deletions config/pkg/lib/libpng.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ libpng:
- zlib
static-libs@unix:
- libpng16.a
static-libs@windows:
- libpng16_static.lib
- libpng_a.lib
2 changes: 2 additions & 0 deletions config/pkg/lib/libssh2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ libssh2:
- libssh2
static-libs@unix:
- libssh2.a
static-libs@windows:
- libssh2.lib
6 changes: 6 additions & 0 deletions config/pkg/lib/libxml2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ libxml2:
- libiconv
- zlib
- xz
depends@windows:
- zlib
- libiconv-win
headers:
- libxml2
pkg-configs:
- libxml-2.0
static-libs@windows:
- libxml2s.lib
- libxml2_a.lib
2 changes: 2 additions & 0 deletions config/pkg/lib/nghttp2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ nghttp2:
- libnghttp2
static-libs@unix:
- libnghttp2.a
static-libs@windows:
- nghttp2.lib
2 changes: 2 additions & 0 deletions config/pkg/lib/nghttp3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ nghttp3:
- libnghttp3
static-libs@unix:
- libnghttp3.a
static-libs@windows:
- nghttp3.lib
5 changes: 2 additions & 3 deletions config/pkg/lib/ngtcp2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ ngtcp2:
license: MIT
depends:
- openssl
suggests:
- nghttp3
- brotli
headers:
- ngtcp2
pkg-configs:
Expand All @@ -22,3 +19,5 @@ ngtcp2:
static-libs@unix:
- libngtcp2.a
- libngtcp2_crypto_ossl.a
static-libs@windows:
- ngtcp2.lib
3 changes: 3 additions & 0 deletions config/pkg/lib/onig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ onig:
- oniguruma.h
static-libs@unix:
- libonig.a
static-libs@windows:
- onig.lib
- onig_a.lib
3 changes: 3 additions & 0 deletions config/pkg/lib/openssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ openssl:
static-libs@unix:
- libssl.a
- libcrypto.a
static-libs@windows:
- libssl.lib
- libcrypto.lib
3 changes: 3 additions & 0 deletions config/pkg/lib/zlib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ zlib:
- zconf.h
static-libs@unix:
- libz.a
static-libs@windows:
- zlibstatic.lib
- zlib_a.lib
2 changes: 2 additions & 0 deletions config/pkg/lib/zstd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ zstd:
- libzstd
static-libs@unix:
- libzstd.a
static-libs@windows:
- zstd_static.lib
9 changes: 9 additions & 0 deletions config/pkg/target/curl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ curl:
depends@unix:
- openssl
- zlib
depends@windows:
- zlib
- libssh2
- nghttp2
suggests@unix:
- libssh2
- brotli
Expand All @@ -23,6 +27,9 @@ curl:
- ldap
- idn2
- krb5
suggests@windows:
- brotli
- zstd
frameworks:
- CoreFoundation
- CoreServices
Expand All @@ -33,3 +40,5 @@ curl:
- curl
static-libs@unix:
- libcurl.a
static-libs@windows:
- libcurl_a.lib
8 changes: 8 additions & 0 deletions src/Package/Library/brotli.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Util\FileSystem;

#[Library('brotli')]
class brotli
{
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $package): void
{
WindowsCMakeExecutor::create($package)->build();
// FileSystem::copy("{$package->getLibDir()}\\onig.lib", "{$package->getLibDir()}\\onig_a.lib");
}

#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $lib): void
Expand Down
11 changes: 11 additions & 0 deletions src/Package/Library/bzip2.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ public function patchBeforeBuild(LibraryPackage $lib): void
FileSystem::replaceFileStr($lib->getSourceDir() . '/Makefile', 'CFLAGS=-Wall', 'CFLAGS=-fPIC -Wall');
}

#[BuildFor('Windows')]
public function buildWin(LibraryPackage $package): void
{
cmd()->cd($package->getSourceDir())
->exec('nmake /nologo /f Makefile.msc CFLAGS="-DWIN32 -MT -Ox -D_FILE_OFFSET_BITS=64 -nologo" clean')
->exec('nmake /nologo /f Makefile.msc CFLAGS="-DWIN32 -MT -Ox -D_FILE_OFFSET_BITS=64 -nologo" lib');
FileSystem::copy("{$package->getSourceDir()}\\libbz2.lib", "{$package->getLibDir()}\\libbz2.lib");
FileSystem::copy("{$package->getSourceDir()}\\libbz2.lib", "{$package->getLibDir()}\\libbz2_a.lib");
FileSystem::copy("{$package->getSourceDir()}\\bzlib.h", "{$package->getIncludeDir()}\\bzlib.h");
}

#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $lib, PackageBuilder $builder): void
Expand Down
15 changes: 15 additions & 0 deletions src/Package/Library/freetype.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Util\FileSystem;

#[Library('freetype')]
Expand All @@ -33,4 +34,18 @@ public function buildUnix(LibraryPackage $lib): void
$lib->patchPkgconfPrefix(['freetype2.pc']);
FileSystem::replaceFileStr("{$lib->getBuildRootPath()}/lib/pkgconfig/freetype2.pc", ' -L/lib ', " -L{$lib->getBuildRootPath()}/lib ");
}

#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->optionalPackage('libpng', ...cmake_boolean_args('FT_DISABLE_PNG', true))
->optionalPackage('bzip2', ...cmake_boolean_args('FT_DISABLE_BZIP2', true))
->optionalPackage('brotli', ...cmake_boolean_args('FT_DISABLE_BROTLI', true))
->addConfigureArgs('-DFT_DISABLE_HARFBUZZ=ON')
->build();

// freetype.lib to libfreetype_a.lib
FileSystem::copy("{$lib->getLibDir()}\\freetype.lib", "{$lib->getLibDir()}\\libfreetype_a.lib");
}
}
33 changes: 33 additions & 0 deletions src/Package/Library/gmssl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Util\FileSystem;

#[Library('gmssl')]
class gmssl
Expand All @@ -18,4 +20,35 @@ public function build(LibraryPackage $lib): void
{
UnixCMakeExecutor::create($lib)->build();
}

#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
$buildDir = "{$lib->getSourceDir()}\\builddir";

// GmSSL requires NMake Makefiles generator on Windows
WindowsCMakeExecutor::create($lib)
->setBuildDir($buildDir)
->setCustomDefaultArgs(
'-G "NMake Makefiles"',
'-DWIN32=ON',
'-DBUILD_SHARED_LIBS=OFF',
'-DCMAKE_BUILD_TYPE=Release',
'-DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"',
'-DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"',
'-DCMAKE_INSTALL_PREFIX=' . escapeshellarg($lib->getBuildRootPath()),
'-B ' . escapeshellarg($buildDir),
)
->toStep(1)
->build();

// fix cmake_install.cmake install prefix (GmSSL overrides it internally)
$installCmake = "{$buildDir}\\cmake_install.cmake";
FileSystem::writeFile(
$installCmake,
'set(CMAKE_INSTALL_PREFIX "' . str_replace('\\', '/', $lib->getBuildRootPath()) . '")' . PHP_EOL . FileSystem::readFile($installCmake)
);

cmd()->cd($buildDir)->exec('nmake install XCFLAGS=/MT');
}
}
43 changes: 43 additions & 0 deletions src/Package/Library/libiconv_win.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace Package\Library;

use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Attribute\Package\Validate;
use StaticPHP\DI\ApplicationContext;
use StaticPHP\Exception\EnvironmentException;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Util\FileSystem;
use StaticPHP\Util\System\WindowsUtil;

#[Library('libiconv-win')]
class libiconv_win
{
#[Validate]
public function validate(): void
{
$ver = WindowsUtil::findVisualStudio();
$vs_ver_dir = match ($ver['major_version']) {
'17' => '\MSVC17',
'16' => '\MSVC16',
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
};
ApplicationContext::set('vs_ver_dir', $vs_ver_dir);
}

#[BuildFor('Windows')]
public function build(LibraryPackage $lib): void
{
$vs_ver_dir = ApplicationContext::get('vs_ver_dir');
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}")
->exec('msbuild libiconv.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64');
FileSystem::createDir($lib->getLibDir());
FileSystem::createDir($lib->getIncludeDir());
FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\x64\\lib\\libiconv.lib", "{$lib->getLibDir()}\\libiconv.lib");
FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\x64\\lib\\libiconv_a.lib", "{$lib->getLibDir()}\\libiconv_a.lib");
FileSystem::copy("{$lib->getSourceDir()}\\source\\include\\iconv.h", "{$lib->getIncludeDir()}\\iconv.h");
}
}
19 changes: 19 additions & 0 deletions src/Package/Library/libpng.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Util\FileSystem;

#[Library('libpng')]
class libpng
Expand Down Expand Up @@ -44,4 +46,21 @@ public function buildUnix(LibraryPackage $lib): void
$lib->patchPkgconfPrefix(['libpng16.pc']);
$lib->patchLaDependencyPrefix();
}

#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->addConfigureArgs(
'-DSKIP_INSTALL_PROGRAM=ON',
'-DSKIP_INSTALL_FILES=ON',
'-DPNG_STATIC=ON',
'-DPNG_SHARED=OFF',
'-DPNG_TESTS=OFF',
)
->build();

// libpng16_static.lib to libpng_a.lib
FileSystem::copy("{$lib->getLibDir()}\\libpng16_static.lib", "{$lib->getLibDir()}\\libpng_a.lib");
}
}
12 changes: 12 additions & 0 deletions src/Package/Library/libssh2.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;

#[Library('libssh2')]
class libssh2
{
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->addConfigureArgs(
'-DENABLE_ZLIB_COMPRESSION=ON',
'-DBUILD_TESTING=OFF'
)
->build();
}

#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $lib): void
Expand Down
Loading