Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
translate ▾

Modern-Apps.git / games / kart / build.gradle.kts

build.gradle.kts90 lines · 3.6 KiBRaw
1plugins {
2 id("common-conventions-app")
3 // Listing screenshots come from Compose previews (src/screenshotTest), not from an
4 // instrumented test on a device. Same `:games:kart:metadata` task name either way.
5 id("common-conventions-preview-metadata")
6}
7
8launcherIcon {
9 symbol = "directions_car"
10}
11
12android {
13 defaultConfig {
14 applicationId = "com.vayunmathur.games.kart"
15 }
16}
17
18// ONN 4K box (32-bit armeabi-v7a userspace, Mali-G31, no Vulkan): the GLES
19// fallback in src/main/rust/gles renders 3D there. Same arrangement as
20// :cast:tv + :library:e2ee-p2p (the only armv7 precedent in the tree).
21nativeAbis {
22 armv7 = true
23}
24
25androidComponents {
26 onVariants { variant ->
27 variant.sources.jniLibs?.addStaticSourceDirectory(
28 layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath
29 )
30 }
31}
32
33// Native 3D racer engine (Sunset Oval track, kart physics, chase cam, items +
34// AI). Same arrangement as games/voxels: the crate builds into rustJniLibs and
35// KartNative.isAvailable gates every call, so devices without the .so run the
36// placeholder race. Listing images are hand-captured (Layoutlib can't render
37// the Vulkan surface); see the plan's verification notes.
38// armeabi-v7a as well as arm64: the ONN box runs this app directly on 32-bit
39// Google TV hardware. Only kart_engine opts in (:library:e2ee-p2p precedent) —
40// no other native module changes.
41rustNativeLib(
42 "kart_engine",
43 "kart",
44 extraAbis = listOf(ABI_ARMV7),
45 // kart_gles.* are GLSL ES, compiled at run time by the GLES fallback.
46 shaders = listOf("kart.vert", "kart.frag"),
47)
48
49// Only the classes below actually load a native library: KartHostAndNativeTest
50// calls KartNative.* directly, KartSurfaceViewTest drives KartSurfaceView's
51// surface callbacks (each reads KartNative.isAvailable), and the two screen
52// tests compose KartGameScreen's RacingBody, which reads
53// KartNative.isAvailable before composing KartSurfaceView. Touching
54// KartNative triggers its clinit (NativeLoader.load("kart_engine")).
55// Quarantine those loaders into testDevUnitTestNative (forkEvery = 1); the
56// remaining classes batch 20-per-JVM in testDevUnitTest, which depends on
57// the quarantine task so the usual invocation still runs everything.
58rustNativeTests {
59 nativeClasses.addAll(
60 listOf(
61 "com.vayunmathur.games.kart.platform.KartHostAndNativeTest",
62 "com.vayunmathur.games.kart.ui.KartGameScreenTest",
63 "com.vayunmathur.games.kart.ui.KartRaceSurfaceTest",
64 "com.vayunmathur.games.kart.ui.KartSurfaceViewTest",
65 )
66 )
67 // Shared-JVM polluters keep forkEvery = 1 in the same companion task:
68 // KartViewModelTest and MainActivityTest instantiate KartViewModel,
69 // whose viewModelScope collects the process-wide preferencesDataStore
70 // ("settings" via KartDataStore, plus "kart_identity" via
71 // KartPairingStore) for the VM's lifetime and whose races bank cup /
72 // win / best-lap state other classes expect at defaults;
73 // KartViewModelTest also mutates the global KartNative.isAvailable.
74 // KartStoresTest writes the same two DataStores directly and asserts
75 // defaults first. All other classes batch.
76 isolatedClasses.addAll(
77 listOf(
78 "com.vayunmathur.games.kart.MainActivityTest",
79 "com.vayunmathur.games.kart.data.KartStoresTest",
80 "com.vayunmathur.games.kart.platform.KartViewModelTest",
81 )
82 )
83}
84
85dependencies {
86 implementation(project(":sdk:games"))
87 implementation(project(":sdk:controller"))
88 implementation(project(":library:e2ee-p2p"))
89 implementation(libs.androidx.datastore.preferences)
90}