[3.0] Refactor windows libs (#1067)

This commit is contained in:
Jerry Ma
2026-03-24 15:28:27 +08:00
committed by GitHub
76 changed files with 1552 additions and 68 deletions

12
bin/spc-debug.ps1 Normal file
View File

@@ -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

View File

@@ -15,3 +15,7 @@ brotli:
- libbrotlicommon
- libbrotlidec
- libbrotlienc
static-libs@windows:
- brotlicommon.lib
- brotlidec.lib
- brotlienc.lib

View File

@@ -16,3 +16,6 @@ bzip2:
- bzlib.h
static-libs@unix:
- libbz2.a
static-libs@windows:
- libbz2.lib
- libbz2_a.lib

View File

@@ -11,6 +11,7 @@ freetype:
depends:
- zlib
suggests:
- libpng
- bzip2
- brotli
headers@unix:

View File

@@ -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

View File

@@ -10,3 +10,5 @@ libaom:
lang: cpp
static-libs@unix:
- libaom.a
static-libs@windows:
- aom.lib

View File

@@ -16,3 +16,5 @@ libavif:
- libpng
static-libs@unix:
- libavif.a
static-libs@windows:
- avif.lib

View File

@@ -0,0 +1,12 @@
libffi-win:
type: library
artifact:
source:
type: git
rev: master
url: 'https://github.com/static-php/libffi-win.git'
metadata:
license-files: [LICENSE]
license: MIT
static-libs@windows:
- libffi.lib

View File

@@ -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

View File

@@ -7,6 +7,10 @@ libjpeg:
metadata:
license-files: [LICENSE.md]
license: IJG
suggests@windows:
- zlib
static-libs@unix:
- libjpeg.a
- libturbojpeg.a
static-libs@windows:
- libjpeg_a.lib

View File

@@ -14,3 +14,6 @@ libpng:
- zlib
static-libs@unix:
- libpng16.a
static-libs@windows:
- libpng16_static.lib
- libpng_a.lib

View File

@@ -12,3 +12,5 @@ librabbitmq:
- openssl
static-libs@unix:
- librabbitmq.a
static-libs@windows:
- rabbitmq.4.lib

View File

@@ -13,3 +13,5 @@ libsodium:
- libsodium
static-libs@unix:
- libsodium.a
static-libs@windows:
- libsodium.lib

View File

@@ -20,3 +20,5 @@ libssh2:
- libssh2
static-libs@unix:
- libssh2.a
static-libs@windows:
- libssh2.lib

View File

@@ -14,3 +14,8 @@ libwebp:
- libwebpdemux
- libwebpmux
- libsharpyuv
static-libs@windows:
- libwebp.lib
- libwebpdecoder.lib
- libwebpdemux.lib
- libsharpyuv.lib

View File

@@ -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

View File

@@ -13,3 +13,5 @@ libyaml:
- yaml.h
static-libs@unix:
- libyaml.a
static-libs@windows:
- yaml.lib

View File

@@ -8,9 +8,10 @@ libzip:
prefer-stable: true
metadata:
license-files: [LICENSE]
depends@unix:
license: BSD-3-Clause
depends:
- zlib
suggests@unix:
suggests:
- bzip2
- xz
- zstd
@@ -20,3 +21,5 @@ libzip:
- zipconf.h
static-libs@unix:
- libzip.a
static-libs@windows:
- libzip_a.lib

View File

@@ -22,3 +22,5 @@ nghttp2:
- libnghttp2
static-libs@unix:
- libnghttp2.a
static-libs@windows:
- nghttp2.lib

View File

@@ -17,3 +17,5 @@ nghttp3:
- libnghttp3
static-libs@unix:
- libnghttp3.a
static-libs@windows:
- nghttp3.lib

View File

@@ -11,9 +11,6 @@ ngtcp2:
license: MIT
depends:
- openssl
suggests:
- nghttp3
- brotli
headers:
- ngtcp2
pkg-configs:
@@ -22,3 +19,5 @@ ngtcp2:
static-libs@unix:
- libngtcp2.a
- libngtcp2_crypto_ossl.a
static-libs@windows:
- ngtcp2.lib

View File

@@ -13,3 +13,6 @@ onig:
- oniguruma.h
static-libs@unix:
- libonig.a
static-libs@windows:
- onig.lib
- onig_a.lib

View File

@@ -16,8 +16,14 @@ openssl:
license: OpenSSL
depends:
- zlib
depends@windows:
- zlib
- jom
headers:
- openssl
static-libs@unix:
- libssl.a
- libcrypto.a
static-libs@windows:
- libssl.lib
- libcrypto.lib

View File

@@ -5,19 +5,25 @@ postgresql:
type: ghtagtar
repo: postgres/postgres
match: REL_18_\d+
binary:
windows-x86_64: { type: url, url: 'https://get.enterprisedb.com/postgresql/postgresql-16.8-1-windows-x64-binaries.zip', extract: { lib/libpq.lib: '{build_root_path}/lib/libpq.lib', lib/libpgport.lib: '{build_root_path}/lib/libpgport.lib', lib/libpgcommon.lib: '{build_root_path}/lib/libpgcommon.lib', include/libpq-fe.h: '{build_root_path}/include/libpq-fe.h', include/postgres_ext.h: '{build_root_path}/include/postgres_ext.h', include/pg_config_ext.h: '{build_root_path}/include/pg_config_ext.h', include/libpq/libpq-fs.h: '{build_root_path}/include/libpq/libpq-fs.h' } }
metadata:
license-files: [COPYRIGHT]
license-files: ['@/postgresql.txt']
license: PostgreSQL
depends:
depends@unix:
- libiconv
- libxml2
- openssl
- zlib
- libedit
suggests:
suggests@unix:
- icu
- libxslt
- ldap
- zstd
pkg-configs:
- libpq
static-libs@windows:
- libpq.lib
- libpgport.lib
- libpgcommon.lib

View File

@@ -0,0 +1,12 @@
pthreads4w:
type: library
artifact:
source:
type: git
rev: master
url: 'https://git.code.sf.net/p/pthreads4w/code'
metadata:
license-files: [LICENSE]
license: Apache-2.0
static-libs@windows:
- libpthreadVC3.lib

View File

@@ -10,3 +10,5 @@ qdbm:
license: 'GPL-2.0-only OR LGPL-2.1-only'
static-libs@unix:
- libqdbm.a
static-libs@windows:
- qdbm_a.lib

View File

@@ -10,3 +10,5 @@ sqlite:
- sqlite3ext.h
static-libs@unix:
- libsqlite3.a
static-libs@windows:
- libsqlite3_a.lib

View File

@@ -14,7 +14,13 @@ xz:
- libiconv
headers@unix:
- lzma
headers@windows:
- lzma
- lzma.h
pkg-configs:
- liblzma
static-libs@unix:
- liblzma.a
static-libs@windows:
- lzma.lib
- liblzma_a.lib

View File

@@ -14,3 +14,6 @@ zlib:
- zconf.h
static-libs@unix:
- libz.a
static-libs@windows:
- zlibstatic.lib
- zlib_a.lib

View File

@@ -17,3 +17,5 @@ zstd:
- libzstd
static-libs@unix:
- libzstd.a
static-libs@windows:
- zstd_static.lib

View File

@@ -12,6 +12,10 @@ curl:
depends@unix:
- openssl
- zlib
depends@windows:
- zlib
- libssh2
- nghttp2
suggests@unix:
- libssh2
- brotli
@@ -23,6 +27,9 @@ curl:
- ldap
- idn2
- krb5
suggests@windows:
- brotli
- zstd
frameworks:
- CoreFoundation
- CoreServices
@@ -33,3 +40,5 @@ curl:
- curl
static-libs@unix:
- libcurl.a
static-libs@windows:
- libcurl_a.lib

View File

@@ -0,0 +1,7 @@
jom:
type: target
artifact:
binary:
windows-x86_64: { type: url, url: 'https://download.qt.io/official_releases/jom/jom.zip', extract: '{pkg_root_path}/jom' }
path@windows:
- '{pkg_root_path}\jom'

View File

@@ -8,11 +8,19 @@ use StaticPHP\Attribute\Package\BuildFor;
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

View File

@@ -20,6 +20,17 @@ class bzip2
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

View File

@@ -8,6 +8,7 @@ use StaticPHP\Attribute\Package\BuildFor;
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')]
@@ -33,4 +34,18 @@ class freetype
$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");
}
}

