Initialize generic Eve Flutter runtime

This commit is contained in:
Meta Vens 2026-07-10 09:57:05 +01:00
commit 5998044f2b
108 changed files with 5784 additions and 0 deletions

View file

@ -0,0 +1,80 @@
param(
[string] $FixtureId = "cultui-inspector",
[Parameter(Mandatory = $true)]
[string] $SurfacePath,
[string] $FlutterExe = "E:\Projects\Eve\tools\deps\flutter\bin\flutter.bat",
[string] $OutputPath = "artifacts\parity\android-flutter-cultui-inspector.png",
[int] $Width = 0,
[int] $Height = 0,
[ValidateSet("portrait", "landscape", "natural")]
[string] $Orientation = "natural",
[int] $LaunchDelaySeconds = 4,
[switch] $SkipBuild,
[switch] $ForceInstall
)
$ErrorActionPreference = "Stop"
$projectRoot = Split-Path -Parent $PSScriptRoot
$flutterRoot = $projectRoot
$flutter = $FlutterExe
$flutterSdkRoot = Split-Path -Parent (Split-Path -Parent $flutter)
$assetPath = Join-Path $flutterRoot "assets\current-surface.json"
$fontDir = Join-Path $flutterRoot "assets\fonts"
$apkPath = Join-Path $flutterRoot "build\app\outputs\flutter-apk\app-debug.apk"
if (-not (Test-Path $flutter)) {
throw "Flutter is not installed at $flutter"
}
if (-not $SkipBuild) {
New-Item -ItemType Directory -Force (Split-Path -Parent $assetPath) | Out-Null
New-Item -ItemType Directory -Force $fontDir | Out-Null
Copy-Item -LiteralPath (Join-Path $flutterSdkRoot "bin\cache\artifacts\material_fonts\roboto-regular.ttf") -Destination (Join-Path $fontDir "Roboto-Regular.ttf") -Force
Copy-Item -LiteralPath (Join-Path $flutterSdkRoot "bin\cache\artifacts\material_fonts\roboto-bold.ttf") -Destination (Join-Path $fontDir "Roboto-Bold.ttf") -Force
Copy-Item -LiteralPath $SurfacePath -Destination $assetPath -Force
Push-Location $flutterRoot
try {
& $flutter pub get
if ($LASTEXITCODE -ne 0) {
throw "Flutter pub get failed with exit code $LASTEXITCODE"
}
& $flutter build apk --debug "--dart-define=EVE_PARITY_FIXTURE=$FixtureId"
if ($LASTEXITCODE -ne 0) {
throw "Flutter Android APK build failed with exit code $LASTEXITCODE"
}
} finally {
Pop-Location
}
}
if (-not (Test-Path $apkPath)) {
throw "Flutter Android APK not found: $apkPath"
}
$captureArgs = @(
"-ExecutionPolicy", "Bypass",
"-File", ".\scripts\capture-android-screenshot.ps1",
"-OutputPath", $OutputPath,
"-ApkPath", $apkPath,
"-PackageName", "com.example.eve_parity",
"-ActivityName", ".MainActivity",
"-LaunchDelaySeconds", $LaunchDelaySeconds,
"-Orientation", $Orientation
)
if ($Width -gt 0) {
$captureArgs += @("-Width", $Width)
}
if ($Height -gt 0) {
$captureArgs += @("-Height", $Height)
}
if ($ForceInstall -or -not $SkipBuild) {
$captureArgs += "-ForceInstall"
}
powershell @captureArgs
if ($LASTEXITCODE -ne 0) {
throw "Android Flutter screenshot failed with exit code $LASTEXITCODE"
}

View file

