release: prepare NESLite 1.0.0 with dual cores and signed packaging
This commit is contained in:
@@ -7,10 +7,10 @@ $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'
|
||||
$apk = Join-Path $root 'app\build\outputs\apk\debug\app-debug.apk'
|
||||
$apk = Join-Path $root 'build\app\outputs\apk\debug\app-debug.apk'
|
||||
|
||||
if (-not (Test-Path $adb)) { throw "adb not found: $adb" }
|
||||
if (-not (Test-Path $apk)) { throw "M1 APK not found: $apk. Run tools/check.ps1 -Scope Build first." }
|
||||
if (-not (Test-Path $apk)) { throw "APK not found: $apk. Run 打包.cmd first." }
|
||||
|
||||
$devices = @(& $adb devices | Select-Object -Skip 1 | ForEach-Object {
|
||||
if ($_ -match '^([^\s]+)\s+device$') { $Matches[1] }
|
||||
|
||||
@@ -16,7 +16,11 @@ $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'
|
||||
$auditRoot = [IO.Path]::GetFullPath((Join-Path $root 'build\native-audit'))
|
||||
$expectedAuditRoot = [IO.Path]::GetFullPath((Join-Path $root 'build')) + [IO.Path]::DirectorySeparatorChar
|
||||
if (-not $auditRoot.StartsWith($expectedAuditRoot, [StringComparison]::OrdinalIgnoreCase)) {
|
||||
throw 'Native audit output must remain inside the repository build directory.'
|
||||
}
|
||||
if (Test-Path $auditRoot) { Remove-Item -LiteralPath $auditRoot -Recurse -Force }
|
||||
$null = New-Item -ItemType Directory -Path $auditRoot
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
@@ -80,7 +84,7 @@ $result = [ordered]@{
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $OutputPath) { $OutputPath = Join-Path $root '.build\rc-native-audit.json' }
|
||||
if (-not $OutputPath) { $OutputPath = Join-Path $root 'build\reports\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
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[ValidateSet('Build', 'Local', 'Module', 'Stage')]
|
||||
[string]$Scope = 'Build'
|
||||
)
|
||||
|
||||
$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 }
|
||||
|
||||
if (-not (Test-Path (Join-Path $env:JAVA_HOME 'bin\java.exe'))) {
|
||||
throw 'JDK 17 not found. Set JAVA_HOME to the pinned JDK; see docs/build.md.'
|
||||
}
|
||||
$javaExecutable = Join-Path $env:JAVA_HOME 'bin\java.exe'
|
||||
$javaVersionProcess = New-Object System.Diagnostics.Process
|
||||
$javaVersionProcess.StartInfo = New-Object System.Diagnostics.ProcessStartInfo
|
||||
$javaVersionProcess.StartInfo.FileName = $javaExecutable
|
||||
$javaVersionProcess.StartInfo.Arguments = '-version'
|
||||
$javaVersionProcess.StartInfo.UseShellExecute = $false
|
||||
$javaVersionProcess.StartInfo.RedirectStandardError = $true
|
||||
$javaVersionProcess.StartInfo.CreateNoWindow = $true
|
||||
$null = $javaVersionProcess.Start()
|
||||
$javaVersion = $javaVersionProcess.StandardError.ReadToEnd()
|
||||
$javaVersionProcess.WaitForExit()
|
||||
if ($javaVersionProcess.ExitCode -ne 0) {
|
||||
throw "Could not query JDK version at ${javaExecutable}."
|
||||
}
|
||||
if ($javaVersion -notmatch 'version "17\.') {
|
||||
throw "JDK 17 is required, but JAVA_HOME resolves to: $javaVersion"
|
||||
}
|
||||
if (-not (Test-Path (Join-Path $sdkRoot 'platforms\android-36.1'))) {
|
||||
throw "Android SDK Platform 36.1 not found at $sdkRoot. See docs/build.md."
|
||||
}
|
||||
|
||||
$env:ANDROID_HOME = $sdkRoot
|
||||
$env:ANDROID_SDK_ROOT = $sdkRoot
|
||||
$env:Path = "$env:JAVA_HOME\bin;$env:Path"
|
||||
$gradle = Join-Path $root 'gradlew.bat'
|
||||
$cmake = Join-Path $sdkRoot 'cmake\3.22.1\bin\cmake.exe'
|
||||
|
||||
function Invoke-AppBuild {
|
||||
& $gradle ':app:assembleDebug'
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Debug APK build failed.' }
|
||||
}
|
||||
|
||||
function Invoke-LocalTest {
|
||||
& $gradle ':app:testDebugUnitTest'
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Local unit test failed.' }
|
||||
}
|
||||
|
||||
function Invoke-NativeTest {
|
||||
if (-not (Test-Path $cmake)) { throw "Pinned Android CMake was not found: $cmake" }
|
||||
$buildDir = Join-Path $root '.build\native-tests'
|
||||
$ctest = Join-Path (Split-Path -Parent $cmake) 'ctest.exe'
|
||||
& $cmake -S (Join-Path $root 'app\src\main\cpp') -B $buildDir
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Native test configuration failed.' }
|
||||
& $cmake --build $buildDir --config Debug
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Native test build failed.' }
|
||||
& $ctest --test-dir $buildDir -C Debug --output-on-failure
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Native smoke test failed.' }
|
||||
}
|
||||
|
||||
Push-Location $root
|
||||
try {
|
||||
switch ($Scope) {
|
||||
'Build' { Invoke-AppBuild }
|
||||
'Local' { Invoke-LocalTest }
|
||||
'Module' { Invoke-NativeTest; Invoke-LocalTest }
|
||||
'Stage' { Invoke-AppBuild; Invoke-NativeTest; Invoke-LocalTest }
|
||||
}
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
@@ -30,7 +30,7 @@ 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"
|
||||
$OutputDirectory = Join-Path $root "build\device-evidence\h-long-$stamp"
|
||||
}
|
||||
$null = New-Item -ItemType Directory -Path $OutputDirectory -Force
|
||||
$rawDirectory = Join-Path $OutputDirectory 'meminfo'
|
||||
|
||||
@@ -39,3 +39,4 @@ function Get-PinnedRepository {
|
||||
Get-PinnedRepository -Name 'libretro-fceumm' -Url 'https://github.com/libretro/libretro-fceumm.git' -Commit '236ccdfc911e84c60fea6b9d0699c2d440a8de14'
|
||||
Get-PinnedRepository -Name 'libretro-headers' -Url 'https://github.com/libretro/RetroArch.git' -Commit '0c9622896333ee62dc4326bbe8784a210ddeb03c' -SparsePath @('libretro-common/include/libretro.h')
|
||||
Get-PinnedRepository -Name 'oboe' -Url 'https://github.com/google/oboe.git' -Commit 'a81bb9f87d4105b84b682685d3bfbb5beca371d1'
|
||||
Get-PinnedRepository -Name 'nestopia' -Url 'https://github.com/libretro/nestopia.git' -Commit '224713b257c8620513c1c9ca28dc7f8dea711e18'
|
||||
|
||||
@@ -5,11 +5,11 @@ param(
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
if (-not $OutputDirectory) { $OutputDirectory = Join-Path $root '.build\rc-roms' }
|
||||
if (-not $OutputDirectory) { $OutputDirectory = Join-Path $root 'build\rc-roms' }
|
||||
$resolvedOutput = [IO.Path]::GetFullPath($OutputDirectory)
|
||||
$resolvedBuildRoot = [IO.Path]::GetFullPath((Join-Path $root '.build'))
|
||||
$resolvedBuildRoot = [IO.Path]::GetFullPath((Join-Path $root 'build')) + [IO.Path]::DirectorySeparatorChar
|
||||
if (-not $resolvedOutput.StartsWith($resolvedBuildRoot, [StringComparison]::OrdinalIgnoreCase)) {
|
||||
throw 'Generated ROM output must remain inside the repository .build directory.'
|
||||
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
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
[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.15'
|
||||
$versionCode = 9015
|
||||
$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.'
|
||||
@@ -0,0 +1,25 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
project(neslite_rom_probe LANGUAGES C CXX)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
if(MSVC)
|
||||
message(FATAL_ERROR "Use MinGW GCC or a GNU-compatible Clang toolchain for the optional core probe.")
|
||||
endif()
|
||||
set(ROOT "${CMAKE_CURRENT_LIST_DIR}/../..")
|
||||
set(HOST "${ROOT}/app/src/main/cpp")
|
||||
include("${HOST}/cmake/fceumm.cmake")
|
||||
include("${HOST}/cmake/nestopia.cmake")
|
||||
if(WIN32)
|
||||
# The Android ELF export script does not apply to a Windows diagnostic DLL.
|
||||
set_property(TARGET neslite_nestopia PROPERTY LINK_OPTIONS "")
|
||||
endif()
|
||||
foreach(core IN ITEMS fceumm nestopia)
|
||||
add_executable(probe_${core} probe.cpp
|
||||
"${HOST}/rom_compatibility.cpp" "${HOST}/sha256.cpp" "${HOST}/video_conversion.cpp"
|
||||
"${HOST}/video_viewport.cpp")
|
||||
target_include_directories(probe_${core} PRIVATE "${HOST}" "${NESLITE_LIBRETRO_HEADERS_DIR}")
|
||||
endforeach()
|
||||
target_link_libraries(probe_fceumm PRIVATE fceumm_core)
|
||||
target_link_libraries(probe_nestopia PRIVATE neslite_nestopia)
|
||||
target_compile_definitions(probe_nestopia PRIVATE PROBE_NESTOPIA)
|
||||
@@ -0,0 +1,30 @@
|
||||
# 可选的单 ROM 桌面检查
|
||||
|
||||
用于区分 ROM/内核输出问题和 Android 显示问题。它使用项目锁定的两个内核,以及生产代码的哈希、
|
||||
兼容选项、像素转换和显示尺寸计算;不启动 Android、Oboe 或 GL,不代替实机验收。默认检查一份 ROM 的 1800 帧,
|
||||
保存几个 PPM 帧和统计结果,再做一次核心状态往返;不会安装为应用或自动加入 Stage 检查。
|
||||
|
||||
本机已验证 MinGW GCC 16.1.0/Ninja。从项目根目录配置(先按 `docs/build.md` 获取固定第三方源码):
|
||||
|
||||
```powershell
|
||||
$taskSdkCmake = "$env:LOCALAPPDATA\Android\Sdk\cmake\3.22.1\bin"
|
||||
$env:Path = "C:\gcc-16.1.0-64\bin;$env:Path"
|
||||
& "$taskSdkCmake\cmake.exe" -S tools/rom-probe -B build/rom-check -G Ninja "-DCMAKE_MAKE_PROGRAM=$taskSdkCmake/ninja.exe" -DCMAKE_C_COMPILER=C:/gcc-16.1.0-64/bin/gcc.exe -DCMAKE_CXX_COMPILER=C:/gcc-16.1.0-64/bin/g++.exe -DCMAKE_BUILD_TYPE=Release
|
||||
& "$taskSdkCmake\cmake.exe" --build build/rom-check --target probe_fceumm probe_nestopia -j 8
|
||||
Copy-Item -LiteralPath '龙珠英雄.nes' -Destination build/rom-check/sample.nes
|
||||
& build/rom-check/probe_fceumm.exe build/rom-check/sample.nes build/rom-check/fceumm 1800
|
||||
& build/rom-check/probe_nestopia.exe build/rom-check/sample.nes build/rom-check/nestopia 1800
|
||||
```
|
||||
|
||||
Windows 的上游文件接口要求 UTF-8,而窄字符命令行编码可能不同,所以本机检查使用 ASCII 名称的
|
||||
字节相同副本;它不修改原 ROM,也不涉及应用内已经使用哈希文件名的导入路径。样本不进入 Git。
|
||||
|
||||
可在帧数后传 `original-defaults` 暂时绕过兼容规则,重现两个内核的原始选项。帧数限 60~3600。
|
||||
只核对显示尺寸时可传 60 帧;输出 `texture` 为回调纹理尺寸,`base` 为核心基础尺寸,
|
||||
`integer_viewport` 为生产算法在 1664×1248 区域内计算的整数缩放结果,不是实际 Android 截图。
|
||||
固定输入脚本在第 180、420 帧按 Start,在第 720~1620 帧每隔 180 帧按一次 A,每次 3 帧;这只是
|
||||
可重复的启动/菜单操作,不是通用自动游玩或完整游戏验收。
|
||||
|
||||
输出中的非零音频计数表示核心确实产生音频样本,不代表听感测试通过。退出码为零仅表示加载及核心
|
||||
状态往返成功;仍须查看帧内容判断是否卡死/黑屏。原始 NTSC 下的 CPU 卡死也可能支持状态序列化。
|
||||
状态往返比较恢复前后再运行 30 帧的画面哈希,不触碰用户存档,也不替代应用存档封装/写盘测试。
|
||||
@@ -0,0 +1,188 @@
|
||||
// Opt-in ROM diagnosis. No ROM data is compiled into this program or the APK.
|
||||
#include <libretro.h>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "rom_compatibility.h"
|
||||
#include "sha256.h"
|
||||
#include "video_conversion.h"
|
||||
#include "video_viewport.h"
|
||||
|
||||
namespace {
|
||||
#ifdef PROBE_NESTOPIA
|
||||
constexpr auto core = neslite::CoreKind::Nestopia;
|
||||
#else
|
||||
constexpr auto core = neslite::CoreKind::Fceumm;
|
||||
#endif
|
||||
neslite::RomCompatibility profile = neslite::RomCompatibility::Default;
|
||||
std::map<std::string, std::string> variables;
|
||||
std::string directory, output;
|
||||
unsigned frame = 0, pixel_format = 0, video_count = 0, changes = 0;
|
||||
std::uint64_t nonzero_audio = 0;
|
||||
std::uint32_t video_hash = 0;
|
||||
std::vector<std::uint16_t> pixels;
|
||||
unsigned width = 0, height = 0;
|
||||
retro_system_av_info av{};
|
||||
|
||||
void logger(enum retro_log_level, const char* format, ...) {
|
||||
va_list args; va_start(args, format); vfprintf(stderr, format, args); va_end(args);
|
||||
}
|
||||
bool environment(unsigned command, void* data) {
|
||||
switch (command) {
|
||||
case RETRO_ENVIRONMENT_GET_CAN_DUPE: *static_cast<bool*>(data) = true; return true;
|
||||
case RETRO_ENVIRONMENT_GET_INPUT_BITMASKS: return true;
|
||||
case RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY:
|
||||
case RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY:
|
||||
case RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY:
|
||||
*static_cast<const char**>(data) = directory.c_str(); return true;
|
||||
case RETRO_ENVIRONMENT_SET_PIXEL_FORMAT:
|
||||
pixel_format = *static_cast<unsigned*>(data); return pixel_format <= 2;
|
||||
case RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION:
|
||||
*static_cast<unsigned*>(data) = 0; return true;
|
||||
case RETRO_ENVIRONMENT_SET_VARIABLES: {
|
||||
for (auto* v = static_cast<const retro_variable*>(data); v && v->key; ++v) {
|
||||
std::string value = v->value ? v->value : "";
|
||||
const auto separator = value.find(';');
|
||||
if (separator != std::string::npos) value.erase(0, separator + 1);
|
||||
value.erase(0, value.find_first_not_of(' '));
|
||||
variables[v->key] = value.substr(0, value.find('|'));
|
||||
if (const auto override = neslite::compatibility_core_option(profile, core, v->key)) {
|
||||
variables[v->key] = *override;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case RETRO_ENVIRONMENT_GET_VARIABLE: {
|
||||
auto* v = static_cast<retro_variable*>(data);
|
||||
const auto it = variables.find(v->key ? v->key : "");
|
||||
v->value = it == variables.end() ? nullptr : it->second.c_str();
|
||||
return it != variables.end();
|
||||
}
|
||||
case RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE: *static_cast<bool*>(data) = false; return true;
|
||||
case RETRO_ENVIRONMENT_SET_VARIABLE: {
|
||||
const auto* v = static_cast<const retro_variable*>(data);
|
||||
if (!v || !v->key || !v->value) return false;
|
||||
variables[v->key] = v->value; return true;
|
||||
}
|
||||
case RETRO_ENVIRONMENT_GET_LOG_INTERFACE:
|
||||
static_cast<retro_log_callback*>(data)->log = logger; return true;
|
||||
case RETRO_ENVIRONMENT_GET_LANGUAGE: *static_cast<unsigned*>(data) = RETRO_LANGUAGE_ENGLISH; return true;
|
||||
case RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION: *static_cast<unsigned*>(data) = 1; return true;
|
||||
case RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE: *static_cast<float*>(data) = 60; return true;
|
||||
case RETRO_ENVIRONMENT_GET_TARGET_SAMPLE_RATE: *static_cast<unsigned*>(data) = 48000; return true;
|
||||
case RETRO_ENVIRONMENT_SET_GEOMETRY:
|
||||
av.geometry = *static_cast<const retro_game_geometry*>(data); return true;
|
||||
case RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO:
|
||||
av = *static_cast<const retro_system_av_info*>(data); return true;
|
||||
case RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL:
|
||||
case RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS:
|
||||
case RETRO_ENVIRONMENT_SET_CONTROLLER_INFO:
|
||||
case RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE:
|
||||
case RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS:
|
||||
case RETRO_ENVIRONMENT_SET_MEMORY_MAPS:
|
||||
case RETRO_ENVIRONMENT_SET_MESSAGE:
|
||||
case RETRO_ENVIRONMENT_SET_MESSAGE_EXT: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
void dump_frame(unsigned number) {
|
||||
if (pixels.empty()) return;
|
||||
std::ofstream file(output + "-" + std::to_string(number) + ".ppm", std::ios::binary);
|
||||
file << "P6\n" << width << " " << height << "\n255\n";
|
||||
for (const auto pixel : pixels) {
|
||||
const char rgb[] = {static_cast<char>(((pixel >> 11) & 31) * 255 / 31),
|
||||
static_cast<char>(((pixel >> 5) & 63) * 255 / 63), static_cast<char>((pixel & 31) * 255 / 31)};
|
||||
file.write(rgb, 3);
|
||||
}
|
||||
if (!file) throw std::runtime_error("Could not save diagnostic frame");
|
||||
}
|
||||
void video(const void* data, unsigned w, unsigned h, size_t pitch) {
|
||||
if (!data) return;
|
||||
if (!neslite::convert_to_rgb565(data, w, h, pitch, pixel_format, &pixels)) {
|
||||
throw std::runtime_error("Unsupported or invalid video frame");
|
||||
}
|
||||
++video_count; width = w; height = h;
|
||||
std::uint32_t hash = 2166136261u;
|
||||
for (const auto pixel : pixels) hash = (hash ^ pixel) * 16777619u;
|
||||
if (hash != video_hash) ++changes;
|
||||
video_hash = hash;
|
||||
if (frame == 179 || frame == 599 || frame == 1199) {
|
||||
std::cout << "frame=" << frame << " colors=" << std::set(pixels.begin(), pixels.end()).size()
|
||||
<< " hash=" << video_hash << '\n';
|
||||
dump_frame(frame);
|
||||
}
|
||||
}
|
||||
void audio(int16_t left, int16_t right) { if (left || right) ++nonzero_audio; }
|
||||
size_t batch(const int16_t* data, size_t count) {
|
||||
for (size_t i = 0; i < count; ++i) audio(data[i * 2], data[i * 2 + 1]);
|
||||
return count;
|
||||
}
|
||||
void poll() {}
|
||||
int16_t input(unsigned port, unsigned, unsigned, unsigned id) {
|
||||
unsigned mask = 0;
|
||||
if (port == 0) {
|
||||
if ((frame >= 180 && frame < 183) || (frame >= 420 && frame < 423)) mask = 1u << RETRO_DEVICE_ID_JOYPAD_START;
|
||||
if (frame >= 720 && frame < 1623 && (frame - 720) % 180 < 3) mask = 1u << RETRO_DEVICE_ID_JOYPAD_A;
|
||||
}
|
||||
return id == RETRO_DEVICE_ID_JOYPAD_MASK ? mask : id < 16 ? (mask >> id) & 1 : 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc < 3 || argc > 5) {
|
||||
std::cerr << "Usage: probe_<core> ASCII_ROM_PATH OUTPUT_PREFIX [frames:60..3600] [original-defaults]\n";
|
||||
return 2;
|
||||
}
|
||||
const unsigned frames = argc > 3 ? static_cast<unsigned>(std::stoul(argv[3])) : 1800;
|
||||
if (frames < 60 || frames > 3600) return 2;
|
||||
const std::filesystem::path rom_path = argv[1];
|
||||
const auto size = std::filesystem::file_size(rom_path);
|
||||
if (size < 16 || size > 64U * 1024U * 1024U) return 3;
|
||||
std::ifstream file(rom_path, std::ios::binary);
|
||||
std::vector<std::uint8_t> rom(size);
|
||||
if (!file.read(reinterpret_cast<char*>(rom.data()), static_cast<std::streamsize>(size))) return 3;
|
||||
const auto hash = neslite::sha256_hex(rom);
|
||||
if (argc < 5 || std::string(argv[4]) != "original-defaults") profile = neslite::rom_compatibility_for(hash);
|
||||
output = argv[2];
|
||||
directory = std::filesystem::absolute(std::filesystem::path(output).parent_path()).string();
|
||||
std::filesystem::create_directories(directory);
|
||||
std::cout << "sha256=" << hash << " profile=" << neslite::compatibility_profile_name(profile) << '\n';
|
||||
retro_set_environment(environment); retro_set_video_refresh(video);
|
||||
retro_set_audio_sample(audio); retro_set_audio_sample_batch(batch);
|
||||
retro_set_input_poll(poll); retro_set_input_state(input);
|
||||
retro_init(); retro_set_controller_port_device(0, RETRO_DEVICE_JOYPAD);
|
||||
retro_game_info game{argv[1], rom.data(), rom.size(), nullptr};
|
||||
if (!retro_load_game(&game)) { retro_deinit(); return 4; }
|
||||
retro_get_system_av_info(&av);
|
||||
std::cout << "fps=" << av.timing.fps << " format=" << pixel_format
|
||||
<< " battery=" << retro_get_memory_size(RETRO_MEMORY_SAVE_RAM) << '\n';
|
||||
for (frame = 0; frame < frames; ++frame) retro_run();
|
||||
dump_frame(frames);
|
||||
std::cout << "frames=" << video_count << " changes=" << changes << " audio_nonzero=" << nonzero_audio << '\n';
|
||||
const auto viewport = neslite::calculate_video_viewport(1664, 1248,
|
||||
av.geometry.base_width, av.geometry.base_height, true);
|
||||
std::cout << "texture=" << width << 'x' << height << " base=" << av.geometry.base_width << 'x'
|
||||
<< av.geometry.base_height << " integer_viewport=" << viewport.width << 'x' << viewport.height
|
||||
<< " at=" << viewport.x << ',' << viewport.y << " surface=1664x1248\n";
|
||||
// One deterministic core-state round trip; this is not an Android save-file test.
|
||||
std::vector<std::uint8_t> state(retro_serialize_size());
|
||||
bool roundtrip = !state.empty() && retro_serialize(state.data(), state.size());
|
||||
if (roundtrip) {
|
||||
for (frame = frames; frame < frames + 30; ++frame) retro_run();
|
||||
const auto expected = video_hash;
|
||||
roundtrip = retro_unserialize(state.data(), state.size());
|
||||
if (roundtrip) {
|
||||
for (frame = frames; frame < frames + 30; ++frame) retro_run();
|
||||
roundtrip = expected == video_hash;
|
||||
}
|
||||
}
|
||||
std::cout << "core_state_roundtrip=" << (roundtrip ? "pass" : "fail") << '\n';
|
||||
retro_unload_game(); retro_deinit();
|
||||
return roundtrip ? 0 : 5;
|
||||
}
|
||||
Reference in New Issue
Block a user