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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// Shared build-target resolution. Applied via `apply(from = …)` by every module that bundles
|
||||
// platform-specific LWJGL natives — :desktop and :render today. It works out the "<os>-<arch>"
|
||||
// token the build is targeting (defaulting to the host), honoring -Pumamo.target to cross-resolve
|
||||
// so a Windows-native artifact can be produced from, say, WSL2 Linux:
|
||||
//
|
||||
// ./gradlew :desktop:packageUberJarForCurrentOS -Pumamo.target=windows-x64
|
||||
//
|
||||
// then launched from the Windows side. This only swaps which prebuilt natives get bundled — JVM
|
||||
// bytecode is platform-independent, so there is no real cross-compiler involved. (jpackage
|
||||
// installers like .msi/.dmg must still be produced ON the target OS; only a runnable uber-jar is
|
||||
// portable this way.)
|
||||
//
|
||||
// The result is handed back to the applying module through two extra properties:
|
||||
// umamoBuildTarget — the resolved "<os>-<arch>" string (e.g. "windows-x64")
|
||||
// umamoLwjglNatives — the matching LWJGL natives classifier (e.g. "natives-windows")
|
||||
//
|
||||
// Why centralize: both :desktop and :render bundle LWJGL natives, and host-detection logic living in
|
||||
// only one place means the two can never drift apart — otherwise a Windows build could bundle one
|
||||
// module's Linux natives and silently fail to launch. The Compose/Skiko side stays in :desktop alone,
|
||||
// because the `compose.desktop.<target>` accessors only resolve inside a `dependencies {}` block —
|
||||
// :desktop reads umamoBuildTarget from here and maps it there.
|
||||
|
||||
val osName = System.getProperty("os.name").lowercase()
|
||||
val osArch = System.getProperty("os.arch").lowercase()
|
||||
val hostOs =
|
||||
when {
|
||||
osName.contains("linux") -> "linux"
|
||||
osName.contains("mac") || osName.contains("darwin") -> "macos"
|
||||
else -> "windows"
|
||||
}
|
||||
val hostArch =
|
||||
when {
|
||||
osArch.contains("aarch64") || osArch.contains("arm64") -> "arm64"
|
||||
else -> "x64"
|
||||
}
|
||||
// EN: Skiko/Compose ships no windows-arm64 build; Windows-on-ARM runs the x64 artifact emulated.
|
||||
val hostTarget =
|
||||
if (hostOs == "windows" && hostArch == "arm64") {
|
||||
"windows-x64"
|
||||
} else {
|
||||
"$hostOs-$hostArch"
|
||||
}
|
||||
|
||||
// EN: `findProperty` reads a Gradle project property (`-Pkey=value` on the command line, or a line in
|
||||
// gradle.properties); it returns null when unset, so `?:` falls back to the host. The override wins.
|
||||
val requestedTarget = (findProperty("umamo.target") as String?)?.lowercase()?.trim()
|
||||
val resolvedTarget = requestedTarget ?: hostTarget
|
||||
|
||||
val recognizedTargets = listOf("linux-x64", "linux-arm64", "windows-x64", "macos-x64", "macos-arm64")
|
||||
require(resolvedTarget in recognizedTargets) {
|
||||
"Unknown -Pumamo.target='$resolvedTarget'. Recognized: ${recognizedTargets.joinToString(", ")}."
|
||||
}
|
||||
if (requestedTarget != null) {
|
||||
logger.lifecycle("[${project.path}] resolving natives for $resolvedTarget (build host is $hostTarget)")
|
||||
}
|
||||
|
||||
// Release packaging must never cross-resolve. Unlike the uber jar, a jpackage app image jlinks
|
||||
// the HOST JDK into itself, so a mismatched -Pumamo.target bundles one platform's Skiko/LWJGL
|
||||
// natives inside another platform's runtime — an artifact that runs nowhere, and one nothing
|
||||
// downstream can detect. The release workflow passes -Pumamo.target explicitly (so artifact
|
||||
// names are a function of the matrix rather than of what the runner reported) AND this flag, so
|
||||
// an unexpected runner os.arch fails the build instead of shipping a broken download. Same
|
||||
// shape as -Dumamo.requireGl in the GL tests: opt-in, and only CI opts in.
|
||||
val requireTargetIsHost = (findProperty("umamo.requireTargetIsHost") as String?).toBoolean()
|
||||
require(!requireTargetIsHost || resolvedTarget == hostTarget) {
|
||||
"-Pumamo.requireTargetIsHost=true, but -Pumamo.target='$resolvedTarget' is not the build host " +
|
||||
"'$hostTarget'. An app image jlinks the host JDK, so cross-resolving natives here produces " +
|
||||
"an artifact that runs nowhere."
|
||||
}
|
||||
|
||||
// EN: LWJGL publishes its per-platform natives under these classifiers (org.lwjgl:lwjgl::natives-windows, …).
|
||||
val lwjglNativesClassifier =
|
||||
when (resolvedTarget) {
|
||||
"linux-x64" -> "natives-linux"
|
||||
"linux-arm64" -> "natives-linux-arm64"
|
||||
"windows-x64" -> "natives-windows"
|
||||
"macos-x64" -> "natives-macos"
|
||||
"macos-arm64" -> "natives-macos-arm64"
|
||||
else -> error("unreachable: resolvedTarget validated above")
|
||||
}
|
||||
|
||||
// EN: `extra` is Gradle's per-project untyped property bag; the applying module reads these back with
|
||||
// `extra["umamoBuildTarget"] as String`. This is how an `apply(from =)` script returns values.
|
||||
extra["umamoBuildTarget"] = resolvedTarget
|
||||
extra["umamoLwjglNatives"] = lwjglNativesClassifier
|
||||
@@ -0,0 +1,2 @@
|
||||
#This file is generated by updateDaemonJvm
|
||||
toolchainVersion=21
|
||||
@@ -0,0 +1,113 @@
|
||||
# Version catalog — single source of truth for dependency + plugin versions.
|
||||
# バージョンカタログ:依存とプラグインのバージョンを一元管理する。
|
||||
# Why: Gradle's typed `libs.*` accessors beat scattered string versions in each
|
||||
# build script — one place to bump, compile-checked references.
|
||||
[versions]
|
||||
kotlin = "2.4.20"
|
||||
agp = "9.3.0"
|
||||
composeMultiplatform = "1.11.1"
|
||||
ktlint = "14.2.0"
|
||||
lwjgl = "3.4.2"
|
||||
androidxActivity = "1.13.0"
|
||||
# JDOM 1.x (package org.jdom) — the exact XML library the Cubism editor uses. Pinned to 1.1.x
|
||||
# so XMLOutputter + Format.getPrettyFormat() reproduce main.xml byte-for-byte; JDOM2 (org.jdom2)
|
||||
# would re-order/re-format and break the round-trip. See docs/formats/CMO3.md §3.
|
||||
jdom = "1.1.3"
|
||||
kotlinxSerialization = "1.11.0"
|
||||
# okio — the de-facto multiplatform filesystem (Kotlin stdlib has no common File). Backs :storage's
|
||||
# file IO on desktop + Android with one API, and FakeFileSystem makes :settings testable with no disk.
|
||||
okio = "3.17.0"
|
||||
# kotlinx-coroutines — for :settings' change-event SharedFlow (the reactive spine the UI/History want).
|
||||
kotlinxCoroutines = "1.11.0"
|
||||
# kotlinx-datetime — the local wall clock the CAFF zip timestamp needs. The Kotlin stdlib has a common
|
||||
# Clock but no time ZONE, and a DOS timestamp is local time, so this is the smallest thing that closes
|
||||
# the gap without reintroducing an expect/actual. See docs/formats/CMO3.md §1.
|
||||
kotlinxDatetime = "0.8.0"
|
||||
# FileKit — multiplatform native file pickers (desktop + Android one API). Replaces the AWT FileDialog
|
||||
# in :storage so the picker is OS-native everywhere and Android SAF comes for free. See module/storage.
|
||||
filekit = "0.14.2"
|
||||
# JNA — desktop-only FFI for small Win32 calls (e.g. the DWM title-bar tint via dwmapi.dll). Already on
|
||||
# the desktop runtime classpath transitively (FileKit's native dialogs use it); pinned to FileKit's
|
||||
# version and declared explicitly so :desktop can compile against it without a resolution bump.
|
||||
jna = "5.19.1"
|
||||
# SQLDelight — typed access to the embedded SQLite layer table in a .clip file.
|
||||
sqldelight = "2.3.2"
|
||||
# poly2tri — constrained Delaunay triangulation (JVM/Android). Used by Add Vertex Accept so closed
|
||||
# draft rings zigzag instead of cascading ears along the boundary.
|
||||
poly2tri = "0.7.0"
|
||||
|
||||
# Android SDK levels (referenced from each android target).
|
||||
android-compileSdk = "37"
|
||||
android-minSdk = "26"
|
||||
android-targetSdk = "37"
|
||||
|
||||
[libraries]
|
||||
# --- LWJGL (desktop GPU): managed via the BOM so module versions stay aligned. ---
|
||||
lwjgl-bom = { module = "org.lwjgl:lwjgl-bom", version.ref = "lwjgl" }
|
||||
lwjgl-core = { module = "org.lwjgl:lwjgl" }
|
||||
lwjgl-opengl = { module = "org.lwjgl:lwjgl-opengl" }
|
||||
# GLFW: a hidden-window GL context — the desktop app's offscreen viewport renderer and the
|
||||
# :render GPU-vs-CPU transform-feedback test both create their contexts through it.
|
||||
lwjgl-glfw = { module = "org.lwjgl:lwjgl-glfw" }
|
||||
|
||||
# AndroidX Activity + Compose interop: provides ComponentActivity.setContent { } for the
|
||||
# Android app entrypoint (not covered by the Compose MP `compose.*` accessors).
|
||||
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidxActivity" }
|
||||
|
||||
# Compose Multiplatform artifacts as direct coordinates. The `compose.*` Gradle-plugin aliases
|
||||
# (compose.runtime, compose.ui, …) were deprecated in CMP 1.10/1.11 — the warning literally says
|
||||
# "Specify dependency directly". These org.jetbrains.compose artifacts still carry Gradle module
|
||||
# metadata that redirects to androidx.compose.* on the Android target, so per-target resolution is
|
||||
# unchanged; only the alias DSL went away. Kebab names map to nested accessors, so the call sites
|
||||
# read identically: `libs.compose.runtime`, `libs.compose.components.resources`, etc.
|
||||
compose-runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "composeMultiplatform" }
|
||||
compose-foundation = { module = "org.jetbrains.compose.foundation:foundation", version.ref = "composeMultiplatform" }
|
||||
compose-ui = { module = "org.jetbrains.compose.ui:ui", version.ref = "composeMultiplatform" }
|
||||
# Compose UI testing. The keyform sheet's lane resolves tap-versus-drag from one raw pointer stream, which
|
||||
# no unit test over pure functions can cover - only a real composition with real pointer input can.
|
||||
compose-ui-test = { module = "org.jetbrains.compose.ui:ui-test", version.ref = "composeMultiplatform" }
|
||||
compose-ui-test-junit4 = { module = "org.jetbrains.compose.ui:ui-test-junit4", version.ref = "composeMultiplatform" }
|
||||
compose-components-resources = { module = "org.jetbrains.compose.components:components-resources", version.ref = "composeMultiplatform" }
|
||||
|
||||
# JDOM 1.x — main.xml read/write for the CMO3 serializer (jvmAndroidMain; works on Android via JAXP).
|
||||
jdom = { module = "org.jdom:jdom", version.ref = "jdom" }
|
||||
kotlinxSerializationJson = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
|
||||
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }
|
||||
# okio's in-memory FileSystem for tests — :settings unit tests run with no real disk.
|
||||
okio-fakefilesystem = { module = "com.squareup.okio:okio-fakefilesystem", version.ref = "okio" }
|
||||
kotlinxCoroutinesCore = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
|
||||
kotlinxDatetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" }
|
||||
kotlinxCoroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" }
|
||||
# FileKit dialogs — open/save pickers (FileKit.openFilePicker/openFileSaver) plus the PlatformFile type
|
||||
# the FilePicker contract returns. Pulls filekit-core transitively; multiplatform (jvm + android).
|
||||
filekitDialogs = { module = "io.github.vinceglb:filekit-dialogs", version.ref = "filekit" }
|
||||
# JNA — small Win32 FFI from :desktop (DWM caption-color tinting). See the version note above.
|
||||
jna = { module = "net.java.dev.jna:jna", version.ref = "jna" }
|
||||
# SQLDelight SQLite drivers: JVM JdbcSqliteDriver
|
||||
sqldelightSqliteDriver = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqldelight" }
|
||||
sqldelightAndroidDriver = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||
# SQLDelight's Kotlin/Native driver (SQLiter), for CLIP on iPadOS — Clip Studio Paint runs on iPad,
|
||||
# so CLIP ingest is the native path that actually matters. Publishes iosArm64 alongside the rest.
|
||||
sqldelightNativeDriver = { module = "app.cash.sqldelight:native-driver", version.ref = "sqldelight" }
|
||||
|
||||
# The Kotlin Gradle Plugin as a LIBRARY coordinate, not a plugin marker: gradle/build-logic's
|
||||
# convention plugins CONFIGURE KMP (KotlinMultiplatformExtension, the source-set hierarchy DSL) rather
|
||||
# than applying it, so they need its API on their compile classpath. Same `kotlin` version ref the
|
||||
# modules apply, so what build-logic compiles against and what the modules get can never drift.
|
||||
kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
poly2tri = { module = "org.orbisgis:poly2tri", version.ref = "poly2tri" }
|
||||
|
||||
[plugins]
|
||||
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||
# Since Kotlin 2.0 the Compose compiler ships as a Kotlin Gradle plugin, version-locked
|
||||
# to Kotlin itself (replaces the old standalone composeCompiler version matrix).
|
||||
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }
|
||||
androidApplication = { id = "com.android.application", version.ref = "agp" }
|
||||
# Modern KMP-aware Android library plugin (declare `android {}` inside `kotlin {}`),
|
||||
# the AGP-recommended replacement for `com.android.library` + manual androidTarget().
|
||||
androidKmpLibrary = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" }
|
||||
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
|
||||
kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
# SQLDelight code-gen plugin — generates the typed CLIP database from module/format .sq files.
|
||||
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
|
||||
@@ -0,0 +1,28 @@
|
||||
// EN: Shared application-version resolution. Applied via `apply(from = …)` by the app modules that
|
||||
// stamp a version onto an artifact — :desktop (uber-jar name, jpackage packageVersion) and
|
||||
// :android (versionName). ProjectInfo.kt IS the version (its docblock forbids a second
|
||||
// definition), so this script parses the constant out of the source at configuration time
|
||||
// rather than declaring its own. providers.fileContents (not File.readText) so the
|
||||
// configuration cache tracks the file as an input and invalidates when the version changes.
|
||||
//
|
||||
// The result is handed back to the applying module through two extra properties:
|
||||
// umamoVersion — the full string, e.g. "0.1.0-dev" (jar names, Android versionName)
|
||||
// umamoVersionNumeric — the prerelease-stripped MAJOR.MINOR.PATCH, e.g. "0.1.0" (jpackage
|
||||
// rejects suffixes, so native installers get the numeric form)
|
||||
// JA: 共有のアプリバージョン解決スクリプト。ProjectInfo.kt の VERSION 定数を設定時に読み取り、
|
||||
// umamoVersion(完全な文字列)と umamoVersionNumeric(数値のみ)を extra で返す。
|
||||
|
||||
val projectInfoFile =
|
||||
rootProject.layout.projectDirectory.file("module/ui/src/commonMain/kotlin/org/umamo/ui/help/ProjectInfo.kt")
|
||||
val projectInfoText = providers.fileContents(projectInfoFile).asText.get()
|
||||
val versionMatch =
|
||||
Regex("""VERSION\s*=\s*"([^"]+)"""").find(projectInfoText)
|
||||
?: error("ProjectInfo.kt: VERSION constant not found; the build derives its version from it")
|
||||
val fullVersion = versionMatch.groupValues[1]
|
||||
val numericVersion = fullVersion.substringBefore('-')
|
||||
require(numericVersion.matches(Regex("""\d+\.\d+\.\d+"""))) {
|
||||
"ProjectInfo.VERSION '$fullVersion' does not start with numeric MAJOR.MINOR.PATCH"
|
||||
}
|
||||
|
||||
extra["umamoVersion"] = fullVersion
|
||||
extra["umamoVersionNumeric"] = numericVersion
|
||||
Vendored
BIN
Binary file not shown.
+9
@@ -0,0 +1,9 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
Reference in New Issue
Block a user