@ -0,0 +1,102 @@
param(
[string] $OutputPath = "artifacts\parity\android-periwinkle.png",
[string] $ApkPath = "artifacts\android\eve-debug.apk",
[string] $PackageName = "org.gamecult.eve",
[string] $ActivityName = ".MainActivity",
[int] $LaunchDelaySeconds = 3,
[int] $Width = 0,
[int] $Height = 0,
[ValidateSet("portrait", "landscape", "natural")]
[string] $Orientation = "natural",
[switch] $UseFixture,
[switch] $ForceInstall
)
$ErrorActionPreference = "Stop"
$projectRoot = Split-Path -Parent $PSScriptRoot
$absoluteOutput = if ([System.IO.Path]::IsPathRooted($OutputPath)) { $OutputPath } else { Join-Path $projectRoot $OutputPath }
$absoluteApk = if ([System.IO.Path]::IsPathRooted($ApkPath)) { $ApkPath } else { Join-Path $projectRoot $ApkPath }
New-Item -ItemType Directory -Force (Split-Path -Parent $absoluteOutput) | Out-Null
$devices = adb devices | Select-String -Pattern "device$"
if (-not $devices) {
throw "No adb device is connected for Android parity capture."
}
if (-not (Test-Path $absoluteApk)) {
throw "Android APK not found: $absoluteApk"
}
$overrideSize = $Width -gt 0 -and $Height -gt 0
$overrideRotation = $Orientation -ne "natural"
$previousWindowUserRotation = $null
$previousIgnoreOrientationRequest = $null
try {
if ($overrideRotation) {
$previousWindowUserRotation = (adb shell cmd window user-rotation).Trim()
$previousIgnoreOrientationRequest = (adb shell cmd window get-ignore-orientation-request).Trim()
$rotation = if ($Orientation -eq "landscape") { "1" } else { "0" }
adb shell cmd window set-ignore-orientation-request true | Out-Host
adb shell cmd window user-rotation lock $rotation | Out-Host
}
if ($overrideSize -or $overrideRotation) {
adb shell am force-stop $PackageName | Out-Host
}
if ($overrideSize) {
$wmWidth = if ($Orientation -eq "landscape") { $Height } else { $Width }
$wmHeight = if ($Orientation -eq "landscape") { $Width } else { $Height }
adb shell wm size "${wmWidth}x${wmHeight}" | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "adb wm size failed with exit code $LASTEXITCODE"
}
}
$installed = adb shell pm path $PackageName
if ($ForceInstall -or -not $installed) {
adb install -r $absoluteApk | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "adb install failed with exit code $LASTEXITCODE"
}
}
$launchArgs = @("shell", "am", "start", "-n", "$PackageName/$ActivityName")
if ($UseFixture) {
$launchArgs += @("--ez", "org.gamecult.eve.PARITY_FIXTURE", "true")
}
adb @launchArgs | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "adb launch failed with exit code $LASTEXITCODE"
}
Start-Sleep -Seconds $LaunchDelaySeconds
cmd /c "adb exec-out screencap -p > `"$absoluteOutput`""
if ($LASTEXITCODE -ne 0) {
throw "adb screencap failed with exit code $LASTEXITCODE"
}
} finally {
if ($overrideSize) {
adb shell wm size reset | Out-Host
}
if ($overrideRotation) {
if ($previousWindowUserRotation -match "^free") {
adb shell cmd window user-rotation free | Out-Host
} elseif ($previousWindowUserRotation -match "^lock\s+(\d+)") {
adb shell cmd window user-rotation lock $Matches[1] | Out-Host
}
if ($previousIgnoreOrientationRequest -match "true") {
adb shell cmd window set-ignore-orientation-request true | Out-Host
} elseif ($previousIgnoreOrientationRequest -match "false") {
adb shell cmd window set-ignore-orientation-request false | Out-Host
}
}
}
if (-not (Test-Path $absoluteOutput) -or (Get-Item $absoluteOutput).Length -le 0) {
throw "adb screencap did not produce a PNG: $absoluteOutput"
}
Write-Host $absoluteOutput

View file

@ -0,0 +1,54 @@
param(
[ValidateSet("windows", "linux")]
[string] $Target = "windows",
[ValidateSet("phone", "tablet", "desktop")]
[string] $ViewportId = "desktop",
[string] $FixtureId = "cultui-inspector",
[string] $OutputPath = "artifacts\parity\flutter-windows-cultui-inspector.png",
[Parameter(Mandatory = $true)]
[string] $SurfacePath,
[string] $FlutterExe = "E:\Projects\Eve\tools\deps\flutter\bin\flutter.bat"
)
$ErrorActionPreference = "Stop"
$projectRoot = Split-Path -Parent $PSScriptRoot
$flutterRoot = $projectRoot
$flutter = $FlutterExe
$flutterSdkRoot = Split-Path -Parent (Split-Path -Parent $flutter)
$assetPath = Join-Path $flutterRoot "assets\current-surface.json"
$fontDir = Join-Path $flutterRoot "assets\fonts"
$absoluteOutput = if ([System.IO.Path]::IsPathRooted($OutputPath)) { $OutputPath } else { Join-Path $projectRoot $OutputPath }
New-Item -ItemType Directory -Force (Split-Path -Parent $absoluteOutput) | Out-Null
New-Item -ItemType Directory -Force (Split-Path -Parent $assetPath) | Out-Null
New-Item -ItemType Directory -Force $fontDir | Out-Null
if (-not (Test-Path $flutter)) {
throw "Flutter is not installed at $flutter"
}
if ($Target -eq "linux" -and $env:OS -like "Windows*") {
throw "Linux Flutter screenshot requires a Linux runner; this host is Windows."
}
Copy-Item -LiteralPath (Join-Path $flutterSdkRoot "bin\cache\artifacts\material_fonts\roboto-regular.ttf") -Destination (Join-Path $fontDir "Roboto-Regular.ttf") -Force
Copy-Item -LiteralPath (Join-Path $flutterSdkRoot "bin\cache\artifacts\material_fonts\roboto-bold.ttf") -Destination (Join-Path $fontDir "Roboto-Bold.ttf") -Force
Copy-Item -LiteralPath $SurfacePath -Destination $assetPath -Force
Push-Location $flutterRoot
try {
& $flutter test --update-goldens "--dart-define=EVE_PARITY_FIXTURE=$FixtureId" --plain-name $ViewportId
if ($LASTEXITCODE -ne 0) {
throw "Flutter golden smoke failed with exit code $LASTEXITCODE"
}
} finally {
Pop-Location
}
$golden = Join-Path $flutterRoot "test\goldens\$FixtureId-$ViewportId.png"
if (-not (Test-Path $golden) -or (Get-Item $golden).Length -le 0) {
throw "Flutter golden did not produce a PNG: $golden"
}
Copy-Item -LiteralPath $golden -Destination $absoluteOutput -Force
Write-Host $absoluteOutput

View file

@ -0,0 +1,68 @@
param(
[string] $SshTarget = "nightwing",
[ValidateSet("phone", "tablet", "desktop")]
[string] $ViewportId = "desktop",
[string] $FixtureId = "cultui-inspector",
[Parameter(Mandatory = $true)]
[string] $SurfacePath,
[string] $LocalFlutterRoot = "E:\Projects\Eve\tools\deps\flutter",
[string] $OutputPath = "artifacts\parity\linux-flutter-cultui-inspector.png",
[string] $RemoteRoot = "~/.local/share/gamecult/eve-parity-runner",
[string] $RemoteFlutter = "~/.local/share/gamecult/flutter/bin/flutter"
)
$ErrorActionPreference = "Stop"
$projectRoot = Split-Path -Parent $PSScriptRoot
$sourceRoot = $projectRoot
$assetPath = Join-Path $sourceRoot "assets\current-surface.json"
$fontDir = Join-Path $sourceRoot "assets\fonts"
$absoluteOutput = if ([System.IO.Path]::IsPathRooted($OutputPath)) { $OutputPath } else { Join-Path $projectRoot $OutputPath }
$archivePath = Join-Path ([System.IO.Path]::GetTempPath()) "eve-parity-linux-$([guid]::NewGuid()).tar"
New-Item -ItemType Directory -Force (Split-Path -Parent $absoluteOutput) | Out-Null
New-Item -ItemType Directory -Force (Split-Path -Parent $assetPath) | Out-Null
New-Item -ItemType Directory -Force $fontDir | Out-Null
if (-not (Test-Path $sourceRoot)) {
throw "Flutter parity source not found: $sourceRoot"
}
Copy-Item -LiteralPath $SurfacePath -Destination $assetPath -Force
Copy-Item -LiteralPath (Join-Path $LocalFlutterRoot "bin\cache\artifacts\material_fonts\roboto-regular.ttf") -Destination (Join-Path $fontDir "Roboto-Regular.ttf") -Force
Copy-Item -LiteralPath (Join-Path $LocalFlutterRoot "bin\cache\artifacts\material_fonts\roboto-bold.ttf") -Destination (Join-Path $fontDir "Roboto-Bold.ttf") -Force
try {
Push-Location $sourceRoot
try {
tar --exclude .dart_tool --exclude build -cf $archivePath .
if ($LASTEXITCODE -ne 0) {
throw "tar failed with exit code $LASTEXITCODE"
}
} finally {
Pop-Location
}
ssh $SshTarget "rm -rf $RemoteRoot && mkdir -p $RemoteRoot"
scp $archivePath "${SshTarget}:/tmp/eve-parity-linux.tar" | Out-Host
ssh $SshTarget "tar -xf /tmp/eve-parity-linux.tar -C $RemoteRoot && rm /tmp/eve-parity-linux.tar"
ssh $SshTarget "cd $RemoteRoot && $RemoteFlutter test --update-goldens --dart-define=EVE_PARITY_FIXTURE=$FixtureId --plain-name $ViewportId" | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "Nightwing Flutter golden smoke failed with exit code $LASTEXITCODE"
}
$remoteGolden = "$RemoteRoot/test/goldens/$FixtureId-$ViewportId.png"
scp "${SshTarget}:$remoteGolden" $absoluteOutput | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "scp from Nightwing failed with exit code $LASTEXITCODE"
}
} finally {
if (Test-Path $archivePath) {
Remove-Item -LiteralPath $archivePath -Force
}
}
if (-not (Test-Path $absoluteOutput) -or (Get-Item $absoluteOutput).Length -le 0) {
throw "Nightwing Flutter capture did not produce a PNG: $absoluteOutput"
}
Write-Host $absoluteOutput

View file

@ -0,0 +1,17 @@
param(
[string] $SshTarget = "nightwing"
)
$ErrorActionPreference = "Stop"
$projectRoot = Split-Path -Parent $PSScriptRoot
$localScript = Join-Path $projectRoot "scripts\install-nightwing-flutter-sdk.sh"
$remoteScript = "~/.local/bin/install-eve-flutter-sdk.sh"
$stateDir = "~/.local/state/gamecult"
$pidPath = "$stateDir/eve-linux-flutter-install.pid"
$logPath = "$stateDir/eve-linux-flutter-install.log"
ssh $SshTarget "mkdir -p ~/.local/bin ~/.local/state/gamecult"
scp $localScript "${SshTarget}:$remoteScript" | Out-Host
ssh $SshTarget "chmod +x $remoteScript"
ssh $SshTarget "nohup $remoteScript >/dev/null 2>&1 & echo `$! > $pidPath && echo $pidPath && echo $logPath"

