Skip to content

Commit ad631f9

Browse files
committed
Add pdo_sqlsrv, libyaml patches from v2
1 parent a3624b1 commit ad631f9

3 files changed

Lines changed: 69 additions & 4 deletions

File tree

config/pkg/ext/builtin-extensions.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ ext-calendar:
1212
ext-com_dotnet:
1313
type: php-extension
1414
php-extension:
15-
support:
16-
Linux: 'no'
17-
Darwin: 'no'
18-
BSD: 'no'
15+
os:
16+
- Windows
1917
arg-type@windows: '--enable-com-dotnet=yes'
2018
ext-ctype:
2119
type: php-extension
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Package\Extension;
6+
7+
use Package\Target\php;
8+
use StaticPHP\Attribute\Package\BeforeStage;
9+
use StaticPHP\Attribute\Package\Extension;
10+
use StaticPHP\Attribute\PatchDescription;
11+
use StaticPHP\Util\FileSystem;
12+
13+
#[Extension('pdo_sqlsrv')]
14+
class pdo_sqlsrv
15+
{
16+
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-pdo_sqlsrv')]
17+
#[PatchDescription('Remove /sdl flag from pdo_sqlsrv config.w32 to prevent strict SDL check compilation failures')]
18+
public function patchBeforeBuildconfForWindows(): void
19+
{
20+
// Fix the compilation issue of pdo_sqlsrv on Windows (/sdl check is too strict and will cause Zend compilation to fail)
21+
if (file_exists(SOURCE_PATH . '/php-src/ext/pdo_sqlsrv/config.w32')) {
22+
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/pdo_sqlsrv/config.w32', '/sdl', '');
23+
}
24+
}
25+
26+
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-pdo_sqlsrv')]
27+
#[PatchDescription('Fix pdo_sqlsrv directory structure for PHP 8.5+ (source layout changed)')]
28+
public function patchDirectoryStructureForPhp85(): void
29+
{
30+
$source_dir = SOURCE_PATH . '/php-src/ext/pdo_sqlsrv';
31+
if (!file_exists($source_dir . '/config.m4') && is_dir($source_dir . '/source/pdo_sqlsrv')) {
32+
FileSystem::moveFileOrDir($source_dir . '/LICENSE', $source_dir . '/source/pdo_sqlsrv/LICENSE');
33+
FileSystem::moveFileOrDir($source_dir . '/source/shared', $source_dir . '/source/pdo_sqlsrv/shared');
34+
FileSystem::moveFileOrDir($source_dir . '/source/pdo_sqlsrv', SOURCE_PATH . '/pdo_sqlsrv');
35+
FileSystem::removeDir($source_dir);
36+
FileSystem::moveFileOrDir(SOURCE_PATH . '/pdo_sqlsrv', $source_dir);
37+
}
38+
}
39+
}

src/Package/Extension/yaml.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Package\Extension;
6+
7+
use Package\Target\php;
8+
use StaticPHP\Attribute\Package\BeforeStage;
9+
use StaticPHP\Attribute\Package\Extension;
10+
use StaticPHP\Attribute\PatchDescription;
11+
use StaticPHP\Util\FileSystem;
12+
13+
#[Extension('yaml')]
14+
class yaml
15+
{
16+
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-yaml')]
17+
#[PatchDescription('Fix yaml config.w32 to always link against static libyaml on Windows')]
18+
public function patchBeforeBuildconfForWindows(): void
19+
{
20+
// Force static libyaml linkage: config.w32 normally only picks libs ending in '_a.lib',
21+
// but libyaml may not follow that naming convention, so we add 'yes' == 'yes' to always match.
22+
FileSystem::replaceFileStr(
23+
SOURCE_PATH . '/php-src/ext/yaml/config.w32',
24+
"lib.substr(lib.length - 6, 6) == '_a.lib'",
25+
"lib.substr(lib.length - 6, 6) == '_a.lib' || 'yes' == 'yes'"
26+
);
27+
}
28+
}

0 commit comments

Comments
 (0)