Add native QUIC realtime transport for Unity
This commit is contained in:
parent
1742473845
commit
1d126f4a35
37 changed files with 1150 additions and 86 deletions
54
scripts/build-quic-native.ps1
Normal file
54
scripts/build-quic-native.ps1
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
param(
|
||||
[string] $Configuration = "Release",
|
||||
[string] $Architecture = "x64",
|
||||
[string] $OutputDirectory = "artifacts\quic-native"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ($Architecture -ne "x64") {
|
||||
throw "The first CultMesh native QUIC package supports x64 Windows desktop only."
|
||||
}
|
||||
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$version = "2.5.9"
|
||||
$expectedPackageSha256 = "9877A919E1AA73AA4800F1E8A06B6539021F376228910138EB04540CD956617B"
|
||||
$cacheRoot = Join-Path $repoRoot "artifacts\dependencies\msquic-schannel-$version"
|
||||
$packagePath = Join-Path $cacheRoot "Microsoft.Native.Quic.MsQuic.Schannel.$version.zip"
|
||||
$extractRoot = Join-Path $cacheRoot "package"
|
||||
$nativeRoot = Join-Path $extractRoot "build\native"
|
||||
$buildRoot = Join-Path $repoRoot "artifacts\quic-native-build\$Architecture\$Configuration"
|
||||
$outputRoot = if ([IO.Path]::IsPathRooted($OutputDirectory)) {
|
||||
$OutputDirectory
|
||||
} else {
|
||||
Join-Path $repoRoot $OutputDirectory
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $cacheRoot | Out-Null
|
||||
if (-not (Test-Path -LiteralPath $packagePath)) {
|
||||
& curl.exe -L --fail --silent --show-error `
|
||||
-o $packagePath `
|
||||
"https://www.nuget.org/api/v2/package/Microsoft.Native.Quic.MsQuic.Schannel/$version"
|
||||
if ($LASTEXITCODE -ne 0) { throw "MsQuic package download failed with exit code $LASTEXITCODE" }
|
||||
}
|
||||
if ((Get-FileHash -LiteralPath $packagePath -Algorithm SHA256).Hash -ne $expectedPackageSha256) {
|
||||
throw "MsQuic package digest does not match the pinned release."
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath (Join-Path $nativeRoot "include\msquic.h"))) {
|
||||
if (Test-Path -LiteralPath $extractRoot) { Remove-Item -LiteralPath $extractRoot -Recurse -Force }
|
||||
Expand-Archive -LiteralPath $packagePath -DestinationPath $extractRoot
|
||||
}
|
||||
|
||||
cmake -S (Join-Path $repoRoot "native\GameCult.Mesh.Quic.Native") -B $buildRoot -A x64 `
|
||||
"-DMSQUIC_ROOT=$($nativeRoot.Replace('\', '/'))"
|
||||
if ($LASTEXITCODE -ne 0) { throw "CultMesh native QUIC configure failed with exit code $LASTEXITCODE" }
|
||||
cmake --build $buildRoot --config $Configuration
|
||||
if ($LASTEXITCODE -ne 0) { throw "CultMesh native QUIC build failed with exit code $LASTEXITCODE" }
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $outputRoot | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $buildRoot "bin\$Configuration\gamecult_mesh_quic_native.dll") `
|
||||
-Destination $outputRoot -Force
|
||||
Copy-Item -LiteralPath (Join-Path $nativeRoot "bin\x64\msquic.dll") -Destination $outputRoot -Force
|
||||
Copy-Item -LiteralPath (Join-Path $extractRoot "LICENSE") -Destination (Join-Path $outputRoot "MSQUIC-LICENSE.txt") -Force
|
||||
|
||||
Write-Host "CultMesh native QUIC runtime: $outputRoot"
|
||||
Get-ChildItem -LiteralPath $outputRoot -File | Select-Object Name,Length
|
||||
|
|
@ -8,8 +8,11 @@ $ErrorActionPreference = "Stop"
|
|||
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$projectPath = Join-Path $repoRoot "src\GameCult.Mesh\GameCult.Mesh.csproj"
|
||||
$quicProjectPath = Join-Path $repoRoot "src\GameCult.Mesh.Quic.Native\GameCult.Mesh.Quic.Native.csproj"
|
||||
$templateRoot = Join-Path $repoRoot "unity\org.gamecult.cultlib"
|
||||
$publishRoot = Join-Path $repoRoot "artifacts\unity-publish"
|
||||
$quicPublishRoot = Join-Path $repoRoot "artifacts\unity-quic-publish"
|
||||
$quicNativeRoot = Join-Path $repoRoot "artifacts\unity-quic-native"
|
||||
$outputRoot = if ([System.IO.Path]::IsPathRooted($OutputDirectory)) {
|
||||
$OutputDirectory
|
||||
} else {
|
||||
|
|
@ -20,6 +23,9 @@ $pluginRoot = Join-Path $outputRoot "Runtime\Plugins"
|
|||
if (Test-Path -LiteralPath $publishRoot) {
|
||||
Remove-Item -LiteralPath $publishRoot -Recurse -Force
|
||||
}
|
||||
if (Test-Path -LiteralPath $quicPublishRoot) {
|
||||
Remove-Item -LiteralPath $quicPublishRoot -Recurse -Force
|
||||
}
|
||||
if (Test-Path -LiteralPath $outputRoot) {
|
||||
Remove-Item -LiteralPath $outputRoot -Recurse -Force
|
||||
}
|
||||
|
|
@ -28,6 +34,13 @@ dotnet publish $projectPath -c $Configuration -o $publishRoot
|
|||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "CultLib publish failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
dotnet publish $quicProjectPath -c $Configuration -o $quicPublishRoot
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "CultLib native QUIC managed publish failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
& (Join-Path $PSScriptRoot "build-quic-native.ps1") `
|
||||
-Configuration $Configuration `
|
||||
-OutputDirectory $quicNativeRoot
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $pluginRoot | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $templateRoot "package.json") -Destination $outputRoot
|
||||
|
|
@ -39,6 +52,7 @@ $expectedAssemblies = @(
|
|||
"GameCult.Caching.MessagePack.dll",
|
||||
"GameCult.Logging.dll",
|
||||
"GameCult.Mesh.dll",
|
||||
"GameCult.Mesh.Quic.Native.dll",
|
||||
"GameCult.Networking.dll",
|
||||
"Isopoh.Cryptography.Argon2.dll",
|
||||
"Isopoh.Cryptography.Blake2b.dll",
|
||||
|
|
@ -62,6 +76,9 @@ $publishedByName = @{}
|
|||
foreach ($assembly in Get-ChildItem -LiteralPath $publishRoot -Filter "*.dll") {
|
||||
$publishedByName[$assembly.Name] = $assembly
|
||||
}
|
||||
foreach ($assembly in Get-ChildItem -LiteralPath $quicPublishRoot -Filter "*.dll") {
|
||||
$publishedByName[$assembly.Name] = $assembly
|
||||
}
|
||||
foreach ($assemblyName in $expectedAssemblies) {
|
||||
if (-not $publishedByName.ContainsKey($assemblyName)) {
|
||||
throw "CultLib Unity package is missing expected assembly: $assemblyName"
|
||||
|
|
@ -78,6 +95,13 @@ foreach ($assemblyName in $expectedAssemblies) {
|
|||
Copy-Item -LiteralPath $pdb -Destination $pluginRoot
|
||||
}
|
||||
}
|
||||
$nativePluginRoot = Join-Path $pluginRoot "x86_64"
|
||||
New-Item -ItemType Directory -Force -Path $nativePluginRoot | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $quicNativeRoot "gamecult_mesh_quic_native.dll") -Destination $nativePluginRoot
|
||||
Copy-Item -LiteralPath (Join-Path $quicNativeRoot "msquic.dll") -Destination $nativePluginRoot
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $outputRoot "Third Party Notices") | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $quicNativeRoot "MSQUIC-LICENSE.txt") `
|
||||
-Destination (Join-Path $outputRoot "Third Party Notices\MSQUIC-LICENSE.txt")
|
||||
|
||||
if ($UpdateTemplate) {
|
||||
$templatePluginRoot = Join-Path $templateRoot "Runtime\Plugins"
|
||||
|
|
@ -89,6 +113,16 @@ if ($UpdateTemplate) {
|
|||
Copy-Item -LiteralPath $pdb -Destination $templatePluginRoot -Force
|
||||
}
|
||||
}
|
||||
$templateNativePluginRoot = Join-Path $templatePluginRoot "x86_64"
|
||||
New-Item -ItemType Directory -Force -Path $templateNativePluginRoot | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $nativePluginRoot "gamecult_mesh_quic_native.dll") `
|
||||
-Destination $templateNativePluginRoot -Force
|
||||
Copy-Item -LiteralPath (Join-Path $nativePluginRoot "msquic.dll") `
|
||||
-Destination $templateNativePluginRoot -Force
|
||||
$templateNoticesRoot = Join-Path $templateRoot "Third Party Notices"
|
||||
New-Item -ItemType Directory -Force -Path $templateNoticesRoot | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $outputRoot "Third Party Notices\MSQUIC-LICENSE.txt") `
|
||||
-Destination $templateNoticesRoot -Force
|
||||
Write-Host "Updated tracked Unity package assemblies: $templatePluginRoot"
|
||||
}
|
||||
|
||||
|
|
@ -96,3 +130,4 @@ $manifest = Get-Content -LiteralPath (Join-Path $outputRoot "package.json") -Raw
|
|||
Write-Host "CultLib Unity package: $outputRoot"
|
||||
Write-Host "Package: $($manifest.name)@$($manifest.version)"
|
||||
Write-Host "Managed assemblies: $($expectedAssemblies.Count)"
|
||||
Write-Host "Native realtime: MsQuic Schannel 2.5.9 (Windows x64)"
|
||||
|
|
|
|||
Loading…
Reference in a new issue