mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
update libwebp and libxml2 (#982)
This commit is contained in:
commit
07ea1e2887
@ -771,8 +771,9 @@
|
||||
]
|
||||
},
|
||||
"libwebp": {
|
||||
"type": "url",
|
||||
"url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz",
|
||||
"type": "ghtagtar",
|
||||
"repo": "webmproject/libwebp",
|
||||
"match": "v1\\.\\d+\\.\\d+$",
|
||||
"provide-pre-built": true,
|
||||
"license": {
|
||||
"type": "file",
|
||||
@ -780,8 +781,10 @@
|
||||
}
|
||||
},
|
||||
"libxml2": {
|
||||
"type": "url",
|
||||
"url": "https://github.com/GNOME/libxml2/archive/refs/tags/v2.12.5.tar.gz",
|
||||
"type": "ghtagtar",
|
||||
"repo": "GNOME/libxml2",
|
||||
"match": "v2\\.\\d+\\.\\d+$",
|
||||
"provide-pre-built": false,
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "Copyright"
|
||||
@ -1169,9 +1172,8 @@
|
||||
}
|
||||
},
|
||||
"xdebug": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/xdebug",
|
||||
"filename": "xdebug.tgz",
|
||||
"type": "pie",
|
||||
"repo": "xdebug/xdebug",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
|
||||
@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\toolchain\ToolchainManager;
|
||||
use SPC\toolchain\ZigToolchain;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('imagick')]
|
||||
@ -19,7 +21,9 @@ class imagick extends Extension
|
||||
protected function splitLibsIntoStaticAndShared(string $allLibs): array
|
||||
{
|
||||
[$static, $shared] = parent::splitLibsIntoStaticAndShared($allLibs);
|
||||
if (str_contains(getenv('PATH'), 'rh/devtoolset') || str_contains(getenv('PATH'), 'rh/gcc-toolset')) {
|
||||
if (ToolchainManager::getToolchainClass() !== ZigToolchain::class &&
|
||||
(str_contains(getenv('PATH'), 'rh/devtoolset') || str_contains(getenv('PATH'), 'rh/gcc-toolset'))
|
||||
) {
|
||||
$static .= ' -l:libstdc++.a';
|
||||
$shared = str_replace('-lstdc++', '', $shared);
|
||||
}
|
||||
|
||||
@ -24,4 +24,9 @@ class mongodb extends Extension
|
||||
$arg .= $this->builder->getLib('zlib') ? ' --with-mongodb-zlib=yes ' : ' --with-mongodb-zlib=bundled ';
|
||||
return clean_spaces($arg);
|
||||
}
|
||||
|
||||
public function getExtraEnv(): array
|
||||
{
|
||||
return ['CFLAGS' => '-std=c17'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ class pgsql extends Extension
|
||||
protected function getExtraEnv(): array
|
||||
{
|
||||
return [
|
||||
'CFLAGS' => '-Wno-int-conversion',
|
||||
'CFLAGS' => '-std=c17 -Wno-int-conversion',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@ namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\builder\linux\SystemUtil;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\toolchain\GccNativeToolchain;
|
||||
use SPC\toolchain\ToolchainManager;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
@ -15,26 +17,19 @@ class liburing extends LinuxLibraryBase
|
||||
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
if (!SystemUtil::isMuslDist()) {
|
||||
return false;
|
||||
if (SystemUtil::isMuslDist()) {
|
||||
FileSystem::replaceFileStr($this->source_dir . '/configure', 'realpath -s', 'realpath');
|
||||
return true;
|
||||
}
|
||||
FileSystem::replaceFileStr($this->source_dir . '/configure', 'realpath -s', 'realpath');
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
$use_libc = SPCTarget::getLibc() !== 'glibc' || version_compare(SPCTarget::getLibcVersion(), '2.30', '>=');
|
||||
$use_libc = ToolchainManager::getToolchainClass() !== GccNativeToolchain::class || version_compare(SPCTarget::getLibcVersion(), '2.30', '>=');
|
||||
$make = UnixAutoconfExecutor::create($this);
|
||||
|
||||
if (!$use_libc) {
|
||||
$make->appendEnv([
|
||||
'CC' => 'gcc', // libc-less version fails to compile with clang or zig
|
||||
'CXX' => 'g++',
|
||||
'AR' => 'ar',
|
||||
'LD' => 'ld',
|
||||
]);
|
||||
} else {
|
||||
if ($use_libc) {
|
||||
$make->appendEnv([
|
||||
'CFLAGS' => '-D_GNU_SOURCE',
|
||||
]);
|
||||
@ -51,7 +46,7 @@ class liburing extends LinuxLibraryBase
|
||||
$use_libc ? '--use-libc' : '',
|
||||
)
|
||||
->configure()
|
||||
->make('library', 'install ENABLE_SHARED=0', with_clean: false);
|
||||
->make('library ENABLE_SHARED=0', 'install ENABLE_SHARED=0', with_clean: false);
|
||||
|
||||
$this->patchPkgconfPrefix();
|
||||
}
|
||||
|
||||
@ -62,6 +62,7 @@ class openssl extends LinuxLibraryBase
|
||||
"{$zlib_extra}" .
|
||||
'enable-pie ' .
|
||||
'no-legacy ' .
|
||||
'no-tests ' .
|
||||
"linux-{$arch}"
|
||||
)
|
||||
->exec('make clean')
|
||||
|
||||
@ -10,7 +10,12 @@ trait gmp
|
||||
{
|
||||
protected function build(): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($this)->configure()->make();
|
||||
UnixAutoconfExecutor::create($this)
|
||||
->appendEnv([
|
||||
'CFLAGS' => '-std=c17',
|
||||
])
|
||||
->configure()
|
||||
->make();
|
||||
$this->patchPkgconfPrefix(['gmp.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,13 +29,17 @@ trait libjxl
|
||||
);
|
||||
|
||||
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
||||
$cmake->addConfigureArgs(
|
||||
'-DCXX_MAVX512F_SUPPORTED:BOOL=FALSE',
|
||||
'-DCXX_MAVX512DQ_SUPPORTED:BOOL=FALSE',
|
||||
'-DCXX_MAVX512CD_SUPPORTED:BOOL=FALSE',
|
||||
'-DCXX_MAVX512BW_SUPPORTED:BOOL=FALSE',
|
||||
'-DCXX_MAVX512VL_SUPPORTED:BOOL=FALSE'
|
||||
);
|
||||
$cflags = getenv('SPC_DEFAULT_C_FLAGS') ?: getenv('CFLAGS') ?: '';
|
||||
$has_avx512 = str_contains($cflags, '-mavx512') || str_contains($cflags, '-march=x86-64-v4');
|
||||
if (!$has_avx512) {
|
||||
$cmake->addConfigureArgs(
|
||||
'-DCXX_MAVX512F_SUPPORTED:BOOL=FALSE',
|
||||
'-DCXX_MAVX512DQ_SUPPORTED:BOOL=FALSE',
|
||||
'-DCXX_MAVX512CD_SUPPORTED:BOOL=FALSE',
|
||||
'-DCXX_MAVX512BW_SUPPORTED:BOOL=FALSE',
|
||||
'-DCXX_MAVX512VL_SUPPORTED:BOOL=FALSE'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$cmake->build();
|
||||
|
||||
@ -5,13 +5,26 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\util\executor\UnixCMakeExecutor;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
trait libwebp
|
||||
{
|
||||
protected function build(): void
|
||||
{
|
||||
UnixCMakeExecutor::create($this)
|
||||
->addConfigureArgs('-DWEBP_BUILD_EXTRAS=ON')
|
||||
->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',
|
||||
SPCTarget::getLibcVersion() === '2.31' && GNU_ARCH === 'x86_64' ? '-DWEBP_ENABLE_SIMD=OFF' : '' // fix an edge bug for debian 11 with gcc 10
|
||||
)
|
||||
->build();
|
||||
// patch pkgconfig
|
||||
$this->patchPkgconfPrefix(patch_option: PKGCONF_PATCH_PREFIX | PKGCONF_PATCH_LIBDIR);
|
||||
|
||||
@ -16,6 +16,7 @@ trait ncurses
|
||||
|
||||
UnixAutoconfExecutor::create($this)
|
||||
->appendEnv([
|
||||
'CFLAGS' => '-std=c17',
|
||||
'LDFLAGS' => SPCTarget::isStatic() ? '-static' : '',
|
||||
])
|
||||
->configure(
|
||||
|
||||
@ -572,6 +572,44 @@ class FileSystem
|
||||
return file_put_contents($file, implode('', $lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Move file or directory, handling cross-device scenarios
|
||||
* Uses rename() if possible, falls back to copy+delete for cross-device moves
|
||||
*
|
||||
* @param string $source Source path
|
||||
* @param string $dest Destination path
|
||||
*/
|
||||
public static function moveFileOrDir(string $source, string $dest): void
|
||||
{
|
||||
$source = self::convertPath($source);
|
||||
$dest = self::convertPath($dest);
|
||||
|
||||
// Check if source and dest are on the same device to avoid cross-device rename errors
|
||||
$source_stat = @stat($source);
|
||||
$dest_parent = dirname($dest);
|
||||
$dest_stat = @stat($dest_parent);
|
||||
|
||||
// Only use rename if on same device
|
||||
if ($source_stat !== false && $dest_stat !== false && $source_stat['dev'] === $dest_stat['dev']) {
|
||||
if (@rename($source, $dest)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to copy + delete for cross-device moves or if rename failed
|
||||
if (is_dir($source)) {
|
||||
self::copyDir($source, $dest);
|
||||
self::removeDir($source);
|
||||
} else {
|
||||
if (!copy($source, $dest)) {
|
||||
throw new FileSystemException("Failed to copy file from {$source} to {$dest}");
|
||||
}
|
||||
if (!unlink($source)) {
|
||||
throw new FileSystemException("Failed to remove source file: {$source}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function extractArchive(string $filename, string $target): void
|
||||
{
|
||||
// Create base dir
|
||||
@ -648,44 +686,6 @@ class FileSystem
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Move file or directory, handling cross-device scenarios
|
||||
* Uses rename() if possible, falls back to copy+delete for cross-device moves
|
||||
*
|
||||
* @param string $source Source path
|
||||
* @param string $dest Destination path
|
||||
*/
|
||||
private static function moveFileOrDir(string $source, string $dest): void
|
||||
{
|
||||
$source = self::convertPath($source);
|
||||
$dest = self::convertPath($dest);
|
||||
|
||||
// Check if source and dest are on the same device to avoid cross-device rename errors
|
||||
$source_stat = @stat($source);
|
||||
$dest_parent = dirname($dest);
|
||||
$dest_stat = @stat($dest_parent);
|
||||
|
||||
// Only use rename if on same device
|
||||
if ($source_stat !== false && $dest_stat !== false && $source_stat['dev'] === $dest_stat['dev']) {
|
||||
if (@rename($source, $dest)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to copy + delete for cross-device moves or if rename failed
|
||||
if (is_dir($source)) {
|
||||
self::copyDir($source, $dest);
|
||||
self::removeDir($source);
|
||||
} else {
|
||||
if (!copy($source, $dest)) {
|
||||
throw new FileSystemException("Failed to copy file from {$source} to {$dest}");
|
||||
}
|
||||
if (!unlink($source)) {
|
||||
throw new FileSystemException("Failed to remove source file: {$source}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unzip file with stripping top-level directory
|
||||
*/
|
||||
|
||||
@ -25,6 +25,7 @@ class SourcePatcher
|
||||
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchFfiCentos7FixO3strncmp']);
|
||||
FileSystem::addSourceExtractHook('sqlsrv', [__CLASS__, 'patchSQLSRVWin32']);
|
||||
FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVWin32']);
|
||||
FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVPhp85']);
|
||||
FileSystem::addSourceExtractHook('yaml', [__CLASS__, 'patchYamlWin32']);
|
||||
FileSystem::addSourceExtractHook('libyaml', [__CLASS__, 'patchLibYaml']);
|
||||
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchImapLicense']);
|
||||
@ -432,6 +433,23 @@ class SourcePatcher
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the compilation issue of pdo_sqlsrv with php 8.5
|
||||
*/
|
||||
public static function patchSQLSRVPhp85(): bool
|
||||
{
|
||||
$source_dir = SOURCE_PATH . '/php-src/ext/pdo_sqlsrv';
|
||||
if (!file_exists($source_dir . '/config.m4') && is_dir($source_dir . '/source/pdo_sqlsrv')) {
|
||||
FileSystem::moveFileOrDir($source_dir . '/LICENSE', $source_dir . '/source/pdo_sqlsrv/LICENSE');
|
||||
FileSystem::moveFileOrDir($source_dir . '/source/shared', $source_dir . '/source/pdo_sqlsrv/shared');
|
||||
FileSystem::moveFileOrDir($source_dir . '/source/pdo_sqlsrv', SOURCE_PATH . '/pdo_sqlsrv');
|
||||
FileSystem::removeDir($source_dir);
|
||||
FileSystem::moveFileOrDir(SOURCE_PATH . '/pdo_sqlsrv', $source_dir);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function patchYamlWin32(): bool
|
||||
{
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/yaml/config.w32', "lib.substr(lib.length - 6, 6) == '_a.lib'", "lib.substr(lib.length - 6, 6) == '_a.lib' || 'yes' == 'yes'");
|
||||
|
||||
@ -48,10 +48,10 @@ class GoXcaddy extends CustomPackage
|
||||
'macos' => 'darwin',
|
||||
default => throw new \InvalidArgumentException('Unsupported OS: ' . $name),
|
||||
};
|
||||
$go_version = '1.25.0';
|
||||
[$go_version] = explode("\n", Downloader::curlExec('https://go.dev/VERSION?m=text'));
|
||||
$config = [
|
||||
'type' => 'url',
|
||||
'url' => "https://go.dev/dl/go{$go_version}.{$os}-{$arch}.tar.gz",
|
||||
'url' => "https://go.dev/dl/{$go_version}.{$os}-{$arch}.tar.gz",
|
||||
];
|
||||
Downloader::downloadPackage($name, $config, $force);
|
||||
}
|
||||
|
||||
@ -50,14 +50,14 @@ $prefer_pre_built = false;
|
||||
|
||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||
$extensions = match (PHP_OS_FAMILY) {
|
||||
'Linux', 'Darwin' => 'bcmath',
|
||||
'Linux', 'Darwin' => 'bcmath,xsl,xml',
|
||||
'Windows' => 'bcmath',
|
||||
};
|
||||
|
||||
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
|
||||
$shared_extensions = match (PHP_OS_FAMILY) {
|
||||
'Linux' => 'pcov',
|
||||
'Darwin' => 'pcov',
|
||||
'Linux' => '',
|
||||
'Darwin' => '',
|
||||
'Windows' => '',
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user