feat: prepare M8 release candidate

This commit is contained in:
2026-09-12 15:11:53 +08:00
parent 08b8f9671e
commit 01149be202
25 changed files with 938 additions and 16 deletions
+88
View File
@@ -0,0 +1,88 @@
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$ApkPath,
[string]$OutputPath = ''
)
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$sdkRoot = if ($env:ANDROID_HOME) { $env:ANDROID_HOME } else { 'C:\Users\shenw_o246oq4\AppData\Local\Android\Sdk' }
$ndkVersion = '28.2.13676358'
$buildToolsVersion = '36.1.0'
$zipalign = Join-Path $sdkRoot "build-tools\$buildToolsVersion\zipalign.exe"
$readelf = Join-Path $sdkRoot "ndk\$ndkVersion\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-readelf.exe"
$resolvedApk = (Resolve-Path $ApkPath).Path
if (-not (Test-Path $zipalign)) { throw "zipalign not found: $zipalign" }
if (-not (Test-Path $readelf)) { throw "llvm-readelf not found: $readelf" }
$auditRoot = Join-Path $root '.build\rc-native-audit'
if (Test-Path $auditRoot) { Remove-Item -LiteralPath $auditRoot -Recurse -Force }
$null = New-Item -ItemType Directory -Path $auditRoot
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($resolvedApk, $auditRoot)
$nativeFiles = Get-ChildItem (Join-Path $auditRoot 'lib') -Filter '*.so' -File -Recurse -ErrorAction SilentlyContinue
if (-not $nativeFiles) { throw 'No native libraries were found in the candidate APK.' }
$unexpectedAbi = $nativeFiles | Where-Object { $_.FullName -notmatch '[\\/]lib[\\/]arm64-v8a[\\/]' }
if ($unexpectedAbi) { throw "Unexpected non-arm64 native libraries: $($unexpectedAbi.FullName -join ', ')" }
$zipalignOutput = & $zipalign -c -P 16 -v 4 $resolvedApk 2>&1
if ($LASTEXITCODE -ne 0) { throw "APK 16 KB zip alignment failed:`n$($zipalignOutput -join [Environment]::NewLine)" }
$libraries = foreach ($library in $nativeFiles) {
$segments = & $readelf -lW $library.FullName 2>&1
if ($LASTEXITCODE -ne 0) { throw "ELF inspection failed for $($library.Name)." }
$loadLines = @($segments | Where-Object { $_ -match '^\s*LOAD\s+' })
if (-not $loadLines) { throw "No LOAD segments found in $($library.Name)." }
$alignments = foreach ($line in $loadLines) {
if ($line -notmatch '(0x[0-9a-fA-F]+)\s*$') { throw "Cannot parse LOAD alignment: $line" }
[Convert]::ToInt64($Matches[1].Substring(2), 16)
}
if (($alignments | Measure-Object -Minimum).Minimum -lt 16384) {
throw "$($library.Name) contains a LOAD segment aligned below 16 KB."
}
$dynamic = & $readelf -dW $library.FullName 2>&1
if ($LASTEXITCODE -ne 0) { throw "Dynamic dependency inspection failed for $($library.Name)." }
$needed = @($dynamic | ForEach-Object {
if ($_ -match '\(NEEDED\).*\[(.+?)\]') { $Matches[1] }
})
[ordered]@{
apkPath = $library.FullName.Substring($auditRoot.Length + 1).Replace('\', '/')
bytes = $library.Length
sha256 = (Get-FileHash $library.FullName -Algorithm SHA256).Hash
minimumLoadAlignmentBytes = ($alignments | Measure-Object -Minimum).Minimum
needed = $needed
}
}
$readelfVersion = ((& $readelf --version 2>&1 | Select-Object -First 2) -join ' ').Trim()
$result = [ordered]@{
formatVersion = 1
apk = [ordered]@{
path = $resolvedApk
bytes = (Get-Item $resolvedApk).Length
sha256 = (Get-FileHash $resolvedApk -Algorithm SHA256).Hash
zipAlignmentBytes = 16384
zipAlignmentPassed = $true
}
packaging = [ordered]@{
abi = 'arm64-v8a'
fceumm = 'statically linked into libneslite_jni.so'
oboe = 'statically linked into libneslite_jni.so'
runtimeLibraries = @($libraries | ForEach-Object { $_.apkPath })
}
libraries = @($libraries)
tools = [ordered]@{
androidBuildTools = $buildToolsVersion
ndk = $ndkVersion
llvmReadelf = $readelfVersion
}
}
if (-not $OutputPath) { $OutputPath = Join-Path $root '.build\rc-native-audit.json' }
$outputDirectory = Split-Path -Parent $OutputPath
if ($outputDirectory) { $null = New-Item -ItemType Directory -Path $outputDirectory -Force }
$result | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath $OutputPath -Encoding utf8NoBOM
Write-Output "RC native static audit passed: $OutputPath"
$result | ConvertTo-Json -Depth 8
+118
View File
@@ -0,0 +1,118 @@
[CmdletBinding()]
param(
[string]$Serial = '',
[string]$Package = 'org.neslite.app',
[ValidateRange(1, 1440)]
[int]$Minutes = 120,
[ValidateRange(10, 300)]
[int]$IntervalSeconds = 60,
[string]$OutputDirectory = ''
)
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$sdkRoot = if ($env:ANDROID_HOME) { $env:ANDROID_HOME } else { 'C:\Users\shenw_o246oq4\AppData\Local\Android\Sdk' }
$adb = Join-Path $sdkRoot 'platform-tools\adb.exe'
if (-not (Test-Path $adb)) { throw "adb not found: $adb" }
$adbArguments = @()
if ($Serial) { $adbArguments += @('-s', $Serial) }
function Invoke-Adb([string[]]$Arguments) {
$output = & $adb @adbArguments @Arguments 2>&1
if ($LASTEXITCODE -ne 0) { throw "adb failed: $($output -join [Environment]::NewLine)" }
return @($output)
}
$state = (Invoke-Adb @('get-state') | Select-Object -First 1).Trim()
if ($state -ne 'device') { throw "Target device is not ready: $state" }
$pidValue = (Invoke-Adb @('shell', 'pidof', $Package) | Select-Object -First 1).Trim()
if (-not $pidValue) { throw "Package is not running: $Package" }
if (-not $OutputDirectory) {
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
$OutputDirectory = Join-Path $root ".build\device-evidence\h-long-$stamp"
}
$null = New-Item -ItemType Directory -Path $OutputDirectory -Force
$rawDirectory = Join-Path $OutputDirectory 'meminfo'
$null = New-Item -ItemType Directory -Path $rawDirectory -Force
$device = [ordered]@{
serial = (Invoke-Adb @('get-serialno') | Select-Object -First 1).Trim()
product = (Invoke-Adb @('shell', 'getprop', 'ro.product.model') | Select-Object -First 1).Trim()
release = (Invoke-Adb @('shell', 'getprop', 'ro.build.version.release') | Select-Object -First 1).Trim()
api = (Invoke-Adb @('shell', 'getprop', 'ro.build.version.sdk') | Select-Object -First 1).Trim()
abi = (Invoke-Adb @('shell', 'getprop', 'ro.product.cpu.abi') | Select-Object -First 1).Trim()
pageSizeBytes = [long]((Invoke-Adb @('shell', 'getconf', 'PAGESIZE') | Select-Object -First 1).Trim())
}
$started = Get-Date
$deadline = $started.AddMinutes($Minutes)
$samples = [System.Collections.Generic.List[object]]::new()
$index = 0
while ((Get-Date) -lt $deadline) {
$pidValue = (Invoke-Adb @('shell', 'pidof', $Package) | Select-Object -First 1).Trim()
if (-not $pidValue) { throw "Package exited during H-LONG at sample $index." }
$raw = Invoke-Adb @('shell', 'dumpsys', 'meminfo', '--local', $Package)
$rawPath = Join-Path $rawDirectory ("sample-{0:D4}.txt" -f $index)
$raw | Set-Content -LiteralPath $rawPath -Encoding utf8NoBOM
$text = $raw -join "`n"
$totalPss = if ($text -match 'TOTAL PSS:\s*([0-9,]+)') { [long]($Matches[1] -replace ',', '') } else { 0L }
$javaHeap = if ($text -match 'Java Heap:\s*([0-9,]+)') { [long]($Matches[1] -replace ',', '') } else { 0L }
$nativeHeap = if ($text -match 'Native Heap:\s*([0-9,]+)') { [long]($Matches[1] -replace ',', '') } else { 0L }
$samples.Add([pscustomobject]@{
index = $index
epochMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
elapsedMinutes = [Math]::Round(((Get-Date) - $started).TotalMinutes, 3)
pid = $pidValue
totalPssKiB = $totalPss
javaHeapKiB = $javaHeap
nativeHeapKiB = $nativeHeap
})
$samples | Export-Csv -LiteralPath (Join-Path $OutputDirectory 'memory.csv') -NoTypeInformation -Encoding utf8NoBOM
++$index
if ((Get-Date).AddSeconds($IntervalSeconds) -lt $deadline) { Start-Sleep -Seconds $IntervalSeconds }
}
$logcat = Invoke-Adb @('logcat', '-d', '--pid', $pidValue, '-v', 'epoch', '*:W')
$logcat | Set-Content -LiteralPath (Join-Path $OutputDirectory 'logcat-warnings.txt') -Encoding utf8NoBOM
$logText = $logcat -join "`n"
$trendSamples = @($samples | Where-Object elapsedMinutes -ge 10)
$trendSlopeKiBPerMinute = 0.0
if ($trendSamples.Count -ge 2) {
$meanX = ($trendSamples.elapsedMinutes | Measure-Object -Average).Average
$meanY = ($trendSamples.totalPssKiB | Measure-Object -Average).Average
$numerator = 0.0
$denominator = 0.0
foreach ($sample in $trendSamples) {
$deltaX = $sample.elapsedMinutes - $meanX
$numerator += $deltaX * ($sample.totalPssKiB - $meanY)
$denominator += $deltaX * $deltaX
}
if ($denominator -gt 0) { $trendSlopeKiBPerMinute = $numerator / $denominator }
}
$summary = [ordered]@{
formatVersion = 1
package = $Package
device = $device
requestedMinutes = $Minutes
intervalSeconds = $IntervalSeconds
startedAt = $started.ToString('o')
finishedAt = (Get-Date).ToString('o')
sampleCount = $samples.Count
firstTotalPssKiB = if ($samples.Count) { $samples[0].totalPssKiB } else { 0 }
lastTotalPssKiB = if ($samples.Count) { $samples[$samples.Count - 1].totalPssKiB } else { 0 }
peakTotalPssKiB = if ($samples.Count) { ($samples.totalPssKiB | Measure-Object -Maximum).Maximum } else { 0 }
postWarmupTrendStartMinute = 10
postWarmupTotalPssSlopeKiBPerMinute = [Math]::Round($trendSlopeKiBPerMinute, 3)
fatalExceptionCount = ([regex]::Matches($logText, 'FATAL EXCEPTION')).Count
anrCount = ([regex]::Matches($logText, 'ANR in ' + [regex]::Escape($Package))).Count
verdict = if ($Minutes -ge 120 -and $samples.Count -ge 120 -and
@($samples | Where-Object totalPssKiB -eq 0).Count -eq 0 -and
$logText -notmatch 'FATAL EXCEPTION|ANR in ') {
'REVIEW_MEMORY_TREND'
} else {
'INCOMPLETE_OR_FAILED'
}
}
$summary | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $OutputDirectory 'summary.json') -Encoding utf8NoBOM
Write-Output "H-LONG capture complete: $OutputDirectory"
Write-Output 'Review memory.csv for a sustained post-warmup trend before marking the run passed.'
+103
View File
@@ -0,0 +1,103 @@
[CmdletBinding()]
param(
[string]$OutputDirectory = ''
)
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
if (-not $OutputDirectory) { $OutputDirectory = Join-Path $root '.build\rc-roms' }
$resolvedOutput = [IO.Path]::GetFullPath($OutputDirectory)
$resolvedBuildRoot = [IO.Path]::GetFullPath((Join-Path $root '.build'))
if (-not $resolvedOutput.StartsWith($resolvedBuildRoot, [StringComparison]::OrdinalIgnoreCase)) {
throw 'Generated ROM output must remain inside the repository .build directory.'
}
if (Test-Path $resolvedOutput) { Remove-Item -LiteralPath $resolvedOutput -Recurse -Force }
$null = New-Item -ItemType Directory -Path $resolvedOutput
$specifications = @(
@{ id = 'RC01'; mapper = 0; region = 'NTSC'; header = 'iNES'; battery = $false; prgBanks = 1 },
@{ id = 'RC02'; mapper = 0; region = 'PAL'; header = 'NES2'; battery = $false; prgBanks = 2 },
@{ id = 'RC03'; mapper = 1; region = 'NTSC'; header = 'iNES'; battery = $true; prgBanks = 2 },
@{ id = 'RC04'; mapper = 1; region = 'PAL'; header = 'NES2'; battery = $true; prgBanks = 2 },
@{ id = 'RC05'; mapper = 2; region = 'NTSC'; header = 'iNES'; battery = $false; prgBanks = 2 },
@{ id = 'RC06'; mapper = 2; region = 'PAL'; header = 'NES2'; battery = $false; prgBanks = 2 },
@{ id = 'RC07'; mapper = 3; region = 'NTSC'; header = 'iNES'; battery = $false; prgBanks = 2 },
@{ id = 'RC08'; mapper = 3; region = 'PAL'; header = 'NES2'; battery = $false; prgBanks = 2 },
@{ id = 'RC09'; mapper = 4; region = 'NTSC'; header = 'iNES'; battery = $true; prgBanks = 2 },
@{ id = 'RC10'; mapper = 4; region = 'PAL'; header = 'NES2'; battery = $true; prgBanks = 2 },
@{ id = 'RC11'; mapper = 0; region = 'NTSC'; header = 'NES2'; battery = $true; prgBanks = 1 },
@{ id = 'RC12'; mapper = 4; region = 'NTSC'; header = 'NES2'; battery = $false; prgBanks = 2 }
)
$manifestEntries = foreach ($specification in $specifications) {
$header = [byte[]]::new(16)
$header[0] = 0x4e; $header[1] = 0x45; $header[2] = 0x53; $header[3] = 0x1a
$header[4] = [byte]$specification.prgBanks
$header[5] = 1
$header[6] = [byte]((($specification.mapper -band 0x0f) -shl 4) -bor $(if ($specification.battery) { 0x02 } else { 0 }))
$header[7] = [byte]($specification.mapper -band 0xf0)
if ($specification.header -eq 'NES2') { $header[7] = [byte]($header[7] -bor 0x08) }
if ($specification.region -eq 'PAL') {
if ($specification.header -eq 'NES2') { $header[12] = 1 } else { $header[9] = 1 }
}
$prg = [byte[]]::new([int]$specification.prgBanks * 16384)
[Array]::Fill($prg, [byte]0xea)
$programOffset = $prg.Length - 16384
$program = [byte[]](0x78, 0xd8, 0xa2, 0xff, 0x9a, 0xe8, 0x8e, 0x00, 0x20, 0x8e, 0x01, 0x20, 0x4c, 0x0c, 0xc0)
[Array]::Copy($program, 0, $prg, $programOffset, $program.Length)
$marker = [Text.Encoding]::ASCII.GetBytes("NESLITE-$($specification.id)-M$($specification.mapper)-$($specification.region)-$($specification.header)")
[Array]::Copy($marker, 0, $prg, $programOffset + 64, $marker.Length)
$vectorOffset = $prg.Length - 6
for ($index = 0; $index -lt 3; ++$index) {
$prg[$vectorOffset + ($index * 2)] = 0x00
$prg[$vectorOffset + ($index * 2) + 1] = 0xc0
}
$chr = [byte[]]::new(8192)
$rom = [byte[]]::new($header.Length + $prg.Length + $chr.Length)
[Array]::Copy($header, 0, $rom, 0, $header.Length)
[Array]::Copy($prg, 0, $rom, $header.Length, $prg.Length)
[Array]::Copy($chr, 0, $rom, $header.Length + $prg.Length, $chr.Length)
$fileName = "$($specification.id)-m$($specification.mapper)-$($specification.region.ToLowerInvariant())-$($specification.header.ToLowerInvariant()).nes"
$path = Join-Path $resolvedOutput $fileName
[IO.File]::WriteAllBytes($path, $rom)
[ordered]@{
id = $specification.id
fileName = $fileName
sha256 = (Get-FileHash $path -Algorithm SHA256).Hash
bytes = $rom.Length
region = $specification.region
mapper = $specification.mapper
header = $specification.header
battery = [bool]$specification.battery
license = 'CC0-1.0 generated test fixture'
purpose = 'Deterministic loader/header/mapper-declaration smoke fixture; not gameplay evidence.'
}
}
$manifest = [ordered]@{
formatVersion = 1
generator = 'tools/generate-rc-roms.ps1'
rights = 'Generated by NESLite for this test set and dedicated under CC0-1.0; contains no third-party game data.'
limitations = 'Minimal looping programs validate import/load declarations only; they do not replace action, scrolling, audio, or battery-progress gameplay samples.'
samples = @($manifestEntries)
}
$frozenPath = Join-Path $root 'tests\rc-rom-manifest.json'
$frozen = Get-Content $frozenPath -Raw | ConvertFrom-Json
if ($frozen.samples.Count -ne $manifestEntries.Count) { throw 'Frozen RC ROM sample count changed.' }
foreach ($expected in $frozen.samples) {
$matches = @($manifestEntries | Where-Object id -eq $expected.id)
$actual = if ($matches.Count -eq 1) { $matches[0] } else { $null }
if (-not $actual -or $actual.sha256 -ne $expected.sha256 -or $actual.region -ne $expected.region -or
$actual.mapper -ne $expected.mapper -or $actual.header -ne $expected.header -or
$actual.battery -ne $expected.battery) {
throw "Generated RC ROM no longer matches frozen manifest: $($expected.id)"
}
}
$manifest | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $resolvedOutput 'manifest.json') -Encoding utf8NoBOM
@'
To the extent possible under law, the author has waived all copyright and related or neighboring rights to these generated test fixtures under CC0 1.0 Universal.
These fixtures contain only a minimal original loop and deterministic metadata; they contain no third-party game code, graphics, audio, or other ROM content.
'@ | Set-Content -LiteralPath (Join-Path $resolvedOutput 'LICENSE.txt') -Encoding utf8NoBOM
Write-Output "Generated 12 deterministic RC ROM fixtures: $resolvedOutput"
$manifest | ConvertTo-Json -Depth 6
+152
View File
@@ -0,0 +1,152 @@
[CmdletBinding()]
param(
[string]$OutputDirectory = ''
)
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$sdkRoot = if ($env:ANDROID_HOME) { $env:ANDROID_HOME } else { 'C:\Users\shenw_o246oq4\AppData\Local\Android\Sdk' }
$bundledJdk = Join-Path $root '.toolchains\jdk-17.0.17+10'
$env:JAVA_HOME = if ($env:JAVA_HOME -and (Test-Path (Join-Path $env:JAVA_HOME 'bin\java.exe'))) {
$env:JAVA_HOME
} else {
$bundledJdk
}
$env:ANDROID_HOME = $sdkRoot
$env:ANDROID_SDK_ROOT = $sdkRoot
$versionName = '0.9.4'
$versionCode = 9004
$gitStatus = @(& git -C $root status --porcelain)
if ($LASTEXITCODE -ne 0) { throw 'Cannot inspect the Git worktree.' }
if ($gitStatus.Count -ne 0) { throw 'RC packaging requires a clean committed worktree.' }
$sourceCommit = (& git -C $root rev-parse HEAD).Trim()
if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve the source commit.' }
if (-not $OutputDirectory) { $OutputDirectory = Join-Path $root ".build\rc-$versionName" }
$resolvedOutput = [IO.Path]::GetFullPath($OutputDirectory)
$resolvedBuildRoot = [IO.Path]::GetFullPath((Join-Path $root '.build'))
if (-not $resolvedOutput.StartsWith($resolvedBuildRoot, [StringComparison]::OrdinalIgnoreCase)) {
throw 'RC output must remain inside the repository .build directory.'
}
if (Test-Path $resolvedOutput) { Remove-Item -LiteralPath $resolvedOutput -Recurse -Force }
$null = New-Item -ItemType Directory -Path $resolvedOutput
& pwsh -NoProfile -ExecutionPolicy Bypass -File (Join-Path $root 'tools\check.ps1') -Scope Stage
if ($LASTEXITCODE -ne 0) { throw 'Stage checks failed.' }
& (Join-Path $root 'gradlew.bat') ':app:assembleRelease' ':app:lintRelease' ':app:assembleDebugAndroidTest'
if ($LASTEXITCODE -ne 0) { throw 'Release build or lint failed.' }
$builtApk = Join-Path $root 'app\build\outputs\apk\release\app-release-unsigned.apk'
$builtSymbols = Join-Path $root 'app\build\outputs\native-debug-symbols\release\native-debug-symbols.zip'
if (-not (Test-Path $builtApk)) { throw "Unsigned release APK not found: $builtApk" }
if (-not (Test-Path $builtSymbols)) { throw "Native symbols not found: $builtSymbols" }
$candidateApk = Join-Path $resolvedOutput "NESLite-$versionName-rc-arm64-v8a-unsigned.apk"
$candidateSymbols = Join-Path $resolvedOutput "NESLite-$versionName-native-debug-symbols.zip"
Copy-Item -LiteralPath $builtApk -Destination $candidateApk
Copy-Item -LiteralPath $builtSymbols -Destination $candidateSymbols
$testTools = Join-Path $resolvedOutput 'test-tools'
$null = New-Item -ItemType Directory -Path $testTools
Copy-Item -LiteralPath (Join-Path $root 'app\build\outputs\apk\debug\app-debug.apk') -Destination $testTools
Copy-Item -LiteralPath (Join-Path $root 'app\build\outputs\apk\androidTest\debug\app-debug-androidTest.apk') -Destination $testTools
$nativeAudit = Join-Path $resolvedOutput 'native-audit.json'
& pwsh -NoProfile -ExecutionPolicy Bypass -File (Join-Path $root 'tools\check-rc-native.ps1') -ApkPath $candidateApk -OutputPath $nativeAudit
if ($LASTEXITCODE -ne 0) { throw 'Native static audit failed.' }
$aapt = Join-Path $sdkRoot 'build-tools\36.1.0\aapt.exe'
$badging = @(& $aapt dump badging $candidateApk 2>&1)
if ($LASTEXITCODE -ne 0) { throw 'Could not inspect candidate APK identity.' }
$packageLine = $badging | Select-Object -First 1
if ($packageLine -notmatch "name='org\.neslite\.app'.*versionCode='$versionCode'.*versionName='$versionName'") {
throw "Unexpected release identity: $packageLine"
}
$appSourceArchive = Join-Path $resolvedOutput "NESLite-$versionName-source.zip"
& git -C $root archive --format=zip "--prefix=NESLite-$versionName/" "--output=$appSourceArchive" HEAD
if ($LASTEXITCODE -ne 0) { throw 'Application source archive failed.' }
$thirdPartyManifest = Get-Content (Join-Path $root 'third_party\manifest.json') -Raw | ConvertFrom-Json
$thirdPartyArchives = @()
foreach ($source in $thirdPartyManifest.sources) {
$sourceDirectory = Join-Path $root "third_party\sources\$($source.directory)"
if (-not (Test-Path $sourceDirectory)) { throw "Third-party source is missing: $($source.directory)" }
$actualCommit = (& git -C $sourceDirectory rev-parse HEAD).Trim()
if ($LASTEXITCODE -ne 0 -or $actualCommit -ne $source.commit) {
throw "Third-party source is not at its locked commit: $($source.directory)"
}
$archive = Join-Path $resolvedOutput "$($source.directory)-$($source.commit.Substring(0, 12))-source.zip"
& git -C $sourceDirectory archive --format=zip "--prefix=$($source.directory)/" "--output=$archive" $source.commit
if ($LASTEXITCODE -ne 0) { throw "Source archive failed: $($source.directory)" }
$thirdPartyArchives += Split-Path -Leaf $archive
}
$materials = Join-Path $resolvedOutput 'release-materials'
$null = New-Item -ItemType Directory -Path $materials
Copy-Item -LiteralPath (Join-Path $root 'LICENSE') -Destination $materials
Copy-Item -LiteralPath (Join-Path $root 'THIRD_PARTY_NOTICES.md') -Destination $materials
Copy-Item -LiteralPath (Join-Path $root 'third_party\manifest.json') -Destination $materials
Copy-Item -LiteralPath (Join-Path $root 'third_party\sources\oboe\LICENSE') -Destination (Join-Path $materials 'APACHE-2.0.txt')
Copy-Item -LiteralPath (Join-Path $root 'third_party\sources\libretro-fceumm\Copying') -Destination (Join-Path $materials 'GPL-2.0.txt')
Copy-Item -LiteralPath (Join-Path $root 'docs\build.md') -Destination $materials
Copy-Item -LiteralPath (Join-Path $root 'docs\usage.md') -Destination $materials
Copy-Item -LiteralPath (Join-Path $root 'docs\architecture.md') -Destination $materials
Copy-Item -LiteralPath (Join-Path $root 'docs\save-format.md') -Destination $materials
Copy-Item -LiteralPath (Join-Path $root 'docs\known-issues.md') -Destination $materials
Copy-Item -LiteralPath (Join-Path $root 'docs\reports\m8-release-candidate.md') -Destination $materials
& pwsh -NoProfile -ExecutionPolicy Bypass -File (Join-Path $root 'tools\generate-rc-roms.ps1')
if ($LASTEXITCODE -ne 0) { throw 'Frozen RC ROM generation or hash verification failed.' }
$fixtureMetadata = Join-Path $resolvedOutput 'rom-fixture-metadata'
$null = New-Item -ItemType Directory -Path $fixtureMetadata
Copy-Item -LiteralPath (Join-Path $root '.build\rc-roms\manifest.json') -Destination $fixtureMetadata
Copy-Item -LiteralPath (Join-Path $root '.build\rc-roms\LICENSE.txt') -Destination $fixtureMetadata
$manifest = [ordered]@{
formatVersion = 1
generatedAt = (Get-Date).ToUniversalTime().ToString('o')
sourceCommit = $sourceCommit
versionName = $versionName
versionCode = $versionCode
applicationId = 'org.neslite.app'
abi = @('arm64-v8a')
signing = [ordered]@{
signed = $false
status = 'BLOCKED_PENDING_RELEASE_KEY'
note = 'This static-audit candidate must be signed with the protected release key before installation or upgrade testing.'
}
native = [ordered]@{
fceummCommit = '236ccdfc911e84c60fea6b9d0699c2d440a8de14'
libretroHeaderCommit = '0c9622896333ee62dc4326bbe8784a210ddeb03c'
oboeCommit = 'a81bb9f87d4105b84b682685d3bfbb5beca371d1'
symbols = Split-Path -Leaf $candidateSymbols
mapping = 'not generated; minification is disabled'
}
artifacts = [ordered]@{
apk = Split-Path -Leaf $candidateApk
applicationSource = Split-Path -Leaf $appSourceArchive
thirdPartySources = $thirdPartyArchives
nativeAudit = Split-Path -Leaf $nativeAudit
materials = 'release-materials/'
romFixtureMetadata = 'rom-fixture-metadata/'
androidMigrationTest = 'test-tools/app-debug-androidTest.apk'
}
runtimeEvidence = [ordered]@{
romCompatibility = 'BLOCKED_NO_EXECUTED_RC_COMPATIBILITY_OR_GAMEPLAY_SAMPLES'
hLong = 'BLOCKED_NO_DEVICE'
hInput = 'BLOCKED_NO_DEVICE'
fourKiB = 'BLOCKED_NO_DEVICE'
sixteenKiB = 'BLOCKED_NO_DEVICE'
api28 = 'BLOCKED_NO_DEVICE'
upgrade = 'BLOCKED_NO_SIGNED_OLD_DATASET_OR_DEVICE'
}
}
$manifestPath = Join-Path $resolvedOutput 'candidate-manifest.json'
$manifest | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath $manifestPath -Encoding utf8NoBOM
$checksumFiles = Get-ChildItem $resolvedOutput -File -Recurse | Where-Object Name -ne 'SHA256SUMS.txt' | Sort-Object FullName
$checksumLines = foreach ($file in $checksumFiles) {
$relative = [IO.Path]::GetRelativePath($resolvedOutput, $file.FullName).Replace('\', '/')
"{0} {1}" -f (Get-FileHash $file.FullName -Algorithm SHA256).Hash, $relative
}
$checksumLines | Set-Content -LiteralPath (Join-Path $resolvedOutput 'SHA256SUMS.txt') -Encoding ascii
Write-Output "RC materials created: $resolvedOutput"
Write-Output 'The APK is intentionally unsigned; device and upgrade gates remain blocked until release signing is available.'