View File

@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
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
@@ -18,4 +20,35 @@ class gmssl
{
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');
}
}

View File

@@ -8,12 +8,28 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Toolchain\Interface\ToolchainInterface;
use StaticPHP\Toolchain\ZigToolchain;
#[Library('libaom')]
class libaom extends LibraryPackage
{
#[BuildFor('Windows')]
public function buildWin(): void
{
WindowsCMakeExecutor::create($this)
->setBuildDir("{$this->getSourceDir()}/builddir")
->addConfigureArgs(
'-DAOM_TARGET_CPU=generic',
'-DENABLE_TESTS=OFF',
'-DENABLE_EXAMPLES=OFF',
'-DENABLE_TOOLS=OFF',
'-DENABLE_DOCS=OFF',
)
->build();
}
#[BuildFor('Darwin')]
#[BuildFor('Linux')]
public function buildUnix(ToolchainInterface $toolchain): void

View File

@@ -6,12 +6,25 @@ namespace Package\Library;
use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Attribute\Package\PatchBeforeBuild;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
#[Library('libavif')]
class libavif
{
#[PatchBeforeBuild]
public function patchBeforeBuild(LibraryPackage $lib): void
{
// workaround for libavif 1.2.0 bug: MSVC does not support empty initializer list
if (SystemTarget::getTargetOS() === 'Windows') {
FileSystem::replaceFileStr($lib->getSourceDir() . '/src/read.c', 'avifFileType ftyp = {};', 'avifFileType ftyp = { 0 };');
}
}
#[BuildFor('Darwin')]
#[BuildFor('Linux')]
public function buildUnix(LibraryPackage $lib): void
@@ -27,4 +40,17 @@ class libavif
// patch pkgconfig
$lib->patchPkgconfPrefix(['libavif.pc']);
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->addConfigureArgs(
'-DAVIF_BUILD_APPS=OFF',
'-DAVIF_BUILD_TESTS=OFF',
'-DAVIF_LIBYUV=OFF',
'-DAVIF_ENABLE_GTEST=OFF',
)
->build();
}
}

View File

@@ -0,0 +1,47 @@
<?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('libffi-win')]
class libffi_win
{
#[Validate]
public function validate(): void
{
$ver = WindowsUtil::findVisualStudio();
$vs_ver_dir = match ($ver['major_version']) {
'17' => '\win32\vs17_x64',
'16' => '\win32\vs16_x64',
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported!"),
};
ApplicationContext::set('libffi_win_vs_ver_dir', $vs_ver_dir);
}
#[BuildFor('Windows')]
public function build(LibraryPackage $lib): void
{
$vs_ver_dir = ApplicationContext::get('libffi_win_vs_ver_dir');
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}")
->exec('msbuild libffi-msvc.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\\Release\\libffi.lib", "{$lib->getLibDir()}\\libffi.lib");
FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\x64\\Release\\libffi.pdb", "{$lib->getLibDir()}\\libffi.pdb");
FileSystem::copy("{$lib->getSourceDir()}\\include\\ffi.h", "{$lib->getIncludeDir()}\\ffi.h");
FileSystem::replaceFileStr("{$lib->getIncludeDir()}\\ffi.h", '#define LIBFFI_H', "#define LIBFFI_H\n#define FFI_BUILDING");
FileSystem::copy("{$lib->getSourceDir()}\\src\\x86\\ffitarget.h", "{$lib->getIncludeDir()}\\ffitarget.h");
FileSystem::copy("{$lib->getSourceDir()}\\fficonfig.h", "{$lib->getIncludeDir()}\\fficonfig.h");
}
}

View File

@@ -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");
}
}

View File

@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Util\FileSystem;
#[Library('libjpeg')]
class libjpeg
@@ -25,4 +27,20 @@ class libjpeg
// patch pkgconfig
$lib->patchPkgconfPrefix(['libjpeg.pc', 'libturbojpeg.pc']);
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->addConfigureArgs(
'-DENABLE_SHARED=OFF',
'-DENABLE_STATIC=ON',
'-DBUILD_TESTING=OFF',
'-DWITH_JAVA=OFF',
'-DWITH_CRT_DLL=OFF',
)
->optionalPackage('zlib', '-DENABLE_ZLIB_COMPRESSION=ON', '-DENABLE_ZLIB_COMPRESSION=OFF')
->build();
FileSystem::copy("{$lib->getLibDir()}\\jpeg-static.lib", "{$lib->getLibDir()}\\libjpeg_a.lib");
}
}

View File

@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
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
@@ -44,4 +46,21 @@ class libpng
$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");
}
}

View File

@@ -8,6 +8,7 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
#[Library('librabbitmq')]
class librabbitmq extends LibraryPackage
@@ -18,4 +19,11 @@ class librabbitmq extends LibraryPackage
{
UnixCMakeExecutor::create($this)->addConfigureArgs('-DBUILD_STATIC_LIBS=ON')->build();
}
#[BuildFor('Windows')]
public function buildWin(): void
{
WindowsCMakeExecutor::create($this)->build();
rename("{$this->getLibDir()}\\librabbitmq.4.lib", "{$this->getLibDir()}\\rabbitmq.4.lib");
}
}

View File

@@ -6,12 +6,27 @@ namespace Package\Library;
use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Attribute\Package\PatchBeforeBuild;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Exception\BuildFailureException;
use StaticPHP\Exception\EnvironmentException;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
use StaticPHP\Util\System\WindowsUtil;
#[Library('libsodium')]
class libsodium
{
#[PatchBeforeBuild]
#[PatchDescription('Replace SODIUM_STATIC define guard with unconditional #if 1 for MSVC static linking')]
public function patchBeforeBuild(LibraryPackage $lib): void
{
spc_skip_if(SystemTarget::getTargetOS() !== 'Windows', 'This patch is only for Windows builds.');
FileSystem::replaceFileStr($lib->getSourceDir() . '\src\libsodium\include\sodium\export.h', '#ifdef SODIUM_STATIC', '#if 1');
}
#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $lib): void
@@ -21,4 +36,39 @@ class libsodium
// Patch pkg-config file
$lib->patchPkgconfPrefix(['libsodium.pc'], PKGCONF_PATCH_PREFIX);
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
$ver = WindowsUtil::findVisualStudio();
$vs_ver_dir = match ($ver['major_version']) {
'17' => '\vs2022',
'16' => '\vs2019',
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
};
cmd()->cd("{$lib->getSourceDir()}\\builds\\msvc{$vs_ver_dir}")
->exec('msbuild libsodium.sln /t:Rebuild /p:Configuration=StaticRelease /p:Platform=x64 /p:PreprocessorDefinitions="SODIUM_STATIC=1"');
FileSystem::createDir($lib->getLibDir());
FileSystem::createDir($lib->getIncludeDir());
// copy include
FileSystem::copyDir("{$lib->getSourceDir()}\\src\\libsodium\\include\\sodium", "{$lib->getIncludeDir()}\\sodium");
FileSystem::copy("{$lib->getSourceDir()}\\src\\libsodium\\include\\sodium.h", "{$lib->getIncludeDir()}\\sodium.h");
// copy lib
$ls = FileSystem::scanDirFiles("{$lib->getSourceDir()}\\bin");
$find = false;
foreach ($ls as $file) {
if (str_ends_with($file, 'libsodium.lib')) {
FileSystem::copy($file, "{$lib->getLibDir()}\\libsodium.lib");
$find = true;
}
if (str_ends_with($file, 'libsodium.pdb')) {
FileSystem::copy($file, "{$lib->getLibDir()}\\libsodium.pdb");
}
}
if (!$find) {
throw new BuildFailureException("Build libsodium success, but cannot find libsodium.lib in {$lib->getSourceDir()}\\bin .");
}
}
}

View File

@@ -8,10 +8,22 @@ use StaticPHP\Attribute\Package\BuildFor;
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

View File

