Add Fetch Disks button and Anleitung copy-protection viewer
- Cross-compile nibtools for Android NDK; download all 8 episode disks
from the Internet Archive C64 Preservation Project as NBZ and convert
to G64 via JNI (throwaway-pthread to contain nibconv's exit() calls)
- Bundle manual transcription as APK asset; 📖 button opens scrollable
viewer with Seite→Absatz→Zeile→Wort lookup hierarchy documented
This commit is contained in:
@@ -122,11 +122,77 @@ tasks.register("buildVice") {
|
||||
}
|
||||
}
|
||||
|
||||
// Run buildVice before any CMake configure or build step.
|
||||
// ---------------------------------------------------------------------------
|
||||
// nibtools cross-compilation task
|
||||
//
|
||||
// Builds nibconv (NIB/NBZ -> G64/D64 disk image conversion, used by the
|
||||
// "Download Disks" feature) the same way buildVice builds VICE above.
|
||||
// Skipped entirely if nibtools-libs/<abi>/libnibtools.a already exists.
|
||||
// The tarball at <project>/res/nibtools-91344e0ee3.tar.gz is unpacked by
|
||||
// build_nibtools.sh.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
val nibtoolsLibArm = layout.projectDirectory.file("src/main/jni/nibtools-libs/arm64-v8a/libnibtools.a")
|
||||
val nibtoolsLibX86 = layout.projectDirectory.file("src/main/jni/nibtools-libs/x86_64/libnibtools.a")
|
||||
val nibtoolsTarball = layout.projectDirectory.file("../res/nibtools-91344e0ee3.tar.gz")
|
||||
|
||||
tasks.register("buildNibtools") {
|
||||
group = "build"
|
||||
description = "Cross-compile nibtools' nibconv for Android (ARM64 + x86_64)"
|
||||
|
||||
inputs.file(nibtoolsTarball)
|
||||
outputs.file(nibtoolsLibArm)
|
||||
outputs.file(nibtoolsLibX86)
|
||||
|
||||
doLast {
|
||||
if (nibtoolsLibArm.asFile.exists() && nibtoolsLibX86.asFile.exists()) {
|
||||
logger.lifecycle("nibtools already built — skipping")
|
||||
return@doLast
|
||||
}
|
||||
|
||||
val localProps = Properties().apply {
|
||||
rootProject.file("local.properties").takeIf { it.exists() }
|
||||
?.reader()?.use { load(it) }
|
||||
}
|
||||
val sdkDir = localProps.getProperty("sdk.dir")
|
||||
?: System.getenv("ANDROID_HOME")
|
||||
?: ""
|
||||
val ndkPath = localProps.getProperty("ndk.dir")
|
||||
?: System.getenv("ANDROID_NDK_HOME")
|
||||
?: System.getenv("ANDROID_NDK_ROOT")
|
||||
?: System.getenv("NDK")
|
||||
?: sdkDir.takeIf { it.isNotEmpty() }?.let { sdk ->
|
||||
file("$sdk/ndk").takeIf { it.isDirectory }
|
||||
?.listFiles()?.sorted()?.lastOrNull()?.absolutePath
|
||||
?: "$sdk/ndk-bundle".takeIf { file("$sdk/ndk-bundle").isDirectory }
|
||||
}
|
||||
?: throw GradleException(
|
||||
"Android NDK not found.\n" +
|
||||
"Install via: Android Studio → SDK Manager → SDK Tools → NDK (Side by side)"
|
||||
)
|
||||
logger.lifecycle("Building nibtools with NDK at $ndkPath …")
|
||||
|
||||
val proc = ProcessBuilder("bash", "build_nibtools.sh")
|
||||
.directory(layout.projectDirectory.dir("src/main/jni").asFile)
|
||||
.redirectErrorStream(true)
|
||||
.also { it.environment()["NDK"] = ndkPath }
|
||||
.start()
|
||||
proc.inputStream.bufferedReader().forEachLine { logger.lifecycle(it) }
|
||||
val exit = proc.waitFor()
|
||||
if (exit != 0) throw GradleException("build_nibtools.sh failed (exit $exit)")
|
||||
|
||||
layout.projectDirectory.file("src/main/jni/CMakeLists.txt")
|
||||
.asFile.setLastModified(System.currentTimeMillis())
|
||||
logger.lifecycle("nibtools build complete — CMakeLists.txt touched for re-evaluation")
|
||||
}
|
||||
}
|
||||
|
||||
// Run buildVice and buildNibtools before any CMake configure or build step.
|
||||
tasks.whenTaskAdded {
|
||||
if (name.startsWith("configureCMake") || name.startsWith("buildCMake") ||
|
||||
name.startsWith("externalNativeBuild")) {
|
||||
dependsOn("buildVice")
|
||||
dependsOn("buildNibtools")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user