View file

@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euo pipefail
state_dir="$HOME/.local/state/gamecult"
sdk_dir="$HOME/.local/share/gamecult/flutter"
log_path="$state_dir/eve-linux-flutter-install.log"
status_path="$state_dir/eve-linux-flutter-install.status"
export CI=true
export FLUTTER_SUPPRESS_ANALYTICS=true
export NO_COLOR=1
mkdir -p "$state_dir" "$(dirname "$sdk_dir")"
{
date -u '+started %Y-%m-%dT%H:%M:%SZ'
if [ ! -x "$sdk_dir/bin/flutter" ]; then
rm -rf "$sdk_dir.tmp"
git clone --depth 1 -b stable https://github.com/flutter/flutter.git "$sdk_dir.tmp"
rm -rf "$sdk_dir"
mv "$sdk_dir.tmp" "$sdk_dir"
else
git -C "$sdk_dir" fetch --depth 1 origin stable
git -C "$sdk_dir" checkout stable
git -C "$sdk_dir" pull --ff-only origin stable
fi
"$sdk_dir/bin/flutter" --disable-analytics
"$sdk_dir/bin/flutter" --version
"$sdk_dir/bin/flutter" precache --linux
date -u '+completed %Y-%m-%dT%H:%M:%SZ'
echo complete > "$status_path"
} >> "$log_path" 2>&1

