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

Modern-Apps.git / library / map / build.gradle.kts

build.gradle.kts84 lines · 4.0 KiBRaw
1plugins {
2 id("common-conventions-library")
3}
4android {
5 defaultConfig {
6 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
7 }
8 // FrameLoopWakeTest constructs a real `Application` for its `Context`: without this every
9 // `android.util`/`android.app` stub throws "not mocked". Same flag `:maps` sets for
10 // `PoiIndexTest`'s side-file reader, which logs.
11 testOptions.unitTests.isReturnDefaultValues = true
12}
13androidComponents {
14 onVariants { variant ->
15 variant.sources.jniLibs?.addStaticSourceDirectory(
16 layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath
17 )
18 }
19}
20
21dependencies {
22 implementation(libs.androidx.compose.foundation)
23
24 // For androidx.lifecycle.compose.LocalLifecycleOwner, which drives the frame loop's
25 // ON_START/ON_STOP reconciliation. Scoped to this module rather than the convention
26 // plugin: one consumer does not justify reconfiguring every module.
27 implementation(libs.androidx.lifecycle.runtime.compose)
28
29 // The renderer's HTTP transport reaches the app's NetworkClient through JNI:
30 // the Rust core calls back through library/jni-http into NativeHttpBridge
31 // (com.vayunmathur.library.network), which the HOST app provides — all ten
32 // map hosts already depend on :library:network directly. The bridge class is
33 // resolved at runtime from the app's classpath, so this module needs no
34 // :library:network edge (and gains no ACCESS_NETWORK_STATE from it); the
35 // tile-range requests keep library:network's reduced CA bundle and
36 // HttpURLConnection-only policy with no second TLS stack (#884).
37 //
38 // Deliberately not :library — that would drag Room, DataStore, Navigation 3 and
39 // :sdk:games onto this module's compile classpath for one object.
40
41 // Own GeoPoint/GeoBounds – this module has no third-party geometry dependency.
42
43 // :library:image is deliberately gone: it existed to fetch and decode CARTO raster
44 // PNGs, and there is no raster tile path any more.
45
46 // The on-device screenshot harness (`src/androidTest`), which is the only way to see what
47 // the renderer draws: Vulkan needs a real GPU, so the host probes can only measure the CPU
48 // pipeline. The coordinates live in the version catalog with the rest of the repo's
49 // dependencies; every app module also gets the shared launch-no-crash androidTest
50 // dependencies from `common-conventions-app`.
51 androidTestImplementation(libs.androidx.test.runner)
52 androidTestImplementation(libs.androidx.test.core)
53 androidTestImplementation(libs.androidx.test.ext.junit)
54 androidTestImplementation(platform(libs.androidx.compose.bom))
55 androidTestImplementation(libs.androidx.activity.compose)
56 androidTestImplementation(libs.androidx.compose.foundation)
57 // Supplies the bare `ComponentActivity` the harness hosts the map in.
58 androidTestImplementation(libs.androidx.compose.ui.test.manifest)
59}
60
61// The Vulkan vector-tile renderer: `library/map/src/main/rust`, on ash.
62//
63// arm64 only, which is what the seven consumer apps build
64// (`common-conventions-app.gradle.kts:131-133`). `libvulkan.so` is on the device, so this
65// .so is our own code and nothing else — the whole size argument against bundling Dawn.
66//
67// `-PemulatorAbi=x86_64` additionally builds x86_64 so the renderer can be run in an
68// emulator on an x86_64 host. Vulkan cannot be verified on a build host, and an arm64
69// system image on such a host means full-system QEMU translation, so this is the only
70// practical way to exercise the GPU path here. Never on by default.
71//
72// Shaders are GLSL compiled to SPIR-V by the `compileShaders` task (build-logic
73// GlslcCompile), which fails the build if glslc is missing or a shader does not compile.
74rustNativeLib(
75 "map_renderer",
76 "map",
77 extraAbis = if (providers.gradleProperty("emulatorAbi").orNull == ABI_X86_64) {
78 listOf(ABI_X86_64)
79 } else {
80 emptyList()
81 },
82 shaders = listOf("*.vert", "*.frag"),
83 glslcArgs = listOf("--target-env=vulkan1.1", "-O"),
84)