Skip to content

Commit a3624b1

Browse files
committed
Forward-port #1078, add sqlsrv and pdo_sqlsrv extension support for win
1 parent 2a80d5a commit a3624b1

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/Package/Extension/sqlsrv.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\Package\PackageInstaller;
12+
use StaticPHP\Package\PhpExtensionPackage;
13+
14+
#[Extension('sqlsrv')]
15+
class sqlsrv extends PhpExtensionPackage
16+
{
17+
#[BeforeStage('php', [php::class, 'makeForWindows'], 'ext-sqlsrv')]
18+
#[PatchDescription('Fix sqlsrv Makefile: remove /W4 and /WX flags to prevent build errors on Windows')]
19+
public function patchBeforeMake(PackageInstaller $installer): bool
20+
{
21+
$makefile = $installer->getTargetPackage('php')->getSourceDir() . '\Makefile';
22+
$makeContent = file_get_contents($makefile);
23+
$makeContent = preg_replace('/^(CFLAGS_(?:PDO_)?SQLSRV=.*?)\s+\/W4\b/m', '$1', $makeContent);
24+
$makeContent = preg_replace('/^(CFLAGS_(?:PDO_)?SQLSRV=.*?)\s+\/WX\b/m', '$1', $makeContent);
25+
file_put_contents($makefile, $makeContent);
26+
return true;
27+
}
28+
}

src/StaticPHP/Util/FileSystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static function copyDir(string $from, string $to): void
120120
$src_path = FileSystem::convertPath($from);
121121
switch (PHP_OS_FAMILY) {
122122
case 'Windows':
123-
cmd(false)->exec('xcopy "' . $src_path . '" "' . $dst_path . '" /s/e/v/y/i');
123+
cmd(false)->exec('xcopy "' . $src_path . '" "' . $dst_path . '" /s/e/y/i');
124124
break;
125125
case 'Linux':
126126
case 'Darwin':

0 commit comments

Comments
 (0)