@@ -8,6 +8,7 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
#[Library('libwebp')]
class libwebp extends LibraryPackage
@@ -41,4 +42,23 @@ int main() { return _mm256_cvtsi256_si32(_mm256_setzero_si256()); }';
$this->patchPkgconfPrefix(patch_option: PKGCONF_PATCH_PREFIX | PKGCONF_PATCH_LIBDIR);
$this->patchPkgconfPrefix(['libsharpyuv.pc'], PKGCONF_PATCH_CUSTOM, ['/^includedir=.*$/m', 'includedir=${prefix}/include/webp']);
}
#[BuildFor('Windows')]
public function buildWin(): void
{
WindowsCMakeExecutor::create($this)
->addConfigureArgs(
'-DWEBP_BUILD_EXTRAS=OFF',
'-DWEBP_BUILD_ANIM_UTILS=OFF',
'-DWEBP_BUILD_CWEBP=OFF',
'-DWEBP_BUILD_DWEBP=OFF',
'-DWEBP_BUILD_GIF2WEBP=OFF',
'-DWEBP_BUILD_IMG2WEBP=OFF',
'-DWEBP_BUILD_VWEBP=OFF',
'-DWEBP_BUILD_WEBPINFO=OFF',
'-DWEBP_BUILD_WEBPMUX=OFF',
'-DWEBP_BUILD_FUZZTEST=OFF',
)
->build();
}
}

View File

@@ -7,12 +7,33 @@ namespace Package\Library;
use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Util\FileSystem;
#[Library('libxml2')]
class libxml2
{
#[BuildFor('Windows')]
public function buildForWindows(LibraryPackage $lib, PackageInstaller $installer): void
{
$iconv_win = $installer->getLibraryPackage('libiconv-win');
WindowsCMakeExecutor::create($lib)
->addConfigureArgs(
'-DLIBXML2_WITH_ICONV=ON',
"-DIconv_LIBRARY={$iconv_win->getLibDir()}",
"-DIconv_INCLUDE_DIR={$iconv_win->getIncludeDir()}",
'-DLIBXML2_WITH_ZLIB=ON',
'-DLIBXML2_WITH_PYTHON=OFF',
'-DLIBXML2_WITH_LZMA=OFF',
'-DLIBXML2_WITH_PROGRAMS=OFF',
'-DLIBXML2_WITH_TESTS=OFF',
)
->build();
FileSystem::copy("{$lib->getLibDir()}\\libxml2s.lib", "{$lib->getLibDir()}\\libxml2_a.lib");
}
#[BuildFor('Linux')]
public function buildForLinux(LibraryPackage $lib): void
{

View File

@@ -6,16 +6,44 @@ namespace Package\Library;
use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Attribute\Package\PatchBeforeBuild;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
#[Library('libyaml')]
class libyaml
{
#[PatchBeforeBuild]
#[PatchDescription('Copy missing cmake helper files required for MSVC build (not included in libyaml git source)')]
public function patchBeforeBuild(LibraryPackage $lib): void
{
spc_skip_if(SystemTarget::getTargetOS() !== 'Windows', 'This patch is only for Windows builds.');
// check missing files: cmake\config.h.in and .\YamlConfig.cmake.in
if (!file_exists($lib->getSourceDir() . '\cmake\config.h.in')) {
FileSystem::createDir($lib->getSourceDir() . '\cmake');
FileSystem::copy(ROOT_DIR . '/src/globals/extra/libyaml_config.h.in', $lib->getSourceDir() . '\cmake\config.h.in');
}
if (!file_exists($lib->getSourceDir() . '\YamlConfig.cmake.in')) {
FileSystem::copy(ROOT_DIR . '/src/globals/extra/libyaml_yamlConfig.cmake.in', $lib->getSourceDir() . '\YamlConfig.cmake.in');
}
}
#[BuildFor('Darwin')]
#[BuildFor('Linux')]
public function buildUnix(LibraryPackage $lib): void
{
UnixAutoconfExecutor::create($lib)->configure()->make();
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->addConfigureArgs('-DBUILD_TESTING=OFF')
->build();
}
}

View File

@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Util\FileSystem;
#[Library('libzip')]
class libzip
@@ -33,4 +35,28 @@ class libzip
->build();
$lib->patchPkgconfPrefix(['libzip.pc'], PKGCONF_PATCH_PREFIX);
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->optionalPackage('bzip2', ...cmake_boolean_args('ENABLE_BZIP2'))
->optionalPackage('xz', ...cmake_boolean_args('ENABLE_LZMA'))
->optionalPackage('openssl', ...cmake_boolean_args('ENABLE_OPENSSL'))
->optionalPackage('zstd', ...cmake_boolean_args('ENABLE_ZSTD'))
->addConfigureArgs(
'-DENABLE_GNUTLS=OFF',
'-DENABLE_MBEDTLS=OFF',
'-DBUILD_DOC=OFF',
'-DBUILD_EXAMPLES=OFF',
'-DBUILD_REGRESS=OFF',
'-DBUILD_TOOLS=OFF',
'-DBUILD_OSSFUZZ=OFF',
)
->build();
FileSystem::copy(
$lib->getBuildRootPath() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'zip.lib',
$lib->getBuildRootPath() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'libzip_a.lib'
);
}
}

View File

@@ -8,10 +8,26 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
#[Library('nghttp2')]
class nghttp2
{
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->addConfigureArgs(
'-DENABLE_SHARED_LIB=OFF',
'-DENABLE_STATIC_LIB=ON',
'-DENABLE_STATIC_CRT=ON',
'-DENABLE_LIB_ONLY=ON',
'-DENABLE_DOC=OFF',
'-DBUILD_TESTING=OFF',
)
->build();
}
#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $lib): void

View File

@@ -8,10 +8,26 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
#[Library('nghttp3')]
class nghttp3
{
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->addConfigureArgs(
'-DENABLE_SHARED_LIB=OFF',
'-DENABLE_STATIC_LIB=ON',
'-DBUILD_STATIC_LIBS=ON',
'-DBUILD_SHARED_LIBS=OFF',
'-DENABLE_STATIC_CRT=ON',
'-DENABLE_LIB_ONLY=ON',
)
->build();
}
#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $lib): void

View File

@@ -8,10 +8,27 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
#[Library('ngtcp2')]
class ngtcp2
{
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->addConfigureArgs(
'-DENABLE_SHARED_LIB=OFF',
'-DENABLE_STATIC_LIB=ON',
'-DBUILD_STATIC_LIBS=ON',
'-DBUILD_SHARED_LIBS=OFF',
'-DENABLE_STATIC_CRT=ON',
'-DENABLE_LIB_ONLY=ON',
'-DENABLE_OPENSSL=ON',
)
->build();
}
#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $lib): void
@@ -26,18 +43,6 @@ class ngtcp2
]),
'--with-openssl=no'
)
->optionalPackage('nghttp3', ...ac_with_args('libnghttp3', true))
->optionalPackage(
'brotli',
fn (LibraryPackage $brotli) => implode(' ', [
'--with-brotlidec=yes',
"LIBBROTLIDEC_CFLAGS=\"-I{$brotli->getIncludeDir()}\"",
"LIBBROTLIDEC_LIBS=\"{$brotli->getStaticLibFiles()}\"",
'--with-libbrotlienc=yes',
"LIBBROTLIENC_CFLAGS=\"-I{$brotli->getIncludeDir()}\"",
"LIBBROTLIENC_LIBS=\"{$brotli->getStaticLibFiles()}\"",
])
)
->appendEnv(['PKG_CONFIG' => '$PKG_CONFIG --static'])
->configure('--enable-lib-only')
->make();

View File

