Add ext-uv and libuv support on Windows

This commit is contained in:
crazywhalecc
2026-04-10 16:15:07 +08:00
parent db8520d8f0
commit 6ef012e204
3 changed files with 26 additions and 0 deletions

View File

@@ -9,3 +9,5 @@ libuv:
license: MIT
static-libs@unix:
- libuv.a
static-libs@windows:
- libuv.lib

View File

@@ -24,6 +24,21 @@ class uv extends PhpExtensionPackage
}
}
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-uv')]
public function patchBeforeBuild(): void
{
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/php_uv.c",
'#if !defined(PHP_WIN32) || defined(HAVE_SOCKET)',
'#if !defined(PHP_WIN32) || (defined(HAVE_SOCKETS) && !defined(COMPILE_DL_SOCKETS))',
);
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/config.w32",
'CHECK_LIB("Ws2_32.lib","uv", PHP_UV);',
"CHECK_LIB(\"Ws2_32.lib\",\"uv\" , PHP_UV);\n\tCHECK_LIB(\"dbghelp.lib\",\"uv\", PHP_UV);",
);
}
#[BeforeStage('ext-uv', [PhpExtensionPackage::class, 'makeForUnix'])]
public function patchBeforeSharedMake(PhpExtensionPackage $pkg): bool
{

View File

@@ -8,6 +8,7 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
#[Library('libuv')]
class libuv
@@ -22,4 +23,12 @@ class libuv
// patch pkgconfig
$lib->patchPkgconfPrefix(['libuv-static.pc']);
}
#[BuildFor('Windows')]
public function buildWindows(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->addConfigureArgs('-DLIBUV_BUILD_SHARED=OFF')
->build();
}
}