Add an original-asset minigame with modern controls, independent movement and tool animations, randomized safe beacon layouts and 2D drone patrols. Distribute the canonical project through installed knowledge and exercise compiled cartridges and animation boundaries. Fix lowering of admitted sibling constants and add a regression test. Focused compiler, installed knowledge and direct native checks passed; user tested and approved. Full make verify remains blocked by sandbox sysctl restrictions in ACP tests. WRK-0022 remains open.
112 lines
6.5 KiB
Kotlin
112 lines
6.5 KiB
Kotlin
import java.security.MessageDigest
|
|
|
|
plugins {
|
|
id("gradle.java-library-conventions")
|
|
}
|
|
|
|
dependencies {
|
|
implementation(project(":prometeu-infra"))
|
|
|
|
implementation(project(":prometeu-compiler:prometeu-frontend-api"))
|
|
implementation(project(":prometeu-compiler:prometeu-compiler-core"))
|
|
}
|
|
|
|
// Build-time projection of owner-maintained sources; no second normative copy is edited by Studio.
|
|
val pbsSpecs = rootProject.layout.projectDirectory.dir("docs/specs/compiler-languages/pbs")
|
|
val pbsResources = layout.projectDirectory.dir("src/main/resources")
|
|
val beaconWorkshop = rootProject.layout.projectDirectory.dir("test-projects/beacon-workshop")
|
|
val beaconFiles = fileTree(beaconWorkshop) {
|
|
include("src/**", "assets/**", "tools/*.py", "*.md", "prometeu.json", ".gitignore")
|
|
exclude("**/__pycache__/**")
|
|
}
|
|
val generatePbsKnowledge by tasks.registering(Sync::class) {
|
|
from(pbsSpecs) { include("*.md"); into("pbs-knowledge/specs") }
|
|
from(beaconFiles) { into("pbs-knowledge/examples/game/1/beacon-workshop") }
|
|
into(layout.buildDirectory.dir("generated/pbsKnowledge"))
|
|
inputs.files(fileTree(pbsResources) { include("game/stdlib/**/*.pbs", "game/stdlib/**/*.barrel", "pbs-knowledge/examples/**") })
|
|
inputs.files(beaconFiles)
|
|
doLast {
|
|
val entries = mutableListOf<Map<String, Any?>>()
|
|
fun entry(id: String, title: String, kind: String, resource: String, source: File, sdk: Int? = null, target: String? = null) {
|
|
check(source.isFile) { "Missing PBS reference: $source" }
|
|
val digest = MessageDigest.getInstance("SHA-256").digest(source.readBytes())
|
|
.joinToString("") { "%02x".format(it) }
|
|
entries.add(linkedMapOf("id" to id, "title" to title, "kind" to kind,
|
|
"resource" to resource, "sha256" to digest, "sdkVersion" to sdk, "target" to target))
|
|
}
|
|
// Published filename IDs alias the single canonical numbered resource.
|
|
val legacyReferenceIds = mapOf(
|
|
"14" to "typed-arrays-and-optional-execution.md",
|
|
"15" to "first-class-functions-and-captures.md",
|
|
"16" to "generic-contracts.md",
|
|
"17" to "generic-structs-and-free-functions.md",
|
|
"18" to "input-and-existing-type-runtime-alignment.md",
|
|
"19" to "service-constants-and-runtime-math.md",
|
|
"20" to "runtime-random-integration.md",
|
|
"21" to "sdk-list-and-cursor.md",
|
|
"22" to "sdk-linked-and-cursor.md",
|
|
"23" to "sdk-set-and-identity.md",
|
|
"24" to "sdk-map-and-keyval.md",
|
|
"25" to "sdk-stack-and-queue.md"
|
|
)
|
|
val sources = checkNotNull(pbsSpecs.asFile.listFiles()) { "Missing canonical PBS specifications: $pbsSpecs" }
|
|
.filter { it.extension == "md" }.sortedBy { it.name }
|
|
check(legacyReferenceIds.keys.all { chapter -> sources.any { it.name.substringBefore(". ") == chapter } }) {
|
|
"Missing canonical target for a published PBS reference ID"
|
|
}
|
|
sources.forEach { source ->
|
|
val chapter = source.name.substringBefore(". ")
|
|
val quickstart = source.name == "README.md"
|
|
val title = source.readLines().first { it.startsWith("# ") }.removePrefix("# ")
|
|
val kind = if (quickstart) "QUICKSTART" else if (chapter == "3") "SYNTAX" else "SEMANTICS"
|
|
val resource = "pbs-knowledge/specs/${source.name}"
|
|
entry(if (quickstart) "pbs:quickstart" else "pbs:spec:$chapter",
|
|
title, kind, resource, source)
|
|
legacyReferenceIds[chapter]?.let { legacy ->
|
|
entry("pbs:spec:$legacy", title, kind, resource, source)
|
|
}
|
|
}
|
|
fileTree(pbsResources) { include("game/stdlib/**/*.pbs", "game/stdlib/**/*.barrel") }.files.sorted().forEach { source ->
|
|
val path = source.relativeTo(pbsResources.asFile).invariantSeparatorsPath
|
|
val parts = path.split('/')
|
|
val sdk = parts[2].toInt()
|
|
val module = parts.drop(3).dropLast(1).joinToString(":")
|
|
entry("pbs:sdk:game:$sdk:${parts.drop(3).joinToString("/")}", "PBS SDK $sdk @$module / ${source.name}",
|
|
"SDK", path, source, sdk, "Game")
|
|
}
|
|
fileTree(pbsResources.dir("pbs-knowledge/examples/game/1")) { include("**/*") }.files.sorted().forEach { source ->
|
|
val relative = source.relativeTo(pbsResources.dir("pbs-knowledge/examples/game/1").asFile).invariantSeparatorsPath
|
|
entry("pbs:example:game:1:$relative", "PBS Game / SDK 1 example: $relative", "EXAMPLE",
|
|
"pbs-knowledge/examples/game/1/$relative", source, 1, "Game")
|
|
}
|
|
// Binary glyphs travel as resources, never as UTF-8 reference payloads.
|
|
val distributed = beaconFiles.files.sorted().map { source ->
|
|
val relative = source.relativeTo(beaconWorkshop.asFile).invariantSeparatorsPath
|
|
val resource = "pbs-knowledge/examples/game/1/beacon-workshop/$relative"
|
|
if (source.extension != "png") {
|
|
entry("pbs:example:game:1:beacon-workshop/$relative", "Beacon Workshop / $relative",
|
|
"EXAMPLE", resource, source, 1, "Game")
|
|
}
|
|
mapOf("path" to relative, "resource" to resource,
|
|
"sha256" to MessageDigest.getInstance("SHA-256").digest(source.readBytes())
|
|
.joinToString("") { "%02x".format(it) })
|
|
}
|
|
val inventory = destinationDir.resolve("pbs-knowledge/examples/game/1/beacon-workshop/distribution.json")
|
|
inventory.writeText(groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(
|
|
mapOf("schemaVersion" to 1, "files" to distributed))))
|
|
entry("pbs:example:game:1:beacon-workshop/distribution.json", "Beacon Workshop / packaged files",
|
|
"EXAMPLE", "pbs-knowledge/examples/game/1/beacon-workshop/distribution.json", inventory, 1, "Game")
|
|
check(entries.map { it["id"] }.distinct().size == entries.size) { "Duplicate PBS reference IDs" }
|
|
destinationDir.resolve("pbs-knowledge/index.json").writeText(groovy.json.JsonOutput.prettyPrint(
|
|
groovy.json.JsonOutput.toJson(mapOf("schemaVersion" to 1, "owner" to "pbs", "references" to entries))))
|
|
}
|
|
}
|
|
sourceSets.main { resources.srcDir(generatePbsKnowledge) }
|
|
|
|
tasks.named<ProcessResources>("processResources") {
|
|
from(rootProject.layout.projectDirectory.dir("docs/vm-arch")) {
|
|
include("INTRINSICS.csv", "BUILTIN_CONSTANTS.csv", "runtime-catalog.properties")
|
|
into("runtime-catalog/pbs-sdk")
|
|
}
|
|
}
|