@@ -6,13 +6,72 @@ 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\Package\PackageBuilder;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
use StaticPHP\Util\System\LinuxUtil;
use StaticPHP\Util\System\WindowsUtil;
#[Library('openssl')]
class openssl
{
#[Validate]
public function validate(): void
{
if (SystemTarget::getTargetOS() === 'Windows') {
global $argv;
$perl_path_native = PKG_ROOT_PATH . '\strawberry-perl-' . arch2gnu(php_uname('m')) . '-win\perl\bin\perl.exe';
$perl = file_exists($perl_path_native) ? ($perl_path_native) : WindowsUtil::findCommand('perl.exe');
if ($perl === null) {
throw new EnvironmentException(
'You need to install perl first!',
"Please run \"{$argv[0]} doctor\" to fix the environment.",
);
}
ApplicationContext::set('perl', $perl);
}
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib, PackageBuilder $builder): void
{
$perl = ApplicationContext::get('perl');
$cmd = cmd()->cd($lib->getSourceDir())
->exec(
"{$perl} Configure zlib VC-WIN64A " .
'no-shared ' .
'--prefix=' . quote($lib->getBuildRootPath()) . ' ' .
'--with-zlib-lib=' . quote($lib->getLibDir()) . ' ' .
'--with-zlib-include=' . quote($lib->getIncludeDir()) . ' ' .
'--release ' .
'no-legacy ' .
'no-tests ' .
'/FS'
);
// patch zlib
FileSystem::replaceFileStr("{$lib->getSourceDir()}\\Makefile", 'ZLIB1', 'zlibstatic.lib');
// patch debug: https://stackoverflow.com/questions/18486243/how-do-i-build-openssl-statically-linked-against-windows-runtime
FileSystem::replaceFileStr("{$lib->getSourceDir()}\\Makefile", '/debug', '/incremental:no /opt:icf /dynamicbase /nxcompat /ltcg /nodefaultlib:msvcrt');
// build
$cmd->exec("jom.exe /j{$builder->concurrency} install_dev CNF_LDFLAGS=\"/NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:msvcrt /NODEFAULTLIB:msvcrtd /DEFAULTLIB:libcmt /LIBPATH:{$lib->getLibDir()} zlibstatic.lib\"");
// copy necessary c files
FileSystem::copy("{$lib->getSourceDir()}\\ms\\applink.c", "{$lib->getIncludeDir()}\\openssl\\applink.c");
// patch cmake outputs
FileSystem::replaceFileRegex(
"{$lib->getLibDir()}\\cmake\\OpenSSL\\OpenSSLConfig.cmake",
'/set\(OPENSSL_LIBCRYPTO_DEPENDENCIES .*\)/m',
'set(OPENSSL_LIBCRYPTO_DEPENDENCIES "${OPENSSL_LIBRARY_DIR}" ws2_32.lib gdi32.lib advapi32.lib crypt32.lib user32.lib)'
);
}
#[BuildFor('Darwin')]
public function buildForDarwin(LibraryPackage $pkg): void
{

View File

@@ -73,6 +73,11 @@ class postgresql extends LibraryPackage
FileSystem::resetDir("{$this->getSourceDir()}/build");
if ($installer->isPackageResolved('ldap')) {
$ldap_libs = clean_spaces(implode(' ', PkgConfigUtil::getLibsArray('ldap')));
FileSystem::replaceFileStr("{$this->getSourceDir()}/configure", '-lldap', $ldap_libs);
}
// PHP source relies on the non-private encoding functions in libpgcommon.a
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/src/common/Makefile",

View File

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Package\Library;
use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Util\FileSystem;
#[Library('pthreads4w')]
class pthreads4w
{
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
cmd()->cd($lib->getSourceDir())
->exec(
'nmake /E /nologo /f Makefile ' .
'DESTROOT=' . $lib->getBuildRootPath() . ' ' .
'XCFLAGS="/MT" ' . // no dll
'EHFLAGS="/I. /DHAVE_CONFIG_H /Os /Ob2 /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" ' .
'pthreadVC3.inlined_static_stamp'
);
FileSystem::createDir($lib->getLibDir());
FileSystem::createDir($lib->getIncludeDir());
FileSystem::copy("{$lib->getSourceDir()}\\libpthreadVC3.lib", "{$lib->getLibDir()}\\libpthreadVC3.lib");
FileSystem::copy("{$lib->getSourceDir()}\\_ptw32.h", "{$lib->getIncludeDir()}\\_ptw32.h");
FileSystem::copy("{$lib->getSourceDir()}\\pthread.h", "{$lib->getIncludeDir()}\\pthread.h");
FileSystem::copy("{$lib->getSourceDir()}\\sched.h", "{$lib->getIncludeDir()}\\sched.h");
FileSystem::copy("{$lib->getSourceDir()}\\semaphore.h", "{$lib->getIncludeDir()}\\semaphore.h");
}
}

View File

@@ -23,4 +23,15 @@ class qdbm
$ac->make(SystemTarget::getTargetOS() === 'Darwin' ? 'mac' : '');
$lib->patchPkgconfPrefix(['qdbm.pc']);
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
cmd()->cd($lib->getSourceDir())
->exec('nmake /f VCMakefile');
FileSystem::createDir($lib->getLibDir());
FileSystem::createDir($lib->getIncludeDir());
FileSystem::copy("{$lib->getSourceDir()}\\qdbm_a.lib", "{$lib->getLibDir()}\\qdbm_a.lib");
FileSystem::copy("{$lib->getSourceDir()}\\depot.h", "{$lib->getIncludeDir()}\\depot.h");
}
}

View File

@@ -6,8 +6,11 @@ namespace Package\Library;
use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Attribute\Package\PatchBeforeBuild;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
#[Library('sqlite')]
class sqlite
@@ -19,4 +22,18 @@ class sqlite
UnixAutoconfExecutor::create($lib)->configure()->make();
$lib->patchPkgconfPrefix(['sqlite3.pc']);
}
#[PatchBeforeBuild]
public function patchBeforeBuild(LibraryPackage $lib): void
{
spc_skip_if(SystemTarget::getTargetOS() !== 'Windows', 'This patch is only for Windows builds.');
FileSystem::copy(ROOT_DIR . '/src/globals/extra/Makefile-sqlite', "{$lib->getSourceDir()}\\Makefile");
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
cmd()->cd($lib->getSourceDir())
->exec("nmake PREFIX={$lib->getBuildRootPath()} install-static");
}
}

View File

@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Util\FileSystem;
#[Library('xz')]
class xz
@@ -27,4 +29,14 @@ class xz
$lib->patchPkgconfPrefix(['liblzma.pc']);
$lib->patchLaDependencyPrefix();
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)->build();
// copy lzma.lib to liblzma_a.lib
FileSystem::copy("{$lib->getLibDir()}\\lzma.lib", "{$lib->getLibDir()}\\liblzma_a.lib");
// patch lzma.h: make static API always available on Windows
FileSystem::replaceFileStr("{$lib->getIncludeDir()}\\lzma.h", 'defined(LZMA_API_STATIC)', 'defined(_WIN32)');
}
}

View File

@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Util\FileSystem;
#[Library('zlib')]
class zlib
@@ -21,4 +23,29 @@ class zlib
// Patch pkg-config file
$lib->patchPkgconfPrefix(['zlib.pc'], PKGCONF_PATCH_PREFIX);
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)->build();
$detect_list = [
'zlibstatic.lib',
'zs.lib',
'libzs.lib',
'libz.lib',
];
foreach ($detect_list as $item) {
if (file_exists("{$lib->getLibDir()}\\{$item}")) {
FileSystem::copy("{$lib->getLibDir()}\\{$item}", "{$lib->getLibDir()}\\zlib_a.lib");
FileSystem::copy("{$lib->getLibDir()}\\{$item}", "{$lib->getLibDir()}\\zlibstatic.lib");
break;
}
}
FileSystem::removeFileIfExists("{$lib->getBinDir()}\\zlib.dll");
FileSystem::removeFileIfExists("{$lib->getLibDir()}\\zlib.lib");
FileSystem::removeFileIfExists("{$lib->getLibDir()}\\libz.dll");
FileSystem::removeFileIfExists("{$lib->getLibDir()}\\libz.lib");
FileSystem::removeFileIfExists("{$lib->getLibDir()}\\z.lib");
FileSystem::removeFileIfExists("{$lib->getLibDir()}\\z.dll");
}
}

View File

@@ -8,10 +8,24 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
#[Library('zstd')]
class zstd
{
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $package): void
{
WindowsCMakeExecutor::create($package)
->setWorkingDir("{$package->getSourceDir()}/build/cmake")
->setBuildDir("{$package->getSourceDir()}/build/cmake/build")
->addConfigureArgs(
'-DZSTD_BUILD_STATIC=ON',
'-DZSTD_BUILD_SHARED=OFF',
)
->build();
}
#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $lib): void

View File

