Add pdo_sqlsrv, libyaml patches from v2

This commit is contained in:
crazywhalecc
2026-04-08 14:49:38 +08:00
parent a3624b1510
commit ad631f9b6e
3 changed files with 69 additions and 4 deletions

View File

@@ -12,10 +12,8 @@ ext-calendar:
ext-com_dotnet:
type: php-extension
php-extension:
support:
Linux: 'no'
Darwin: 'no'
BSD: 'no'
os:
- Windows
arg-type@windows: '--enable-com-dotnet=yes'
ext-ctype:
type: php-extension

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Util\FileSystem;
#[Extension('pdo_sqlsrv')]
class pdo_sqlsrv
{
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-pdo_sqlsrv')]
#[PatchDescription('Remove /sdl flag from pdo_sqlsrv config.w32 to prevent strict SDL check compilation failures')]
public function patchBeforeBuildconfForWindows(): void
{
// Fix the compilation issue of pdo_sqlsrv on Windows (/sdl check is too strict and will cause Zend compilation to fail)
if (file_exists(SOURCE_PATH . '/php-src/ext/pdo_sqlsrv/config.w32')) {
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/pdo_sqlsrv/config.w32', '/sdl', '');
}
}
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-pdo_sqlsrv')]
#[PatchDescription('Fix pdo_sqlsrv directory structure for PHP 8.5+ (source layout changed)')]
public function patchDirectoryStructureForPhp85(): void
{
$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);
}
}
}

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Util\FileSystem;
#[Extension('yaml')]
class yaml
{
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-yaml')]
#[PatchDescription('Fix yaml config.w32 to always link against static libyaml on Windows')]
public function patchBeforeBuildconfForWindows(): void
{
// Force static libyaml linkage: config.w32 normally only picks libs ending in '_a.lib',
// but libyaml may not follow that naming convention, so we add 'yes' == 'yes' to always match.
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'"
);
}
}