mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 08:15:39 +08:00
Forward-port #1078, add sqlsrv and pdo_sqlsrv extension support for win
This commit is contained in:
28
src/Package/Extension/sqlsrv.php
Normal file
28
src/Package/Extension/sqlsrv.php
Normal 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\Package\PackageInstaller;
|
||||
use StaticPHP\Package\PhpExtensionPackage;
|
||||
|
||||
#[Extension('sqlsrv')]
|
||||
class sqlsrv extends PhpExtensionPackage
|
||||
{
|
||||
#[BeforeStage('php', [php::class, 'makeForWindows'], 'ext-sqlsrv')]
|
||||
#[PatchDescription('Fix sqlsrv Makefile: remove /W4 and /WX flags to prevent build errors on Windows')]
|
||||
public function patchBeforeMake(PackageInstaller $installer): bool
|
||||
{
|
||||
$makefile = $installer->getTargetPackage('php')->getSourceDir() . '\Makefile';
|
||||
$makeContent = file_get_contents($makefile);
|
||||
$makeContent = preg_replace('/^(CFLAGS_(?:PDO_)?SQLSRV=.*?)\s+\/W4\b/m', '$1', $makeContent);
|
||||
$makeContent = preg_replace('/^(CFLAGS_(?:PDO_)?SQLSRV=.*?)\s+\/WX\b/m', '$1', $makeContent);
|
||||
file_put_contents($makefile, $makeContent);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ class FileSystem
|
||||
$src_path = FileSystem::convertPath($from);
|
||||
switch (PHP_OS_FAMILY) {
|
||||
case 'Windows':
|
||||
cmd(false)->exec('xcopy "' . $src_path . '" "' . $dst_path . '" /s/e/v/y/i');
|
||||
cmd(false)->exec('xcopy "' . $src_path . '" "' . $dst_path . '" /s/e/y/i');
|
||||
break;
|
||||
case 'Linux':
|
||||
case 'Darwin':
|
||||
|
||||
Reference in New Issue
Block a user