View file

@ -0,0 +1,57 @@
param(
[Parameter(Mandatory = $true)]
[string] $ExportDirectory,
[Parameter(Mandatory = $true)]
[string] $ConsumerScript,
[string] $ConsumerDirectory = "artifacts\conformance-consumer-smoke"
)
$ErrorActionPreference = "Stop"
$projectRoot = Split-Path -Parent $PSScriptRoot
$sourceExport = if ([System.IO.Path]::IsPathRooted($ExportDirectory)) {
$ExportDirectory
} else {
Join-Path $projectRoot $ExportDirectory
}
$consumerRoot = if ([System.IO.Path]::IsPathRooted($ConsumerDirectory)) {
$ConsumerDirectory
} else {
Join-Path $projectRoot $ConsumerDirectory
}
$consumerExport = Join-Path $consumerRoot "export"
if (-not (Test-Path $sourceExport)) {
throw "Conformance export not found: $sourceExport"
}
if (-not (Test-Path $ConsumerScript -PathType Leaf)) {
throw "Conformance consumer script not found: $ConsumerScript"
}
if (Test-Path $consumerExport) {
Remove-Item -LiteralPath $consumerExport -Recurse -Force
}
New-Item -ItemType Directory -Force -Path $consumerRoot | Out-Null
Copy-Item -LiteralPath $sourceExport -Destination $consumerExport -Recurse
Push-Location $projectRoot
try {
node $ConsumerScript $consumerExport `
--expect-pack runtime `
--expect-pack provider `
--expect-fixture sai-vn `
--expect-provider gamecult.home.vn `
--expect-runtime windows-flutter `
--expect-runtime linux-flutter `
--expect-runtime android-flutter `
--expect-runtime-status windows-flutter:active `
--expect-runtime-feature windows-flutter:embeddedDocuments `
--expect-runtime-command-schema windows-flutter:gamecult.eve.command_invocation.v1 `
--expect-runtime-capture-status windows-flutter:golden `
--expect-split-target EveFlutter
if ($LASTEXITCODE -ne 0) {
throw "EveFlutter conformance consumer smoke failed with exit code $LASTEXITCODE"
}
} finally {
Pop-Location
}

