Merge CultMesh reliability into Geometry Unity release
This commit is contained in:
commit
e3e1ac0420
152 changed files with 26486 additions and 753 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
|
||||
|
|
@ -1,14 +1,18 @@
|
|||
param(
|
||||
[string] $Configuration = "Release",
|
||||
[string] $OutputDirectory = "artifacts\unity\org.gamecult.cultlib"
|
||||
[string] $OutputDirectory = "artifacts\unity\org.gamecult.cultlib",
|
||||
[switch] $UpdateTemplate
|
||||
)
|
||||
|
||||
$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 {
|
||||
|
|
@ -23,6 +27,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",
|
||||
|
|
@ -47,6 +52,7 @@ $ownedAssemblies = @(
|
|||
"GameCult.Caching.MessagePack.dll",
|
||||
"GameCult.Logging.dll",
|
||||
"GameCult.Mesh.dll",
|
||||
"GameCult.Mesh.Quic.Native.dll",
|
||||
"GameCult.Networking.dll"
|
||||
)
|
||||
$expectedPdbs = $ownedAssemblies | ForEach-Object { [System.IO.Path]::ChangeExtension($_, ".pdb") }
|
||||
|
|
@ -94,6 +100,9 @@ Assert-SameNames $asmdef.precompiledReferences $expectedAssemblies "asmdef preco
|
|||
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
|
||||
}
|
||||
|
|
@ -103,11 +112,22 @@ dotnet publish $projectPath -c $Configuration -o $publishRoot --disable-build-se
|
|||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "CultLib publish failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
dotnet publish $quicProjectPath -c $Configuration -o $quicPublishRoot --disable-build-servers `
|
||||
-p:UseSharedCompilation=false -m:1 -p:Version=$($manifest.version)
|
||||
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
|
||||
|
||||
$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"
|
||||
|
|
@ -119,13 +139,22 @@ foreach ($assemblyName in $expectedAssemblies) {
|
|||
Copy-Item -LiteralPath $publishedByName[$assemblyName].FullName -Destination $pluginRoot -Force
|
||||
}
|
||||
foreach ($pdbName in $expectedPdbs) {
|
||||
$pdbPath = Join-Path $publishRoot $pdbName
|
||||
$pdbPath = @($publishRoot, $quicPublishRoot) |
|
||||
ForEach-Object { Join-Path $_ $pdbName } |
|
||||
Where-Object { Test-Path -LiteralPath $_ } |
|
||||
Select-Object -First 1
|
||||
if (-not (Test-Path -LiteralPath $pdbPath)) {
|
||||
throw "CultLib Unity package is missing expected symbols: $pdbName"
|
||||
}
|
||||
Copy-Item -LiteralPath $pdbPath -Destination $pluginRoot -Force
|
||||
}
|
||||
|
||||
$nativePluginRoot = Join-Path $pluginRoot "x86_64"
|
||||
Copy-Item -LiteralPath (Join-Path $quicNativeRoot "gamecult_mesh_quic_native.dll") -Destination $nativePluginRoot -Force
|
||||
Copy-Item -LiteralPath (Join-Path $quicNativeRoot "msquic.dll") -Destination $nativePluginRoot -Force
|
||||
Copy-Item -LiteralPath (Join-Path $quicNativeRoot "MSQUIC-LICENSE.txt") `
|
||||
-Destination (Join-Path $outputRoot "Third Party Notices\MSQUIC-LICENSE.txt") -Force
|
||||
|
||||
Assert-SameNames `
|
||||
(Get-ChildItem -LiteralPath $pluginRoot -Filter "*.dll" | Select-Object -ExpandProperty Name) `
|
||||
$expectedAssemblies `
|
||||
|
|
@ -142,7 +171,7 @@ foreach ($assemblyName in $ownedAssemblies) {
|
|||
if ($fileVersion -ne $expectedFileVersion) {
|
||||
throw "$assemblyName has file version $fileVersion; expected $expectedFileVersion."
|
||||
}
|
||||
$freshHash = (Get-FileHash -LiteralPath (Join-Path $publishRoot $assemblyName) -Algorithm SHA256).Hash
|
||||
$freshHash = (Get-FileHash -LiteralPath $publishedByName[$assemblyName].FullName -Algorithm SHA256).Hash
|
||||
$stagedHash = (Get-FileHash -LiteralPath $assemblyPath -Algorithm SHA256).Hash
|
||||
if ($freshHash -ne $stagedHash) {
|
||||
throw "$assemblyName differs between the fresh publish and staged package."
|
||||
|
|
@ -155,9 +184,29 @@ $resolverAssemblyMetadata = [System.Text.Encoding]::UTF8.GetString(
|
|||
if (-not $resolverAssemblyMetadata.Contains("CultDocumentMessagePackResolversAttribute")) {
|
||||
throw "GameCult.Caching.MessagePack.dll lacks CultDocumentMessagePackResolversAttribute."
|
||||
}
|
||||
$meshAssemblyMetadata = [System.Text.Encoding]::UTF8.GetString(
|
||||
[System.IO.File]::ReadAllBytes((Join-Path $pluginRoot "GameCult.Mesh.dll")))
|
||||
if (-not $meshAssemblyMetadata.Contains("ICultMeshBodyReadLease")) {
|
||||
throw "GameCult.Mesh.dll lacks ICultMeshBodyReadLease."
|
||||
}
|
||||
|
||||
if ($UpdateTemplate) {
|
||||
foreach ($name in $expectedAssemblies + $expectedPdbs) {
|
||||
Copy-Item -LiteralPath (Join-Path $pluginRoot $name) -Destination $templatePluginRoot -Force
|
||||
}
|
||||
Copy-Item -LiteralPath (Join-Path $nativePluginRoot "gamecult_mesh_quic_native.dll") `
|
||||
-Destination (Join-Path $templatePluginRoot "x86_64") -Force
|
||||
Copy-Item -LiteralPath (Join-Path $nativePluginRoot "msquic.dll") `
|
||||
-Destination (Join-Path $templatePluginRoot "x86_64") -Force
|
||||
Copy-Item -LiteralPath (Join-Path $outputRoot "Third Party Notices\MSQUIC-LICENSE.txt") `
|
||||
-Destination (Join-Path $templateRoot "Third Party Notices") -Force
|
||||
Write-Host "Updated tracked Unity package assemblies: $templatePluginRoot"
|
||||
}
|
||||
|
||||
Write-Host "CultLib Unity package: $outputRoot"
|
||||
Write-Host "Package: $($manifest.name)@$($manifest.version)"
|
||||
Write-Host "Managed assemblies: $($expectedAssemblies.Count)"
|
||||
Write-Host "Verified owned assembly version: $expectedFileVersion"
|
||||
Write-Host "Verified Stage 1 MessagePack resolver attribute."
|
||||
Write-Host "Verified ICultMeshBodyReadLease."
|
||||
Write-Host "Native realtime: MsQuic Schannel 2.5.9 (Windows x64)"
|
||||
|
|
|
|||
30
scripts/run-typescript-workspaces.mjs
Normal file
30
scripts/run-typescript-workspaces.mjs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { execFileSync } from "node:child_process";
|
||||
import { dirname, join } from "node:path";
|
||||
|
||||
const command = process.argv[2];
|
||||
if (!command) throw new Error("Usage: node scripts/run-typescript-workspaces.mjs <script>");
|
||||
|
||||
const npmCli = process.env.npm_execpath ??
|
||||
join(dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js");
|
||||
const workspaces = ["cultcache-ts", "cultnet-ts", "cultmesh-ts"];
|
||||
const childEnv = process.platform === "win32"
|
||||
? {
|
||||
...process.env,
|
||||
PATH: [
|
||||
dirname(process.execPath),
|
||||
`${process.env.SystemRoot}\\System32`,
|
||||
process.env.SystemRoot,
|
||||
`${process.env.USERPROFILE}\\AppData\\Local\\Microsoft\\WindowsApps`,
|
||||
`${process.env.USERPROFILE}\\.cargo\\bin`,
|
||||
"C:\\Program Files\\dotnet",
|
||||
"C:\\Program Files\\Git\\cmd",
|
||||
].join(";"),
|
||||
}
|
||||
: process.env;
|
||||
|
||||
for (const workspace of workspaces) {
|
||||
execFileSync(process.execPath, [npmCli, "--workspace", workspace, "run", command], {
|
||||
env: childEnv,
|
||||
stdio: "inherit",
|
||||
});
|
||||
}
|
||||
118
scripts/test-typescript-package-closure.mjs
Normal file
118
scripts/test-typescript-package-closure.mjs
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const workspacePackages = ["cultcache-ts", "cultnet-ts", "cultmesh-ts"];
|
||||
const npmCli = process.env.npm_execpath ??
|
||||
join(dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js");
|
||||
const childEnv = process.platform === "win32"
|
||||
? {
|
||||
...process.env,
|
||||
PATH: `${dirname(process.execPath)};${process.env.SystemRoot}\\System32;${process.env.SystemRoot}`,
|
||||
}
|
||||
: process.env;
|
||||
const smokeRoot = mkdtempSync(join(tmpdir(), "cultlib-ts-package-smoke-"));
|
||||
const tarballRoot = join(smokeRoot, "tarballs");
|
||||
const consumerRoot = join(smokeRoot, "consumer");
|
||||
mkdirSync(tarballRoot);
|
||||
mkdirSync(consumerRoot);
|
||||
|
||||
function npm(...args) {
|
||||
return execFileSync(process.execPath, [npmCli, ...args], {
|
||||
cwd: repoRoot,
|
||||
encoding: "utf8",
|
||||
env: childEnv,
|
||||
stdio: ["ignore", "pipe", "inherit"],
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const tarballs = [];
|
||||
for (const packageName of workspacePackages) {
|
||||
const packageRoot = join(repoRoot, "packages", packageName);
|
||||
const packed = JSON.parse(npm("pack", packageRoot, "--json", "--pack-destination", tarballRoot));
|
||||
assert.equal(packed.length, 1, `${packageName} must produce exactly one tarball`);
|
||||
const files = packed[0].files.map(file => file.path);
|
||||
assert.ok(files.includes("dist/index.js"), `${packageName} tarball is missing dist/index.js`);
|
||||
assert.ok(files.includes("dist/index.d.ts"), `${packageName} tarball is missing dist/index.d.ts`);
|
||||
tarballs.push(join(tarballRoot, packed[0].filename));
|
||||
}
|
||||
|
||||
writeFileSync(join(consumerRoot, "package.json"), JSON.stringify({
|
||||
name: "cultlib-ts-package-smoke",
|
||||
version: "1.0.0",
|
||||
private: true,
|
||||
}, null, 2));
|
||||
|
||||
execFileSync(process.execPath, [npmCli,
|
||||
"install",
|
||||
"--ignore-scripts",
|
||||
"--no-audit",
|
||||
"--no-fund",
|
||||
...tarballs,
|
||||
], { cwd: consumerRoot, env: childEnv, stdio: "inherit" });
|
||||
|
||||
writeFileSync(join(consumerRoot, "runtime-smoke.cjs"), `
|
||||
const assert = require("node:assert/strict");
|
||||
const cache = require("cultcache-ts");
|
||||
const net = require("cultnet-ts");
|
||||
const mesh = require("cultmesh-ts");
|
||||
assert.equal(typeof cache.defineDocumentType, "function");
|
||||
assert.equal(typeof net.CultNetPeer, "function");
|
||||
assert.equal(typeof mesh.CultMesh, "function");
|
||||
assert.equal(typeof mesh.CultMeshProviderSession, "function");
|
||||
assert.deepEqual(mesh.CultMesh.vec2(3, 4), { x: 3, y: 4 });
|
||||
`);
|
||||
execFileSync(process.execPath, ["runtime-smoke.cjs"], { cwd: consumerRoot, stdio: "inherit" });
|
||||
|
||||
writeFileSync(join(consumerRoot, "types-smoke.ts"), `
|
||||
import { defineDocumentType } from "cultcache-ts";
|
||||
import { CultNetPeer } from "cultnet-ts";
|
||||
import {
|
||||
CultMesh,
|
||||
CultMeshProviderSession,
|
||||
type CultMeshProviderIdentity,
|
||||
type CultMeshProviderTransport,
|
||||
type CultMeshVec2,
|
||||
} from "cultmesh-ts";
|
||||
|
||||
const point: CultMeshVec2 = CultMesh.vec2(3, 4);
|
||||
const defineDocument: typeof defineDocumentType = defineDocumentType;
|
||||
const peerType: typeof CultNetPeer = CultNetPeer;
|
||||
const providerSessionType: typeof CultMeshProviderSession = CultMeshProviderSession;
|
||||
const providerIdentity: CultMeshProviderIdentity = {
|
||||
providerId: "smoke.provider",
|
||||
serviceInstanceId: "smoke.instance",
|
||||
endpointId: "odin:smoke.instance",
|
||||
verseId: "smoke",
|
||||
};
|
||||
let providerTransport: CultMeshProviderTransport | undefined;
|
||||
void point;
|
||||
void defineDocument;
|
||||
void peerType;
|
||||
void providerSessionType;
|
||||
void providerIdentity;
|
||||
void providerTransport;
|
||||
`);
|
||||
const tsc = join(repoRoot, "node_modules", "typescript", "bin", "tsc");
|
||||
assert.ok(readFileSync(tsc, "utf8").length > 0, "workspace TypeScript compiler is unavailable");
|
||||
execFileSync(process.execPath, [
|
||||
tsc,
|
||||
"--noEmit",
|
||||
"--strict",
|
||||
"--target", "ES2022",
|
||||
"--module", "CommonJS",
|
||||
"--moduleResolution", "Node",
|
||||
"--skipLibCheck",
|
||||
"types-smoke.ts",
|
||||
], { cwd: consumerRoot, stdio: "inherit" });
|
||||
|
||||
console.log("TypeScript package closure smoke: passed");
|
||||
for (const tarball of tarballs) console.log(`Packed: ${tarball}`);
|
||||
} finally {
|
||||
rmSync(smokeRoot, { recursive: true, force: true });
|
||||
}
|
||||
Loading…
Reference in a new issue