app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit f1bc303201774160216693a56806085de2faa4b2
parent f0e823fad95bb5b4cd8adb6eb4896a57872e7800
Author: triesap <tyson@radroots.org>
Date:   Tue,  4 Aug 2026 00:14:50 +0000

build: split debug and release native artifacts

- declare distinct Cargo debug and release build tasks
- keep tests and development bound to the debug library
- stage only the optimized library for distribution resources
- verify the release resource jar matches the release binary

Diffstat:
MMakefile | 2+-
Mapp/desktop/build.gradle.kts | 49++++++++++++++++++++++++++++++++++---------------
2 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile @@ -32,7 +32,7 @@ build: doctor $(GRADLE) --no-daemon :app:desktop:build bindings: doctor - $(GRADLE) --no-daemon :app:desktop:generateUniFfiKotlin :app:desktop:stageUniFfiNativeLibrary + $(GRADLE) --no-daemon :app:desktop:generateUniFfiKotlin :app:desktop:stageReleaseNativeLibrary dev: doctor $(GRADLE) :app:desktop:hotRun --mainClass org.radroots.studio.desktop.MainKt diff --git a/app/desktop/build.gradle.kts b/app/desktop/build.gradle.kts @@ -10,6 +10,7 @@ import org.gradle.api.tasks.PathSensitive import org.gradle.api.tasks.PathSensitivity import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.testing.Test +import org.gradle.jvm.tasks.Jar import org.jetbrains.kotlin.gradle.dsl.JvmTarget version = "0.1.0-alpha" @@ -30,8 +31,8 @@ val rustLibraryName = when { System.getProperty("os.name").startsWith("Windows") -> "radroots_studio_ffi.dll" else -> "libradroots_studio_ffi.so" } -val rustDebugLibrary = rootProject.layout.projectDirectory - .file("core/target/debug/$rustLibraryName") +val rustDebugLibrary = rootProject.layout.projectDirectory.file("core/target/debug/$rustLibraryName") +val rustReleaseLibrary = rootProject.layout.projectDirectory.file("core/target/release/$rustLibraryName") val jnaPlatformPrefix = when { System.getProperty("os.name").startsWith("Mac") && System.getProperty("os.arch") == "aarch64" -> "darwin-aarch64" @@ -43,7 +44,7 @@ val jnaPlatformPrefix = when { else -> "linux-x86-64" } -val buildRustCore by tasks.registering(Exec::class) { +val buildRustCoreDebug by tasks.registering(Exec::class) { workingDir(rootProject.projectDir) commandLine( "cargo", @@ -57,10 +58,25 @@ val buildRustCore by tasks.registering(Exec::class) { outputs.file(rustDebugLibrary) } +val buildRustCoreRelease by tasks.registering(Exec::class) { + workingDir(rootProject.projectDir) + commandLine( + "cargo", + "build", + "--release", + "--manifest-path", + rustManifest.asFile.absolutePath, + "-p", + "radroots-studio-ffi", + ) + inputs.files(rustSources) + outputs.file(rustReleaseLibrary) +} + val generatedUniFfiKotlin = layout.buildDirectory.dir("generated/uniffi/kotlin") -val generatedNativeResources = layout.buildDirectory.dir("generated/uniffi/native-resources") +val generatedReleaseNativeResources = layout.buildDirectory.dir("generated/uniffi/release-native-resources") val generateUniFfiKotlin by tasks.registering(Exec::class) { - dependsOn(buildRustCore) + dependsOn(buildRustCoreDebug) workingDir(rootProject.projectDir) commandLine( "cargo", @@ -88,10 +104,15 @@ val generateUniFfiKotlin by tasks.registering(Exec::class) { inputs.file(rootProject.layout.projectDirectory.file("core/crates/ffi/uniffi.toml")) outputs.dir(generatedUniFfiKotlin) } -val stageUniFfiNativeLibrary by tasks.registering(Copy::class) { - dependsOn(buildRustCore) - from(rustDebugLibrary) - into(generatedNativeResources.map { it.dir(jnaPlatformPrefix) }) +val stageReleaseNativeLibrary by tasks.registering(Copy::class) { + dependsOn(buildRustCoreRelease) + from(rustReleaseLibrary) + into(generatedReleaseNativeResources.map { it.dir(jnaPlatformPrefix) }) +} +val releaseNativeResourcesJar by tasks.registering(Jar::class) { + dependsOn(stageReleaseNativeLibrary) + archiveClassifier.set("release-native-resources") + from(generatedReleaseNativeResources) } dependencies { @@ -139,7 +160,6 @@ tasks.withType<Test>().configureEach { kotlin { sourceSets.main { kotlin.srcDir(generatedUniFfiKotlin) - resources.srcDir(generatedNativeResources) } compilerOptions { @@ -152,18 +172,15 @@ kotlin { tasks.named("compileKotlin") { dependsOn(generateUniFfiKotlin) } -tasks.named("processResources") { - dependsOn(stageUniFfiNativeLibrary) -} tasks.withType<Test>().configureEach { - dependsOn(buildRustCore) + dependsOn(buildRustCoreDebug) systemProperty( "jna.library.path", rustDebugLibrary.asFile.parentFile.absolutePath, ) } tasks.withType<JavaExec>().configureEach { - dependsOn(buildRustCore) + dependsOn(buildRustCoreDebug) systemProperty("radroots.studio.development", "true") systemProperty( "jna.library.path", @@ -173,6 +190,8 @@ tasks.withType<JavaExec>().configureEach { compose.desktop { application { + dependsOn(releaseNativeResourcesJar.get()) + fromFiles(releaseNativeResourcesJar) mainClass = "org.radroots.studio.desktop.MainKt" jvmArgs += listOf(