View file

@ -0,0 +1,86 @@
param(
[string] $LifecyclePath = "eveflutter-lifecycle.json",
[string] $DartExe = "E:\Projects\Eve\tools\deps\flutter\bin\cache\dart-sdk\bin\dart.exe",
[string] $ConformanceExport = "",
[string] $ConformanceConsumerScript = "",
[switch] $SkipAnalyze
)
$ErrorActionPreference = "Stop"
$projectRoot = Split-Path -Parent $PSScriptRoot
$absoluteLifecyclePath = if ([System.IO.Path]::IsPathRooted($LifecyclePath)) {
$LifecyclePath
} else {
Join-Path $projectRoot $LifecyclePath
}
if (-not (Test-Path $absoluteLifecyclePath)) {
throw "EveFlutter lifecycle document not found: $absoluteLifecyclePath"
}
$lifecycle = Get-Content -LiteralPath $absoluteLifecyclePath -Raw | ConvertFrom-Json
if ($lifecycle.schema -ne "gamecult.eve.runtime_lifecycle.v1") {
throw "Unexpected lifecycle schema: $($lifecycle.schema)"
}
if ($lifecycle.splitTarget -ne "EveFlutter") {
throw "Unexpected split target: $($lifecycle.splitTarget)"
}
if ($lifecycle.ownerRepo -ne "EveFlutter") {
throw "Unexpected owner repo: $($lifecycle.ownerRepo)"
}
if ($lifecycle.currentHostRepo -ne "EveFlutter") {
throw "Unexpected current host repo: $($lifecycle.currentHostRepo)"
}
$expectedRuntimes = @("windows-flutter", "linux-flutter", "android-flutter")
foreach ($runtimeId in $expectedRuntimes) {
if (-not ($lifecycle.runtimes -contains $runtimeId)) {
throw "EveFlutter lifecycle missing runtime: $runtimeId"
}
}
foreach ($stage in @("release", "test", "capture")) {
$stageDocument = $lifecycle.$stage
if ($null -eq $stageDocument) {
throw "EveFlutter lifecycle missing stage: $stage"
}
if ($stageDocument.ownerRepo -ne "EveFlutter") {
throw "EveFlutter lifecycle stage $stage has unexpected owner: $($stageDocument.ownerRepo)"
}
if (-not $stageDocument.status) {
throw "EveFlutter lifecycle stage $stage missing status"
}
foreach ($evidencePath in $stageDocument.evidencePaths) {
$absoluteEvidencePath = Join-Path $projectRoot $evidencePath
if (-not (Test-Path $absoluteEvidencePath)) {
throw "EveFlutter lifecycle stage $stage missing evidence path: $evidencePath"
}
}
}
if (-not $SkipAnalyze) {
if (-not (Test-Path $DartExe)) {
throw "Dart SDK not found: $DartExe"
}
Push-Location $projectRoot
try {
& $DartExe analyze lib test
if ($LASTEXITCODE -ne 0) {
throw "EveFlutter Dart analyzer failed with exit code $LASTEXITCODE"
}
} finally {
Pop-Location
}
}
if ($ConformanceExport -and $ConformanceConsumerScript) {
& (Join-Path $projectRoot "scripts\run-eveflutter-conformance-consumer-smoke.ps1") -ExportDirectory $ConformanceExport -ConsumerScript $ConformanceConsumerScript
if ($LASTEXITCODE -ne 0) {
throw "EveFlutter conformance consumer smoke failed with exit code $LASTEXITCODE"
}
}
Write-Host "EveFlutter lifecycle smoke passed: $absoluteLifecyclePath"