Snapshot of the Umamo working tree as it is
Uploaded as-is from /home/litruv/dev/vtsmaker/umamo on 2026-11-03. 1347 files. Includes the uncommitted work in progress in :edit, :runtime, and :ui, and the untracked files under module/edit/src/jvmAndroidMain/. History is not carried over. The source repo is https://github.com/umamoorg/umamo.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// Build script for the convention plugins themselves.
|
||||
//
|
||||
// `kotlin-dsl` turns every *.gradle.kts under src/main/kotlin into a PRECOMPILED SCRIPT PLUGIN whose
|
||||
// id is the file name minus the extension — umamo.kmp-jvmandroid.gradle.kts becomes the plugin id
|
||||
// `umamo.kmp-jvmandroid`. Ordinary .kt files in the same source set compile alongside them, which is
|
||||
// where the shared types (see org.umamo.buildlogic) live.
|
||||
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
// The same JDK 21 (LTS) toolchain every module pins. Without it these scripts compile against whatever
|
||||
// JVM happens to be running the daemon, which is how the Java and Kotlin compile tasks end up
|
||||
// disagreeing about their target level.
|
||||
kotlin {
|
||||
jvmToolchain(21)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// The KMP source-set hierarchy is configured through the Kotlin Gradle Plugin's own API
|
||||
// (KotlinMultiplatformExtension, the hierarchy-template DSL), so the convention plugins compile
|
||||
// against it. This is the LIBRARY coordinate, not the plugin marker — build-logic configures KGP,
|
||||
// it never applies it; the modules still apply `alias(libs.plugins.kotlinMultiplatform)`
|
||||
// themselves. Both read the same `kotlin` version from the catalog, so the API compiled against
|
||||
// and the plugin applied can never drift.
|
||||
implementation(libs.kotlinGradlePlugin)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Settings for the build-logic INCLUDED BUILD — the home of Umamo's convention plugins.
|
||||
//
|
||||
// This is a build of its own, not a subproject: the root settings pulls it in with
|
||||
// `pluginManagement { includeBuild("gradle/build-logic") }`, so its plugins are resolvable by id
|
||||
// from every module's `plugins {}` block. That is what makes `id("umamo.kmp-jvmandroid")` read like
|
||||
// any other plugin rather than an `apply(from = …)` script with no type-safe accessors.
|
||||
//
|
||||
// Being a separate build, it inherits NOTHING from the root — not the repositories, not the version
|
||||
// catalog. Both are re-declared below, and the catalog is the SAME FILE the modules use so a
|
||||
// convention plugin can never compile against a different Kotlin than the one the modules apply.
|
||||
|
||||
rootProject.name = "build-logic"
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
// The Kotlin Gradle Plugin publishes to both; the portal is what resolves plugin markers.
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
// The one catalog, reached by relative path (this file sits in gradle/build-logic, the catalog in
|
||||
// gradle/). Gradle's automatic `gradle/libs.versions.toml` discovery is relative to THIS build's
|
||||
// root, which would be gradle/build-logic/gradle/ — hence the explicit `from`.
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from(files("../libs.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package org.umamo.buildlogic
|
||||
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* One path-valued system property a module forwards to its test JVMs.
|
||||
*
|
||||
* @param String name The system property name, e.g. "cmo3.sample".
|
||||
* @param String? corpusRelativeDefault A module-specific default, relative to test/corpus, or null to
|
||||
* take whatever [sharedCorpusDefault] has for this name (which may itself be nothing,
|
||||
* leaving the property explicit-`-D`-only).
|
||||
*/
|
||||
data class CorpusSampleProperty(
|
||||
val name: String,
|
||||
val corpusRelativeDefault: String?,
|
||||
)
|
||||
|
||||
/**
|
||||
* Declares which corpus-backed system properties a module's test JVMs receive.
|
||||
*
|
||||
* Registered by the `umamo.test-corpus` convention plugin as `umamoTestCorpus`; see that plugin for
|
||||
* the resolution rules, and org.umamo.buildlogic.sharedCorpusDefault for the shared default table.
|
||||
*/
|
||||
abstract class TestCorpusExtension {
|
||||
/** The declared path-valued properties, in declaration order. Read by the convention plugin. */
|
||||
val sampleProperties: MutableList<CorpusSampleProperty> = mutableListOf()
|
||||
|
||||
/** The declared plain flags. Read by the convention plugin. */
|
||||
val flagProperties: MutableList<String> = mutableListOf()
|
||||
|
||||
/** The test JVM heap, or null to leave Gradle's default. Read by the convention plugin. */
|
||||
var testMaxHeap: String? = null
|
||||
private set
|
||||
|
||||
/**
|
||||
* Forwards path-valued sample properties, defaulted from the shared corpus table.
|
||||
*
|
||||
* A name the shared table has no entry for is still forwarded — it simply has no default, so it
|
||||
* only reaches the test JVM when an explicit `-D` is passed.
|
||||
*
|
||||
* @param String propertyNames The system property names.
|
||||
*/
|
||||
fun sample(vararg propertyNames: String) {
|
||||
for (propertyName in propertyNames) {
|
||||
sampleProperties += CorpusSampleProperty(propertyName, null)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forwards one path-valued sample property with a default this module alone wants.
|
||||
*
|
||||
* Use this when the shared table's answer is wrong HERE — :ui's moc3.sample is the case: the other
|
||||
* modules deliberately leave it explicit-only, and giving it a table entry would silently switch
|
||||
* their gated tests on.
|
||||
*
|
||||
* @param String propertyName The system property name.
|
||||
* @param String corpusRelativePath The default, relative to test/corpus. File or directory; it is
|
||||
* used only when it exists, so a partial corpus still self-skips.
|
||||
*/
|
||||
fun sampleWithCorpusDefault(
|
||||
propertyName: String,
|
||||
corpusRelativePath: String,
|
||||
) {
|
||||
sampleProperties += CorpusSampleProperty(propertyName, corpusRelativePath)
|
||||
}
|
||||
|
||||
/**
|
||||
* Forwards on/off flags verbatim — no path resolution, no existence check.
|
||||
*
|
||||
* A flag is a switch, not a location (`-Dcmo3.generate=true`, `-Dumamo.requireGl=true`), so putting
|
||||
* one through the sample path would reject it for not naming a file that exists. Forwarding is
|
||||
* still the part that matters: a flag the build forgets to pass through is a test that reads a
|
||||
* property nobody set and returns immediately, reporting PASSED while doing nothing.
|
||||
*
|
||||
* @param String propertyNames The system property names.
|
||||
*/
|
||||
fun flag(vararg propertyNames: String) {
|
||||
flagProperties += propertyNames
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the heap for this module's test JVMs.
|
||||
*
|
||||
* @param String size A JVM heap size, e.g. "4g".
|
||||
*/
|
||||
fun maxHeap(size: String) {
|
||||
testMaxHeap = size
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The shared corpus default for [propertyName], or null when the table has no entry for it.
|
||||
*
|
||||
* These are the defaults that mean the same thing in every module, so they live in one place rather
|
||||
* than being re-derived per build script (which is how :interop and :render came to disagree with
|
||||
* :format about whether an explicit `-D` gets checked at all).
|
||||
*
|
||||
* @param File corpusDirectory The local golden corpus root. Gitignored, so absent on CI and on a
|
||||
* fresh clone — every lookup here is allowed to come back null.
|
||||
* @param String propertyName The system property name.
|
||||
* @return String? The default value, or null when there is none.
|
||||
*/
|
||||
fun sharedCorpusDefault(
|
||||
corpusDirectory: File,
|
||||
propertyName: String,
|
||||
): String? {
|
||||
if (!corpusDirectory.isDirectory) {
|
||||
return null
|
||||
}
|
||||
return when (propertyName) {
|
||||
// Pinned to one model on purpose, for two independent reasons: :format's facade/CAFF/document
|
||||
// tests assert exact counts (180 image resources, 926 CAFF entries, 158 import PIs) that only
|
||||
// this model satisfies, and it is the corpus model that actually carries glue affecters, which
|
||||
// is what makes :render's glue gates meaningful rather than vacuously green.
|
||||
"cmo3.sample" -> corpusDirectory.resolve("cmo3/EricaTamamo.cmo3").takeIf { it.isFile }?.absolutePath
|
||||
|
||||
// Every .cmo3 in the corpus, spanning Cubism 3.x/4.x/5.3. The cross-version gate wants the
|
||||
// whole set, and ModelGenerator wants it for the same reason its own docblock gives: the
|
||||
// generated model is the UNION over every sample, so a field or enum constant that only one
|
||||
// project exercises still gets covered. Generating from one sample would silently drop the rest.
|
||||
"cmo3.probe", "cmo3.gensample" ->
|
||||
corpusDirectory
|
||||
.resolve("cmo3")
|
||||
.listFiles { candidate -> candidate.isFile && candidate.extension == "cmo3" }
|
||||
?.sortedBy { it.name }
|
||||
?.joinToString(",") { it.absolutePath }
|
||||
?.takeIf { it.isNotEmpty() }
|
||||
|
||||
// The whole moc3 tree — the decode/lowering/bake/probe gates walk it.
|
||||
"moc3.samples" -> corpusDirectory.resolve("moc3").takeIf { it.isDirectory }?.absolutePath
|
||||
|
||||
// Deliberately absent, and worth stating: `moc3.sample` (singular). :ui defaults it to the one
|
||||
// corpus family that is complete on disk, while :interop and :render want it explicit-only —
|
||||
// a table entry here would switch their gated tests on as a side effect.
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves [sampleProperty] to the value handed to the test JVM, or null to leave the test skipping.
|
||||
*
|
||||
* Two ways a path is found, in order:
|
||||
* 1. An explicit `-D` on the Gradle command line. A RELATIVE value resolves against the REPO ROOT —
|
||||
* not the test JVM's working directory, which is the module. That distinction is the whole point:
|
||||
* a gated test that cannot find its sample does not fail, it prints and returns, so it reports
|
||||
* PASSED while doing nothing. A relative path therefore used to disable the gate in total silence.
|
||||
* An explicit path that resolves to nothing fails the build outright instead.
|
||||
* 2. The local golden corpus, when present — the module-specific default if it declared one, else the
|
||||
* shared table. This is what makes the mandatory CMO3 round-trip gate run BY DEFAULT for anyone
|
||||
* who has the corpus, rather than only when they remember the flag.
|
||||
*
|
||||
* Absent entirely (a fresh clone, CI) → null, the tests self-skip, and the build stays green without a
|
||||
* multi-gigabyte corpus in git. That is deliberate; CI passes no sample flags.
|
||||
*
|
||||
* @param File repositoryRoot The repo root, which relative `-D` values resolve against.
|
||||
* @param File corpusDirectory The local golden corpus root (test/corpus).
|
||||
* @param CorpusSampleProperty sampleProperty The property being resolved.
|
||||
* @return String? The absolute path (or comma-separated paths), or null.
|
||||
*/
|
||||
fun resolveCorpusSample(
|
||||
repositoryRoot: File,
|
||||
corpusDirectory: File,
|
||||
sampleProperty: CorpusSampleProperty,
|
||||
): String? {
|
||||
val explicitValue =
|
||||
System.getProperty(sampleProperty.name)
|
||||
?: return moduleOrSharedDefault(corpusDirectory, sampleProperty)
|
||||
|
||||
// Some properties (cmo3.probe) carry a comma-separated list; resolve each element. File.resolve
|
||||
// returns an absolute argument unchanged, so this handles both forms.
|
||||
val resolvedValue =
|
||||
explicitValue
|
||||
.split(',')
|
||||
.filter { it.isNotBlank() }
|
||||
.joinToString(",") { path -> repositoryRoot.resolve(path.trim()).absolutePath }
|
||||
// Fail loudly rather than let the gated test skip-and-pass on a typo.
|
||||
for (path in resolvedValue.split(',')) {
|
||||
require(File(path).exists()) {
|
||||
"-D${sampleProperty.name}=$explicitValue resolves to '$path', which does not exist. " +
|
||||
"Relative values resolve against the repo root ($repositoryRoot)."
|
||||
}
|
||||
}
|
||||
return resolvedValue
|
||||
}
|
||||
|
||||
/**
|
||||
* The default for [sampleProperty]: its own corpus-relative path when it declared one, else the table.
|
||||
*
|
||||
* @param File corpusDirectory The local golden corpus root.
|
||||
* @param CorpusSampleProperty sampleProperty The property being defaulted.
|
||||
* @return String? The absolute path, or null when there is no default or no corpus.
|
||||
*/
|
||||
private fun moduleOrSharedDefault(
|
||||
corpusDirectory: File,
|
||||
sampleProperty: CorpusSampleProperty,
|
||||
): String? {
|
||||
val corpusRelativeDefault =
|
||||
sampleProperty.corpusRelativeDefault
|
||||
?: return sharedCorpusDefault(corpusDirectory, sampleProperty.name)
|
||||
return corpusDirectory.resolve(corpusRelativeDefault).takeIf { it.exists() }?.absolutePath
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Convention plugin: wire a module's iosArm64 compiles into `check`, main AND test.
|
||||
//
|
||||
// Neither task arrives on its own. `check` reaches a target's compile only by way of a runnable test
|
||||
// task, and iosArm64 is a DEVICE target with none — so the commonMain-purity guarantee a module
|
||||
// carries an Apple target FOR only fired when someone typed the task name, and `./gradlew check`
|
||||
// passed straight over a commonMain `java.*` leak exactly as if the target did not exist.
|
||||
//
|
||||
// The test source set matters as much as main, and is the half that actually broke: KraReader sat in
|
||||
// commonMain importing java.util.zip while a commonTest beside it referenced a symbol only it
|
||||
// declared. compileKotlinIosArm64 was green throughout — main compiled fine — and CI failed on
|
||||
// compileTestKotlinIosArm64, a task no local run touched. commonTest has to build for every target
|
||||
// commonMain does, so it gets the same gate.
|
||||
|
||||
// `withId` so the module's `plugins {}` block order does not matter — `check` comes from the base
|
||||
// plugin that Kotlin Multiplatform brings with it, so it exists by the time this fires.
|
||||
plugins.withId("org.jetbrains.kotlin.multiplatform") {
|
||||
tasks.named("check") {
|
||||
dependsOn("compileKotlinIosArm64", "compileTestKotlinIosArm64")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// Convention plugin: the `jvmAndroidMain` source-set group, shared by the two JVM-based targets
|
||||
// (desktop JVM + Android/ART).
|
||||
//
|
||||
// Some code is JVM-API-bound but must reach BOTH those targets — the JDOM + Kotlin-reflection CMO3
|
||||
// serializer in :format above all, and everything layered on it (:interop's export lowering, :ui's
|
||||
// document/file layer and app shell). commonMain cannot hold it and duplicating it into jvmMain +
|
||||
// androidMain would be two copies of the same file, so it lives in src/jvmAndroidMain and is shared
|
||||
// verbatim.
|
||||
//
|
||||
// This block was copy-pasted across four build scripts and marked "[kmp-jvmandroid] keep identical" —
|
||||
// which is the shape of a convention plugin written out longhand. Applied as
|
||||
// `id("umamo.kmp-jvmandroid")`, after the module applies the Kotlin Multiplatform plugin.
|
||||
|
||||
// The hierarchy-template DSL (`applyDefaultHierarchyTemplate {}` with a describe block) is still
|
||||
// marked experimental in KGP. The module build scripts opted in implicitly by living in a Gradle
|
||||
// script; say it out loud here instead of emitting five warnings per compile.
|
||||
@file:OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
|
||||
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
// `withId` rather than a bare `configure`, so the order of the module's `plugins {}` block does not
|
||||
// matter: whether Kotlin Multiplatform is applied before or after this plugin, the hierarchy is set up
|
||||
// the moment it arrives.
|
||||
plugins.withId("org.jetbrains.kotlin.multiplatform") {
|
||||
extensions.configure<KotlinMultiplatformExtension> {
|
||||
// Using a template group (rather than raw `dependsOn`) keeps the auto-wired commonMain edges
|
||||
// intact and avoids the "default hierarchy not applied" warning.
|
||||
applyDefaultHierarchyTemplate {
|
||||
common {
|
||||
group("jvmAndroid") {
|
||||
withJvm()
|
||||
withAndroidTarget()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The group's withAndroidTarget() above matches the LEGACY android target, not AGP 9's new KMP
|
||||
// android-library target (com.android.kotlin.multiplatform.library, which is what every module
|
||||
// here applies) — so androidMain never inherits the jvmAndroid group and cannot see its
|
||||
// declarations or its actuals. Wire the edge explicitly. (withJvm() does match, which is why the
|
||||
// JVM target compiles fine and the breakage shows up as an Android-only failure.)
|
||||
//
|
||||
// Keyed on whichever of the two source sets is configured LAST, because their creation order is
|
||||
// not ours to pick: androidMain arrives with the android target, jvmAndroidMain when the
|
||||
// hierarchy template is applied over the registered targets. Checking both directions means the
|
||||
// edge lands either way, and `dependsOn` is set-valued so arriving twice is harmless.
|
||||
val kotlinSourceSets = sourceSets
|
||||
kotlinSourceSets.configureEach {
|
||||
val configuredSourceSet = this
|
||||
when (configuredSourceSet.name) {
|
||||
"jvmAndroidMain" ->
|
||||
kotlinSourceSets.findByName("androidMain")?.dependsOn(configuredSourceSet)
|
||||
|
||||
"androidMain" ->
|
||||
kotlinSourceSets.findByName("jvmAndroidMain")?.let { jvmAndroidMain ->
|
||||
configuredSourceSet.dependsOn(jvmAndroidMain)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Convention plugin: forward the golden corpus and its `-D` overrides to a module's test JVMs.
|
||||
//
|
||||
// Five build scripts each grew their own copy of this — the same corpusDefaultFor / sample-resolution
|
||||
// pair, drifted three different ways (:interop and :edit forwarded an explicit `-D` verbatim while
|
||||
// :format and :render resolved and existence-checked it; the corpus default table disagreed about
|
||||
// which properties even had one). Since the failure mode of getting it wrong is a gated test that
|
||||
// reports PASSED while doing nothing, one implementation is worth more here than in most places.
|
||||
//
|
||||
// A module declares what it wants and nothing else:
|
||||
//
|
||||
// umamoTestCorpus {
|
||||
// maxHeap("4g")
|
||||
// sample("cmo3.sample", "cmo3.probe")
|
||||
// sampleWithCorpusDefault("moc3.sample", "moc3/modelA/modelA.moc3")
|
||||
// flag("umamo.requireGl")
|
||||
// }
|
||||
//
|
||||
// Resolution rules (explicit `-D` wins, corpus default second, else the test self-skips) are in
|
||||
// org.umamo.buildlogic.resolveCorpusSample, and the shared default table in
|
||||
// org.umamo.buildlogic.sharedCorpusDefault. Read those before adding a property.
|
||||
|
||||
import org.umamo.buildlogic.TestCorpusExtension
|
||||
import org.umamo.buildlogic.resolveCorpusSample
|
||||
|
||||
val umamoTestCorpus = extensions.create<TestCorpusExtension>("umamoTestCorpus")
|
||||
|
||||
// Captured as plain Files so the configuration cache stores values, not a project reference.
|
||||
val repositoryRoot = rootDir
|
||||
|
||||
/** The local golden corpus root. Gitignored, so absent on CI and on a fresh clone. */
|
||||
val corpusDirectory = rootDir.resolve("test/corpus")
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
// Read at task-realization time, which is after the module's `umamoTestCorpus { }` block has run.
|
||||
umamoTestCorpus.testMaxHeap?.let { heapSize ->
|
||||
maxHeapSize = heapSize
|
||||
}
|
||||
for (sampleProperty in umamoTestCorpus.sampleProperties) {
|
||||
resolveCorpusSample(repositoryRoot, corpusDirectory, sampleProperty)?.let { resolvedValue ->
|
||||
systemProperty(sampleProperty.name, resolvedValue)
|
||||
}
|
||||
}
|
||||
for (flagName in umamoTestCorpus.flagProperties) {
|
||||
System.getProperty(flagName)?.let { flagValue ->
|
||||
systemProperty(flagName, flagValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user