@@ -10,6 +10,7 @@ use StaticPHP\Attribute\Package\Target;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
@@ -20,7 +21,9 @@ class curl
#[PatchDescription('Remove CMAKE_C_IMPLICIT_LINK_LIBRARIES and fix macOS framework detection')]
public function patchBeforeBuild(LibraryPackage $lib): bool
{
shell()->cd($lib->getSourceDir())->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt');
if (SystemTarget::getTargetOS() !== 'Windows') {
shell()->cd($lib->getSourceDir())->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt');
}
if (SystemTarget::getTargetOS() === 'Darwin') {
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/CMakeLists.txt", '/NOT COREFOUNDATION_FRAMEWORK/m', 'FALSE');
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/CMakeLists.txt", '/NOT SYSTEMCONFIGURATION_FRAMEWORK/m', 'FALSE');
@@ -29,6 +32,34 @@ class curl
return true;
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->optionalPackage('zstd', ...cmake_boolean_args('CURL_ZSTD'))
->optionalPackage('brotli', ...cmake_boolean_args('CURL_BROTLI'))
->addConfigureArgs(
'-DBUILD_CURL_EXE=OFF',
'-DZSTD_LIBRARY=zstd_static.lib',
'-DBUILD_TESTING=OFF',
'-DBUILD_EXAMPLES=OFF',
'-DUSE_LIBIDN2=OFF',
'-DCURL_USE_LIBPSL=OFF',
'-DUSE_WINDOWS_SSPI=ON',
'-DCURL_USE_SCHANNEL=ON',
'-DCURL_USE_OPENSSL=OFF',
'-DCURL_ENABLE_SSL=ON',
'-DUSE_NGHTTP2=ON',
'-DSHARE_LIB_OBJECT=OFF',
'-DCURL_USE_LIBSSH2=ON',
'-DENABLE_IPV6=ON',
)
->build();
// move libcurl.lib to libcurl_a.lib
rename("{$lib->getLibDir()}\\libcurl.lib", "{$lib->getLibDir()}\\libcurl_a.lib");
FileSystem::replaceFileStr("{$lib->getIncludeDir()}\\curl\\curl.h", '#ifdef CURL_STATICLIB', '#if 1');
}
#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $lib): void

View File

@@ -468,6 +468,9 @@ class ArtifactExtractor
if ($extname !== 'exe' && !is_dir($target)) {
FileSystem::createDir($target);
if (!is_dir($target)) {
throw new FileSystemException("Failed to create target directory: {$target}");
}
}
match (SystemTarget::getTargetOS()) {
'Windows' => match ($extname) {

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace StaticPHP\Command;
use StaticPHP\Artifact\DownloaderOptions;
use StaticPHP\DI\ApplicationContext;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Registry\PackageLoader;
@@ -29,6 +30,7 @@ class InstallPackageCommand extends BaseCommand
return array_filter($packages, fn ($name) => str_starts_with($name, $val));
}
);
$this->getDefinition()->addOptions(DownloaderOptions::getConsoleOptions('dl'));
}
public function handle(): int

View File

@@ -147,13 +147,17 @@ readonly class Doctor
{
if (SystemTarget::getTargetOS() === 'Windows') {
$trial_ls = [
getenv('LOCALAPPDATA') ?: ((getenv('USERPROFILE') ?: 'C:\Users\Default') . '\AppData\Local') . '\.spc-doctor.lock',
getenv('LOCALAPPDATA') ?
(getenv('LOCALAPPDATA') . '\.spc-doctor.lock') :
(((getenv('USERPROFILE') ?: 'C:\Users\Default') . '\AppData\Local') . '\.spc-doctor.lock'),
sys_get_temp_dir() . '\.spc-doctor.lock',
WORKING_DIR . '\.spc-doctor.lock',
];
} else {
$trial_ls = [
getenv('XDG_CACHE_HOME') ?: ((getenv('HOME') ?: '/tmp') . '/.cache') . '/.spc-doctor.lock',
getenv('XDG_CACHE_HOME') ?
(getenv('XDG_CACHE_HOME') . '/.spc-doctor.lock')
: (((getenv('HOME') ?: '/tmp') . '/.cache') . '/.spc-doctor.lock'),
sys_get_temp_dir() . '/.spc-doctor.lock',
WORKING_DIR . '/.spc-doctor.lock',
];

View File

@@ -44,18 +44,20 @@ class LibraryPackage extends Package
return false;
}
}
foreach (PackageConfig::get($this->getName(), 'pkg-configs', []) as $pc) {
if (!str_ends_with($pc, '.pc')) {
$pc .= '.pc';
if (SystemTarget::getTargetOS() !== 'Windows') {
foreach (PackageConfig::get($this->getName(), 'pkg-configs', []) as $pc) {
if (!str_ends_with($pc, '.pc')) {
$pc .= '.pc';
}
if (!file_exists("{$this->getLibDir()}/pkgconfig/{$pc}")) {
return false;
}
}
if (!file_exists("{$this->getLibDir()}/pkgconfig/{$pc}")) {
return false;
}
}
foreach (PackageConfig::get($this->getName(), 'static-bins', []) as $bin) {
$path = FileSystem::isRelativePath($bin) ? "{$this->getBinDir()}/{$bin}" : $bin;
if (!file_exists($path)) {
return false;
foreach (PackageConfig::get($this->getName(), 'static-bins', []) as $bin) {
$path = FileSystem::isRelativePath($bin) ? "{$this->getBinDir()}/{$bin}" : $bin;
if (!file_exists($path)) {
return false;
}
}
}
return true;

View File

@@ -168,10 +168,23 @@ class PackageInstaller
// check download
if ($this->download) {
$downloaderOptions = DownloaderOptions::extractFromConsoleOptions($this->options, 'dl');
$downloader = new ArtifactDownloader(
[...$downloaderOptions, 'source-only' => implode(',', array_map(fn ($x) => $x->getName(), $this->build_packages))],
$this->interactive
// Collect packages that have no build stage for current OS but do have a platform binary.
// These must always download binary (not source), regardless of global prefer-source setting.
$binary_only_packages = array_filter(
$this->packages,
fn ($p) => $p instanceof LibraryPackage
&& !$this->isBuildPackage($p)
&& !$p->hasStage('build')
&& ($p->getArtifact()?->hasPlatformBinary() ?? false)
);
$dl_opts = [
...$downloaderOptions,
'source-only' => implode(',', array_map(fn ($x) => $x->getName(), $this->build_packages)),
];
if ($binary_only_packages !== []) {
$dl_opts['binary-only'] = implode(',', array_map(fn ($x) => $x->getName(), $binary_only_packages));
}
$downloader = new ArtifactDownloader($dl_opts, $this->interactive);
$downloader->addArtifacts($this->getArtifacts())->download();
} else {
logger()->notice('Skipping download (--no-download option enabled)');
@@ -310,6 +323,11 @@ class PackageInstaller
$artifact = $package->getArtifact();
return $artifact->isBinaryExtracted();
}
// Fallback: if the download cache is missing (e.g. download failed or cache was cleared),
// still check whether the files are physically present in buildroot.
if ($package instanceof LibraryPackage) {
return $package->isInstalled();
}
return false;
}
@@ -716,10 +734,13 @@ class PackageInstaller
}
$is_to_build = $this->isBuildPackage($package);
$has_build_stage = $package instanceof LibraryPackage && $package->hasStage('build');
$should_use_binary = $package instanceof LibraryPackage && ($package->getArtifact()?->shouldUseBinary() ?? false);
// Use hasPlatformBinary() here (not shouldUseBinary()) because this runs before download,
// so the binary is not yet on disk. We only need to know if a binary is declared for
// the current platform in the artifact config.
$has_platform_binary = $package instanceof LibraryPackage && ($package->getArtifact()?->hasPlatformBinary() ?? false);
// Check if package can neither be built nor installed
if (!$is_to_build && !$should_use_binary && !$has_build_stage) {
if (!$is_to_build && !$has_platform_binary && !$has_build_stage) {
throw new WrongUsageException("Package '{$package->getName()}' cannot be installed: no build stage defined and no binary artifact available for current OS: " . SystemTarget::getCurrentPlatformString());
}
}

View File

@@ -176,6 +176,12 @@ class WindowsCMakeExecutor extends Executor
return implode(' ', array_merge($this->configure_args, $this->getDefaultCMakeArgs()));
}
public function setWorkingDir(string $dir): static
{
$this->cmd = $this->cmd->cd($dir);
return $this;
}
/**
* Returns the default CMake args.
*/
@@ -207,12 +213,12 @@ class WindowsCMakeExecutor extends Executor
private function initBuildDir(): void
{
if ($this->build_dir === null) {
$this->build_dir = "{$this->package->getSourceDir()}\\build";
$this->build_dir = "{$this->package->getSourceRoot()}\\build";
}
}
private function initCmd(): void
{
$this->cmd = cmd()->cd($this->package->getSourceDir());
$this->cmd = cmd()->cd($this->package->getSourceRoot());
}
}

View File

@@ -6,6 +6,7 @@ namespace StaticPHP\Runtime\Shell;
use StaticPHP\Exception\InterruptException;
use StaticPHP\Exception\SPCInternalException;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
/**
@@ -132,7 +133,8 @@ class DefaultShell extends Shell
};
$mute = $this->console_putput ? '' : ' 2>/dev/null';
$cmd = "tar {$compression_flag}xf {$archive_arg} --strip-components {$strip} -C {$target_arg}{$mute}";
$tar = SystemTarget::isUnix() ? 'tar' : '"C:\\Windows\\system32\\tar.exe"';
$cmd = "{$tar} {$compression_flag}xf {$archive_arg} --strip-components {$strip} -C {$target_arg}{$mute}";
$this->logCommandInfo($cmd);
logger()->debug("[TAR EXTRACT] {$cmd}");
@@ -185,9 +187,11 @@ class DefaultShell extends Shell
};
$extname = FileSystem::extname($archive_path);
$tar = SystemTarget::isUnix() ? 'tar' : '"C:\\Windows\\system32\\tar.exe"';
match ($extname) {
'tar' => $this->executeTarExtract($archive_path, $target_path, 'none'),
'gz', 'tgz', 'xz', 'txz', 'bz2' => $run("{$_7z} x -so {$archive_arg} | tar -f - -x -C {$target_arg} --strip-components 1"),
'gz', 'tgz', 'xz', 'txz', 'bz2' => $run("{$_7z} x -so {$archive_arg} | {$tar} -f - -x -C {$target_arg} --strip-components 1"),
default => $run("{$_7z} x {$archive_arg} -o{$target_arg} -y{$mute}"),
};

View File

@@ -142,6 +142,9 @@ class FileSystem
logger()->debug("Copying file from {$from} to {$to}");
$dst_path = FileSystem::convertPath($to);
$src_path = FileSystem::convertPath($from);
if ($src_path === $dst_path) {
return true;
}
if (!copy($src_path, $dst_path)) {
throw new FileSystemException('Cannot copy file from ' . $src_path . ' to ' . $dst_path);
}
@@ -402,6 +405,7 @@ class FileSystem
public static function replacePathVariable(string $path): string
{
$replacement = [
'{build_root_path}' => BUILD_ROOT_PATH,
'{pkg_root_path}' => PKG_ROOT_PATH,
'{php_sdk_path}' => getenv('PHP_SDK_PATH') ? getenv('PHP_SDK_PATH') : WORKING_DIR . '/php-sdk-binary-tools',
'{working_dir}' => WORKING_DIR,

View File

@@ -4,12 +4,15 @@ declare(strict_types=1);
namespace StaticPHP\Util\System;
use StaticPHP\Exception\EnvironmentException;
use StaticPHP\Util\FileSystem;
class WindowsUtil
{
private static array|false|null $vsCache = null;
/**
* Find windows program using executable name.
* Find Windows program using executable name.
*
* @param string $name command name (xxx.exe)
* @param array $paths search path (default use env path)
@@ -39,8 +42,16 @@ class WindowsUtil
*/
public static function findVisualStudio(): array|false
{
if (self::$vsCache !== null) {
return self::$vsCache;
}
// call vswhere (need VS and C++ tools installed), output is json
$vswhere_exec = PKG_ROOT_PATH . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'vswhere.exe';
// detect vswhere exists, if not throw error
if (!file_exists($vswhere_exec)) {
throw new EnvironmentException('vswhere.exe not found, please run `doctor` command first');
}
$args = [
'-latest',
'-format', 'json',
@@ -49,13 +60,13 @@ class WindowsUtil
$cmd = escapeshellarg($vswhere_exec) . ' ' . implode(' ', $args);
$result = f_exec($cmd, $out, $code);
if ($code !== 0 || !$result) {
return false;
return self::$vsCache = false;
}
$json = json_decode(implode("\n", $out), true);
if (!is_array($json) || count($json) === 0) {
return false;
return self::$vsCache = false;
}
return [
return self::$vsCache = [
'version' => $json[0]['installationVersion'],
'major_version' => explode('.', $json[0]['installationVersion'])[0],
'dir' => $json[0]['installationPath'],
@@ -89,6 +100,7 @@ class WindowsUtil
$ldflags = '/nodefaultlib:msvcrt /nodefaultlib:msvcrtd /defaultlib:libcmt';
}
$buildroot = str_replace('\\', '\\\\', BUILD_ROOT_PATH);
$source = str_replace('\\', '/', SOURCE_PATH);
$toolchain = <<<CMAKE
set(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_PROCESSOR x64)
@@ -99,11 +111,50 @@ SET(CMAKE_CXX_FLAGS_DEBUG "{$cflags}")
SET(CMAKE_EXE_LINKER_FLAGS "{$ldflags}")
SET(CMAKE_FIND_ROOT_PATH "{$buildroot}")
SET(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
list(PREPEND CMAKE_MODULE_PATH "{$source}/cmake-find")
CMAKE;
if (!is_dir(SOURCE_PATH)) {
FileSystem::createDir(SOURCE_PATH);
}
FileSystem::writeFile(SOURCE_PATH . '\toolchain.cmake', $toolchain);
self::writeCmakeFindModules();
return realpath(SOURCE_PATH . '\toolchain.cmake');
}
/**
* Write cmake-find wrapper modules to source/cmake-find/.
* These override cmake's built-in Find*.cmake modules to inject
* Windows-specific static library dependencies (e.g. zlib into OpenSSL).
* Called both from makeCmakeToolchainFile() and from WindowsCMakeExecutor
* so the modules are always present even when the static toolchain.cmake
* file is used directly without regeneration.
*/
public static function writeCmakeFindModules(): void
{
$cmake_find_dir = SOURCE_PATH . DIRECTORY_SEPARATOR . 'cmake-find';
if (!is_dir($cmake_find_dir)) {
FileSystem::createDir($cmake_find_dir);
}
FileSystem::writeFile($cmake_find_dir . DIRECTORY_SEPARATOR . 'FindOpenSSL.cmake', <<<'CMAKE'
# Custom FindOpenSSL.cmake wrapper for static-php-cli Windows builds.
if(WIN32 AND (OpenSSL_FOUND OR OPENSSL_FOUND))
list(GET CMAKE_FIND_ROOT_PATH 0 _spc_buildroot)
# Normalize to forward slashes — backslash paths cause 'Invalid character
# escape' errors when cmake parses them inside string arguments.
file(TO_CMAKE_PATH "${_spc_buildroot}" _spc_buildroot)
set(_spc_zlib "${_spc_buildroot}/lib/zlibstatic.lib")
if(EXISTS "${_spc_zlib}")
foreach(_spc_var OPENSSL_LIBRARIES OPENSSL_CRYPTO_LIBRARIES OPENSSL_SSL_LIBRARIES)
if(DEFINED ${_spc_var} AND NOT "${_spc_zlib}" IN_LIST ${_spc_var})
list(APPEND ${_spc_var} "${_spc_zlib}")
endif()
endforeach()
endif()
unset(_spc_buildroot)
unset(_spc_zlib)
unset(_spc_var)
endif()
CMAKE);
}
}

View File

@@ -0,0 +1,568 @@
UNICODE LICENSE V3
COPYRIGHT AND PERMISSION NOTICE
Copyright © 2016-2025 Unicode, Inc.
NOTICE TO USER: Carefully read the following legal agreement. BY
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
Permission is hereby granted, free of charge, to any person obtaining a
copy of data files and any associated documentation (the "Data Files") or
software and any associated documentation (the "Software") to deal in the
Data Files or Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, and/or sell
copies of the Data Files or Software, and to permit persons to whom the
Data Files or Software are furnished to do so, provided that either (a)
this copyright and permission notice appear with all copies of the Data
Files or Software, or (b) this copyright and permission notice appear in
associated Documentation.
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
THIRD PARTY RIGHTS.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
FILES OR SOFTWARE.
Except as contained in this notice, the name of a copyright holder shall
not be used in advertising or otherwise to promote the sale, use or other
dealings in these Data Files or Software without prior written
authorization of the copyright holder.
SPDX-License-Identifier: Unicode-3.0
----------------------------------------------------------------------
Third-Party Software Licenses
This section contains third-party software notices and/or additional
terms for licensed third-party software components included within ICU
libraries.
----------------------------------------------------------------------
ICU License - ICU 1.8.1 to ICU 57.1
COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 1995-2016 International Business Machines Corporation and others
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
All trademarks and registered trademarks mentioned herein are the
property of their respective owners.
----------------------------------------------------------------------
Chinese/Japanese Word Break Dictionary Data (cjdict.txt)
# The Google Chrome software developed by Google is licensed under
# the BSD license. Other software included in this distribution is
# provided under other licenses, as set forth below.
#
# The BSD License
# http://opensource.org/licenses/bsd-license.php
# Copyright (C) 2006-2008, Google Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with
# the distribution.
# Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# The word list in cjdict.txt are generated by combining three word lists
# listed below with further processing for compound word breaking. The
# frequency is generated with an iterative training against Google web
# corpora.
#
# * Libtabe (Chinese)
# - https://sourceforge.net/project/?group_id=1519
# - Its license terms and conditions are shown below.
#
# * IPADIC (Japanese)
# - http://chasen.aist-nara.ac.jp/chasen/distribution.html
# - Its license terms and conditions are shown below.
#
# ---------COPYING.libtabe ---- BEGIN--------------------
#
# /*
# * Copyright (c) 1999 TaBE Project.
# * Copyright (c) 1999 Pai-Hsiang Hsiao.
# * All rights reserved.
# *
# * Redistribution and use in source and binary forms, with or without
# * modification, are permitted provided that the following conditions
# * are met:
# *
# * . Redistributions of source code must retain the above copyright
# * notice, this list of conditions and the following disclaimer.
# * . Redistributions in binary form must reproduce the above copyright
# * notice, this list of conditions and the following disclaimer in
# * the documentation and/or other materials provided with the
# * distribution.
# * . Neither the name of the TaBE Project nor the names of its
# * contributors may be used to endorse or promote products derived
# * from this software without specific prior written permission.
# *
# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# * OF THE POSSIBILITY OF SUCH DAMAGE.
# */
#
# /*
# * Copyright (c) 1999 Computer Systems and Communication Lab,
# * Institute of Information Science, Academia
# * Sinica. All rights reserved.
# *
# * Redistribution and use in source and binary forms, with or without
# * modification, are permitted provided that the following conditions
# * are met:
# *
# * . Redistributions of source code must retain the above copyright
# * notice, this list of conditions and the following disclaimer.
# * . Redistributions in binary form must reproduce the above copyright
# * notice, this list of conditions and the following disclaimer in
# * the documentation and/or other materials provided with the
# * distribution.
# * . Neither the name of the Computer Systems and Communication Lab
# * nor the names of its contributors may be used to endorse or
# * promote products derived from this software without specific
# * prior written permission.
# *
# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# * OF THE POSSIBILITY OF SUCH DAMAGE.
# */
#
# Copyright 1996 Chih-Hao Tsai @ Beckman Institute,
# University of Illinois
# c-tsai4@uiuc.edu http://casper.beckman.uiuc.edu/~c-tsai4
#
# ---------------COPYING.libtabe-----END--------------------------------
#
#
# ---------------COPYING.ipadic-----BEGIN-------------------------------
#
# Copyright 2000, 2001, 2002, 2003 Nara Institute of Science
# and Technology. All Rights Reserved.
#
# Use, reproduction, and distribution of this software is permitted.
# Any copy of this software, whether in its original form or modified,
# must include both the above copyright notice and the following
# paragraphs.
#
# Nara Institute of Science and Technology (NAIST),
# the copyright holders, disclaims all warranties with regard to this
# software, including all implied warranties of merchantability and
# fitness, in no event shall NAIST be liable for
# any special, indirect or consequential damages or any damages
# whatsoever resulting from loss of use, data or profits, whether in an
# action of contract, negligence or other tortuous action, arising out
# of or in connection with the use or performance of this software.
#
# A large portion of the dictionary entries
# originate from ICOT Free Software. The following conditions for ICOT
# Free Software applies to the current dictionary as well.
#
# Each User may also freely distribute the Program, whether in its
# original form or modified, to any third party or parties, PROVIDED
# that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear
# on, or be attached to, the Program, which is distributed substantially
# in the same form as set out herein and that such intended
# distribution, if actually made, will neither violate or otherwise
# contravene any of the laws and regulations of the countries having
# jurisdiction over the User or the intended distribution itself.
#
# NO WARRANTY
#
# The program was produced on an experimental basis in the course of the
# research and development conducted during the project and is provided
# to users as so produced on an experimental basis. Accordingly, the
# program is provided without any warranty whatsoever, whether express,
# implied, statutory or otherwise. The term "warranty" used herein
# includes, but is not limited to, any warranty of the quality,
# performance, merchantability and fitness for a particular purpose of
# the program and the nonexistence of any infringement or violation of
# any right of any third party.
#
# Each user of the program will agree and understand, and be deemed to
# have agreed and understood, that there is no warranty whatsoever for
# the program and, accordingly, the entire risk arising from or
# otherwise connected with the program is assumed by the user.
#
# Therefore, neither ICOT, the copyright holder, or any other
# organization that participated in or was otherwise related to the
# development of the program and their respective officials, directors,
# officers and other employees shall be held liable for any and all
# damages, including, without limitation, general, special, incidental
# and consequential damages, arising out of or otherwise in connection
# with the use or inability to use the program or any product, material
# or result produced or otherwise obtained by using the program,
# regardless of whether they have been advised of, or otherwise had
# knowledge of, the possibility of such damages at any time during the
# project or thereafter. Each user will be deemed to have agreed to the
# foregoing by his or her commencement of use of the program. The term
# "use" as used herein includes, but is not limited to, the use,
# modification, copying and distribution of the program and the
# production of secondary products from the program.
#
# In the case where the program, whether in its original form or
# modified, was distributed or delivered to or received by a user from
# any person, organization or entity other than ICOT, unless it makes or
# grants independently of ICOT any specific warranty to the user in
# writing, such person, organization or entity, will also be exempted
# from and not be held liable to the user for any such damages as noted
# above as far as the program is concerned.
#
# ---------------COPYING.ipadic-----END----------------------------------
----------------------------------------------------------------------
Lao Word Break Dictionary Data (laodict.txt)
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
# Copyright (c) 2015 International Business Machines Corporation
# and others. All Rights Reserved.
#
# Project: https://github.com/rober42539/lao-dictionary
# Dictionary: https://github.com/rober42539/lao-dictionary/laodict.txt
# License: https://github.com/rober42539/lao-dictionary/LICENSE.txt
# (copied below)
#
# This file is derived from the above dictionary version of Nov 22, 2020
# ----------------------------------------------------------------------
# Copyright (C) 2013 Brian Eugene Wilson, Robert Martin Campbell.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer. Redistributions in binary
# form must reproduce the above copyright notice, this list of conditions and
# the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.
# --------------------------------------------------------------------------
----------------------------------------------------------------------
Burmese Word Break Dictionary Data (burmesedict.txt)
# Copyright (c) 2014 International Business Machines Corporation
# and others. All Rights Reserved.
#
# This list is part of a project hosted at:
# github.com/kanyawtech/myanmar-karen-word-lists
#
# --------------------------------------------------------------------------
# Copyright (c) 2013, LeRoy Benjamin Sharon
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met: Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer. Redistributions in binary form must reproduce the
# above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# Neither the name Myanmar Karen Word Lists, nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# --------------------------------------------------------------------------
----------------------------------------------------------------------
Time Zone Database
ICU uses the public domain data and code derived from Time Zone
Database for its time zone support. The ownership of the TZ database
is explained in BCP 175: Procedure for Maintaining the Time Zone
Database section 7.
# 7. Database Ownership
#
# The TZ database itself is not an IETF Contribution or an IETF
# document. Rather it is a pre-existing and regularly updated work
# that is in the public domain, and is intended to remain in the
# public domain. Therefore, BCPs 78 [RFC5378] and 79 [RFC3979] do
# not apply to the TZ Database or contributions that individuals make
# to it. Should any claims be made and substantiated against the TZ
# Database, the organization that is providing the IANA
# Considerations defined in this RFC, under the memorandum of
# understanding with the IETF, currently ICANN, may act in accordance
# with all competent court orders. No ownership claims will be made
# by ICANN or the IETF Trust on the database or the code. Any person
# making a contribution to the database or code waives all rights to
# future claims in that contribution or in the TZ Database.
----------------------------------------------------------------------
Google double-conversion
Copyright 2006-2011, the V8 project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
JSON parsing library (nlohmann/json)
File: vendor/json/upstream/single_include/nlohmann/json.hpp (only for ICU4C)
MIT License
Copyright (c) 2013-2022 Niels Lohmann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
----------------------------------------------------------------------
File: aclocal.m4 (only for ICU4C)
Section: pkg.m4 - Macros to locate and utilise pkg-config.
Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
As a special exception to the GNU General Public License, if you
distribute this file as part of a program that contains a
configuration script generated by Autoconf, you may include it under
the same distribution terms that you use for the rest of that
program.
(The condition for the exception is fulfilled because
ICU4C includes a configuration script generated by Autoconf,
namely the `configure` script.)
----------------------------------------------------------------------
File: config.guess (only for ICU4C)
This file is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <https://www.gnu.org/licenses/>.
As a special exception to the GNU General Public License, if you
distribute this file as part of a program that contains a
configuration script generated by Autoconf, you may include it under
the same distribution terms that you use for the rest of that
program. This Exception is an additional permission under section 7
of the GNU General Public License, version 3 ("GPLv3").
(The condition for the exception is fulfilled because
ICU4C includes a configuration script generated by Autoconf,
namely the `configure` script.)
----------------------------------------------------------------------
File: install-sh (only for ICU4C)
Copyright 1991 by the Massachusetts Institute of Technology
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the name of M.I.T. not be used in advertising or
publicity pertaining to distribution of the software without specific,
written prior permission. M.I.T. makes no representations about the
suitability of this software for any purpose. It is provided "as is"
without express or implied warranty.
----------------------------------------------------------------------
File: sorttable.js (only for ICU4J)
The MIT Licence, for code from kryogenix.org
Code downloaded from the Browser Experiments section of kryogenix.org is
licenced under the so-called MIT licence. The licence is below.
Copyright (c) 1997-date Stuart Langridge
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,23 @@
PostgreSQL Database Management System
(also known as Postgres, formerly known as Postgres95)
Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
Portions Copyright (c) 1994, The Regents of the University of California
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose, without fee, and without a written agreement
is hereby granted, provided that the above copyright notice and this
paragraph and the following two paragraphs appear in all copies.
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

View File

@@ -20,7 +20,7 @@ index 8f05686367..c155028233 100644
REGISTER_INI_ENTRIES();
- FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0;
+ FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 1;
+ FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 0;
zend_ffi_exception_ce = register_class_FFI_Exception(zend_ce_error);
@@ -103,7 +103,7 @@ index 4287045511..eab0311d07 100644
return NULL;
}
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_in = 0;
fd = STDIN_FILENO;
if (cli_in) {
@@ -112,7 +112,7 @@ index 4287045511..eab0311d07 100644
#endif
} else if (!strcasecmp(path, "stdout")) {
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_out = 0;
fd = STDOUT_FILENO;
if (cli_out++) {
@@ -121,7 +121,7 @@ index 4287045511..eab0311d07 100644
#endif
} else if (!strcasecmp(path, "stderr")) {
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_err = 0;
fd = STDERR_FILENO;
if (cli_err++) {
@@ -130,7 +130,7 @@ index 4287045511..eab0311d07 100644
int dtablesize;
- if (strcmp(sapi_module.name, "cli")) {
+ if (strcmp(sapi_module.name, "cli") || strcmp(sapi_module.name, "micro")) {
+ if (strcmp(sapi_module.name, "cli") && strcmp(sapi_module.name, "micro")) {
if (options & REPORT_ERRORS) {
php_error_docref(NULL, E_WARNING, "Direct access to file descriptors is only available from command-line PHP");
}

View File

@@ -20,7 +20,7 @@ index bbfe07576e..398373d577 100644
REGISTER_INI_ENTRIES();
- FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0;
+ FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 1;
+ FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 0;
zend_ffi_exception_ce = register_class_FFI_Exception(zend_ce_error);
@@ -112,7 +112,7 @@ index 8926485025..6740163bc5 100644
return NULL;
}
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_in = 0;
fd = STDIN_FILENO;
if (cli_in) {
@@ -121,7 +121,7 @@ index 8926485025..6740163bc5 100644
#endif
} else if (!strcasecmp(path, "stdout")) {
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_out = 0;
fd = STDOUT_FILENO;
if (cli_out++) {
@@ -130,7 +130,7 @@ index 8926485025..6740163bc5 100644
#endif
} else if (!strcasecmp(path, "stderr")) {
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_err = 0;
fd = STDERR_FILENO;
if (cli_err++) {
@@ -139,7 +139,7 @@ index 8926485025..6740163bc5 100644
int dtablesize;
- if (strcmp(sapi_module.name, "cli")) {
+ if (strcmp(sapi_module.name, "cli") || strcmp(sapi_module.name, "micro")) {
+ if (strcmp(sapi_module.name, "cli") && strcmp(sapi_module.name, "micro")) {
if (options & REPORT_ERRORS) {
php_error_docref(NULL, E_WARNING, "Direct access to file descriptors is only available from command-line PHP");
}

View File

@@ -20,7 +20,7 @@ index d797f5f93f..27cb05e3e4 100644
REGISTER_INI_ENTRIES();
- FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0;
+ FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 1;
+ FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 0;
zend_ffi_exception_ce = register_class_FFI_Exception(zend_ce_error);
@@ -111,7 +111,7 @@ index a5581d9ccc..98455f7b52 100644
return NULL;
}
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_in = 0;
fd = STDIN_FILENO;
if (cli_in) {
@@ -120,7 +120,7 @@ index a5581d9ccc..98455f7b52 100644
#endif
} else if (!strcasecmp(path, "stdout")) {
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_out = 0;
fd = STDOUT_FILENO;
if (cli_out++) {
@@ -129,7 +129,7 @@ index a5581d9ccc..98455f7b52 100644
#endif
} else if (!strcasecmp(path, "stderr")) {
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_err = 0;
fd = STDERR_FILENO;
if (cli_err++) {
@@ -138,7 +138,7 @@ index a5581d9ccc..98455f7b52 100644
int dtablesize;
- if (strcmp(sapi_module.name, "cli")) {
+ if (strcmp(sapi_module.name, "cli") || strcmp(sapi_module.name, "micro")) {
+ if (strcmp(sapi_module.name, "cli") && strcmp(sapi_module.name, "micro")) {
if (options & REPORT_ERRORS) {
php_error_docref(NULL, E_WARNING, "Direct access to file descriptors is only available from command-line PHP");
}

View File

@@ -20,7 +20,7 @@ index 10fc11f5..eb4d4175 100644
REGISTER_INI_ENTRIES();
- FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0;
+ FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 1;
+ FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 0;
zend_ffi_exception_ce = register_class_FFI_Exception(zend_ce_error);
@@ -98,7 +98,7 @@ index ea33ba49..083184b8 100644
return NULL;
}
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_in = 0;
fd = STDIN_FILENO;
if (cli_in) {
@@ -107,7 +107,7 @@ index ea33ba49..083184b8 100644
#endif
} else if (!strcasecmp(path, "stdout")) {
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_out = 0;
fd = STDOUT_FILENO;
if (cli_out++) {
@@ -116,7 +116,7 @@ index ea33ba49..083184b8 100644
#endif
} else if (!strcasecmp(path, "stderr")) {
- if (!strcmp(sapi_module.name, "cli")) {
+ if (!strcmp(sapi_module.name, "cli") && !strcmp(sapi_module.name, "micro")) {
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
static int cli_err = 0;
fd = STDERR_FILENO;
if (cli_err++) {
@@ -125,7 +125,7 @@ index ea33ba49..083184b8 100644
int dtablesize;
- if (strcmp(sapi_module.name, "cli")) {
+ if (strcmp(sapi_module.name, "cli") || strcmp(sapi_module.name, "micro")) {
+ if (strcmp(sapi_module.name, "cli") && strcmp(sapi_module.name, "micro")) {
if (options & REPORT_ERRORS) {
php_error_docref(NULL, E_WARNING, "Direct access to file descriptors is only available from command-line PHP");
}