modified
android/jolt_main.c +14 -0 | @@ -29,7 +29,15 @@ | ||
| 29 | 29 | #include <android/log.h> |
| 30 | 30 | #include <pthread.h> |
| 31 | 31 | |
| 32 | +/* JOLT_WITHOUT_MOQ builds this glue for an app that does not link | |
| 33 | + * libjoltmoq. frq is one: its media plane is jolt now — MoQ through | |
| 34 | + * libmoq_ffi, Opus, H.264, V4L2 and ALSA — so the Rust one is an object it | |
| 35 | + * never opens, and seventeen megabytes of APK for nothing. Everything moq | |
| 36 | + * below is behind this, because --no-undefined turns an unreferenced symbol | |
| 37 | + * into a link error rather than a surprise on the phone. */ | |
| 38 | +#ifndef JOLT_WITHOUT_MOQ | |
| 32 | 39 | #include "joltmoq.h" |
| 40 | +#endif | |
| 33 | 41 | #include "scheme.h" |
| 34 | 42 | #include "vidya.h" |
| 35 | 43 | #include "vidya_tree.h" |
| @@ -114,6 +122,7 @@ static void register_vidya_api(void) { | ||
| 114 | 122 | REGISTER_VIDYA(vidya_tree_dump); |
| 115 | 123 | } |
| 116 | 124 | |
| 125 | +#ifndef JOLT_WITHOUT_MOQ | |
| 117 | 126 | /* |
| 118 | 127 | * The media plane's symbols, registered for the same reason the Vidya ones |
| 119 | 128 | * above are: they live in libjoltmoq.so, a third object, and Android's loader |
| @@ -164,6 +173,7 @@ static void register_joltmoq_api(void) { | ||
| 164 | 173 | REGISTER_JOLTMOQ(joltmoq_can_dial); |
| 165 | 174 | REGISTER_JOLTMOQ(joltmoq_new_instance); |
| 166 | 175 | } |
| 176 | +#endif /* JOLT_WITHOUT_MOQ */ | |
| 167 | 177 | |
| 168 | 178 | /* |
| 169 | 179 | * Chez writes to stdout/stderr, which on Android goes nowhere. Pump both into |
| @@ -204,8 +214,11 @@ int vidya_jolt_main(void) { | ||
| 204 | 214 | (iptr)(_binary_jolt_boot_end - _binary_jolt_boot_start)); |
| 205 | 215 | Sbuild_heap(NULL, NULL); |
| 206 | 216 | register_vidya_api(); |
| 217 | +#ifndef JOLT_WITHOUT_MOQ | |
| 207 | 218 | register_joltmoq_api(); |
| 219 | +#endif | |
| 208 | 220 | |
| 221 | +#ifndef JOLT_WITHOUT_MOQ | |
| 209 | 222 | /* The media plane's own handles, which it cannot get for itself: they arrive |
| 210 | 223 | in android-activity's glue, and the glue is in libvidya.so. This is the |
| 211 | 224 | only place both objects are in scope. Before Scheme starts, so no call can |
| @@ -221,6 +234,7 @@ int vidya_jolt_main(void) { | ||
| 221 | 234 | "VidyaJolt", "media plane JNI handles: vm=%p activity=%p", |
| 222 | 235 | moq_vm, moq_activity); |
| 223 | 236 | joltmoq_android_init(moq_vm, moq_activity); |
| 237 | +#endif | |
| 224 | 238 | |
| 225 | 239 | __android_log_print(ANDROID_LOG_INFO, "VidyaJolt", "starting Jolt application"); |
| 226 | 240 | int status = Sscheme_start(1, argv); |
| @@ -29,7 +29,15 @@ | |||
| 29 | #include <android/log.h> | 29 | #include <android/log.h> |
| 30 | #include <pthread.h> | 30 | #include <pthread.h> |
| 31 | 31 | ||
| 32 | +/* JOLT_WITHOUT_MOQ builds this glue for an app that does not link | ||
| 33 | + * libjoltmoq. frq is one: its media plane is jolt now — MoQ through | ||
| 34 | + * libmoq_ffi, Opus, H.264, V4L2 and ALSA — so the Rust one is an object it | ||
| 35 | + * never opens, and seventeen megabytes of APK for nothing. Everything moq | ||
| 36 | + * below is behind this, because --no-undefined turns an unreferenced symbol | ||
| 37 | + * into a link error rather than a surprise on the phone. */ | ||
| 38 | +#ifndef JOLT_WITHOUT_MOQ | ||
| 32 | #include "joltmoq.h" | 39 | #include "joltmoq.h" |
| 40 | +#endif | ||
| 33 | #include "scheme.h" | 41 | #include "scheme.h" |
| 34 | #include "vidya.h" | 42 | #include "vidya.h" |
| 35 | #include "vidya_tree.h" | 43 | #include "vidya_tree.h" |
| @@ -114,6 +122,7 @@ static void register_vidya_api(void) { | |||
| 114 | REGISTER_VIDYA(vidya_tree_dump); | 122 | REGISTER_VIDYA(vidya_tree_dump); |
| 115 | } | 123 | } |
| 116 | 124 | ||
| 125 | +#ifndef JOLT_WITHOUT_MOQ | ||
| 117 | /* | 126 | /* |
| 118 | * The media plane's symbols, registered for the same reason the Vidya ones | 127 | * The media plane's symbols, registered for the same reason the Vidya ones |
| 119 | * above are: they live in libjoltmoq.so, a third object, and Android's loader | 128 | * above are: they live in libjoltmoq.so, a third object, and Android's loader |
| @@ -164,6 +173,7 @@ static void register_joltmoq_api(void) { | |||
| 164 | REGISTER_JOLTMOQ(joltmoq_can_dial); | 173 | REGISTER_JOLTMOQ(joltmoq_can_dial); |
| 165 | REGISTER_JOLTMOQ(joltmoq_new_instance); | 174 | REGISTER_JOLTMOQ(joltmoq_new_instance); |
| 166 | } | 175 | } |
| 176 | +#endif /* JOLT_WITHOUT_MOQ */ | ||
| 167 | 177 | ||
| 168 | /* | 178 | /* |
| 169 | * Chez writes to stdout/stderr, which on Android goes nowhere. Pump both into | 179 | * Chez writes to stdout/stderr, which on Android goes nowhere. Pump both into |
| @@ -204,8 +214,11 @@ int vidya_jolt_main(void) { | |||
| 204 | (iptr)(_binary_jolt_boot_end - _binary_jolt_boot_start)); | 214 | (iptr)(_binary_jolt_boot_end - _binary_jolt_boot_start)); |
| 205 | Sbuild_heap(NULL, NULL); | 215 | Sbuild_heap(NULL, NULL); |
| 206 | register_vidya_api(); | 216 | register_vidya_api(); |
| 217 | +#ifndef JOLT_WITHOUT_MOQ | ||
| 207 | register_joltmoq_api(); | 218 | register_joltmoq_api(); |
| 219 | +#endif | ||
| 208 | 220 | ||
| 221 | +#ifndef JOLT_WITHOUT_MOQ | ||
| 209 | /* The media plane's own handles, which it cannot get for itself: they arrive | 222 | /* The media plane's own handles, which it cannot get for itself: they arrive |
| 210 | in android-activity's glue, and the glue is in libvidya.so. This is the | 223 | in android-activity's glue, and the glue is in libvidya.so. This is the |
| 211 | only place both objects are in scope. Before Scheme starts, so no call can | 224 | only place both objects are in scope. Before Scheme starts, so no call can |
| @@ -221,6 +234,7 @@ int vidya_jolt_main(void) { | |||
| 221 | "VidyaJolt", "media plane JNI handles: vm=%p activity=%p", | 234 | "VidyaJolt", "media plane JNI handles: vm=%p activity=%p", |
| 222 | moq_vm, moq_activity); | 235 | moq_vm, moq_activity); |
| 223 | joltmoq_android_init(moq_vm, moq_activity); | 236 | joltmoq_android_init(moq_vm, moq_activity); |
| 237 | +#endif | ||
| 224 | 238 | ||
| 225 | __android_log_print(ANDROID_LOG_INFO, "VidyaJolt", "starting Jolt application"); | 239 | __android_log_print(ANDROID_LOG_INFO, "VidyaJolt", "starting Jolt application"); |
| 226 | int status = Sscheme_start(1, argv); | 240 | int status = Sscheme_start(1, argv); |
modified
flake.nix +40 -4 | @@ -132,8 +132,40 @@ | ||
| 132 | 132 | buildInputs = desktopBuildInputs; |
| 133 | 133 | } // v4l2Env; |
| 134 | 134 | |
| 135 | - # Every external crate, compiled once and shared by the three objects, | |
| 136 | - # the clippy run and the test run. | |
| 135 | + # Every external crate, compiled once and shared by the objects that | |
| 136 | + # actually want it. | |
| 137 | + # | |
| 138 | + # This used to be ONE derivation for the whole workspace, and the | |
| 139 | + # sharing was the point: three objects, one dependency build. What it | |
| 140 | + # cost was invisible until a consumer wanted only some of them. | |
| 141 | + # jolt-moq brings moq-net, iroh, quinn, rustls and aws-lc-sys behind | |
| 142 | + # it -- 440 crates that nothing else here touches -- so a build of | |
| 143 | + # libvidya alone still paid for the media plane. A client that has | |
| 144 | + # stopped loading libjoltmoq paid for it too, which is the case that | |
| 145 | + # made this worth splitting. | |
| 146 | + # | |
| 147 | + # Split by CONSUMER rather than per package: vidya and tui share | |
| 148 | + # nearly everything, and giving them an artifact each would trade one | |
| 149 | + # kind of waste for another. | |
| 150 | + depsFor = { pname, packages }: | |
| 151 | + craneLib.buildDepsOnly (commonArgs // { | |
| 152 | + inherit pname; | |
| 153 | + version = "0.1.0"; | |
| 154 | + cargoExtraArgs = | |
| 155 | + "--locked " + lib.concatMapStringsSep " " (p: "-p " + p) packages; | |
| 156 | + }); | |
| 157 | + | |
| 158 | + uiArtifacts = depsFor { | |
| 159 | + pname = "jolt-native-ui-deps"; | |
| 160 | + packages = [ "vidya-ffi" "jolt-tui" ]; | |
| 161 | + }; | |
| 162 | + moqArtifacts = depsFor { | |
| 163 | + pname = "jolt-native-moq-deps"; | |
| 164 | + packages = [ "jolt-moq" ]; | |
| 165 | + }; | |
| 166 | + | |
| 167 | + # The whole workspace, for the clippy and test runs — those do build | |
| 168 | + # everything, and want the sharing this split gives up. | |
| 137 | 169 | cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { |
| 138 | 170 | pname = "jolt-native-deps"; |
| 139 | 171 | version = "0.1.0"; |
| @@ -147,9 +179,10 @@ | ||
| 147 | 179 | # crates/jolt-vidya. Nothing is silenced — a header that stops being |
| 148 | 180 | # there should fail the build rather than ship an object with no ABI |
| 149 | 181 | # beside it. |
| 150 | - soPackage = { pname, package, dir, soname }: | |
| 182 | + soPackage = { pname, package, dir, soname, artifacts }: | |
| 151 | 183 | craneLib.buildPackage (commonArgs // { |
| 152 | - inherit pname cargoArtifacts; | |
| 184 | + inherit pname; | |
| 185 | + cargoArtifacts = artifacts; | |
| 153 | 186 | version = "0.1.0"; |
| 154 | 187 | cargoExtraArgs = "--locked -p ${package}"; |
| 155 | 188 | doCheck = false; |
| @@ -161,18 +194,21 @@ | ||
| 161 | 194 | }); |
| 162 | 195 | |
| 163 | 196 | libvidya = soPackage { |
| 197 | + artifacts = uiArtifacts; | |
| 164 | 198 | pname = "libvidya"; |
| 165 | 199 | package = "vidya-ffi"; |
| 166 | 200 | dir = "jolt-vidya"; |
| 167 | 201 | soname = "libvidya.so"; |
| 168 | 202 | }; |
| 169 | 203 | libjolttui = soPackage { |
| 204 | + artifacts = uiArtifacts; | |
| 170 | 205 | pname = "libjolttui"; |
| 171 | 206 | package = "jolt-tui"; |
| 172 | 207 | dir = "jolt-tui"; |
| 173 | 208 | soname = "libjolttui.so"; |
| 174 | 209 | }; |
| 175 | 210 | libjoltmoq = soPackage { |
| 211 | + artifacts = moqArtifacts; | |
| 176 | 212 | pname = "libjoltmoq"; |
| 177 | 213 | package = "jolt-moq"; |
| 178 | 214 | dir = "jolt-moq"; |
| @@ -132,8 +132,40 @@ | |||
| 132 | buildInputs = desktopBuildInputs; | 132 | buildInputs = desktopBuildInputs; |
| 133 | } // v4l2Env; | 133 | } // v4l2Env; |
| 134 | 134 | ||
| 135 | - # Every external crate, compiled once and shared by the three objects, | 135 | + # Every external crate, compiled once and shared by the objects that |
| 136 | - # the clippy run and the test run. | 136 | + # actually want it. |
| 137 | + # | ||
| 138 | + # This used to be ONE derivation for the whole workspace, and the | ||
| 139 | + # sharing was the point: three objects, one dependency build. What it | ||
| 140 | + # cost was invisible until a consumer wanted only some of them. | ||
| 141 | + # jolt-moq brings moq-net, iroh, quinn, rustls and aws-lc-sys behind | ||
| 142 | + # it -- 440 crates that nothing else here touches -- so a build of | ||
| 143 | + # libvidya alone still paid for the media plane. A client that has | ||
| 144 | + # stopped loading libjoltmoq paid for it too, which is the case that | ||
| 145 | + # made this worth splitting. | ||
| 146 | + # | ||
| 147 | + # Split by CONSUMER rather than per package: vidya and tui share | ||
| 148 | + # nearly everything, and giving them an artifact each would trade one | ||
| 149 | + # kind of waste for another. | ||
| 150 | + depsFor = { pname, packages }: | ||
| 151 | + craneLib.buildDepsOnly (commonArgs // { | ||
| 152 | + inherit pname; | ||
| 153 | + version = "0.1.0"; | ||
| 154 | + cargoExtraArgs = | ||
| 155 | + "--locked " + lib.concatMapStringsSep " " (p: "-p " + p) packages; | ||
| 156 | + }); | ||
| 157 | + | ||
| 158 | + uiArtifacts = depsFor { | ||
| 159 | + pname = "jolt-native-ui-deps"; | ||
| 160 | + packages = [ "vidya-ffi" "jolt-tui" ]; | ||
| 161 | + }; | ||
| 162 | + moqArtifacts = depsFor { | ||
| 163 | + pname = "jolt-native-moq-deps"; | ||
| 164 | + packages = [ "jolt-moq" ]; | ||
| 165 | + }; | ||
| 166 | + | ||
| 167 | + # The whole workspace, for the clippy and test runs — those do build | ||
| 168 | + # everything, and want the sharing this split gives up. | ||
| 137 | cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { | 169 | cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { |
| 138 | pname = "jolt-native-deps"; | 170 | pname = "jolt-native-deps"; |
| 139 | version = "0.1.0"; | 171 | version = "0.1.0"; |
| @@ -147,9 +179,10 @@ | |||
| 147 | # crates/jolt-vidya. Nothing is silenced — a header that stops being | 179 | # crates/jolt-vidya. Nothing is silenced — a header that stops being |
| 148 | # there should fail the build rather than ship an object with no ABI | 180 | # there should fail the build rather than ship an object with no ABI |
| 149 | # beside it. | 181 | # beside it. |
| 150 | - soPackage = { pname, package, dir, soname }: | 182 | + soPackage = { pname, package, dir, soname, artifacts }: |
| 151 | craneLib.buildPackage (commonArgs // { | 183 | craneLib.buildPackage (commonArgs // { |
| 152 | - inherit pname cargoArtifacts; | 184 | + inherit pname; |
| 185 | + cargoArtifacts = artifacts; | ||
| 153 | version = "0.1.0"; | 186 | version = "0.1.0"; |
| 154 | cargoExtraArgs = "--locked -p ${package}"; | 187 | cargoExtraArgs = "--locked -p ${package}"; |
| 155 | doCheck = false; | 188 | doCheck = false; |
| @@ -161,18 +194,21 @@ | |||
| 161 | }); | 194 | }); |
| 162 | 195 | ||
| 163 | libvidya = soPackage { | 196 | libvidya = soPackage { |
| 197 | + artifacts = uiArtifacts; | ||
| 164 | pname = "libvidya"; | 198 | pname = "libvidya"; |
| 165 | package = "vidya-ffi"; | 199 | package = "vidya-ffi"; |
| 166 | dir = "jolt-vidya"; | 200 | dir = "jolt-vidya"; |
| 167 | soname = "libvidya.so"; | 201 | soname = "libvidya.so"; |
| 168 | }; | 202 | }; |
| 169 | libjolttui = soPackage { | 203 | libjolttui = soPackage { |
| 204 | + artifacts = uiArtifacts; | ||
| 170 | pname = "libjolttui"; | 205 | pname = "libjolttui"; |
| 171 | package = "jolt-tui"; | 206 | package = "jolt-tui"; |
| 172 | dir = "jolt-tui"; | 207 | dir = "jolt-tui"; |
| 173 | soname = "libjolttui.so"; | 208 | soname = "libjolttui.so"; |
| 174 | }; | 209 | }; |
| 175 | libjoltmoq = soPackage { | 210 | libjoltmoq = soPackage { |
| 211 | + artifacts = moqArtifacts; | ||
| 176 | pname = "libjoltmoq"; | 212 | pname = "libjoltmoq"; |
| 177 | package = "jolt-moq"; | 213 | package = "jolt-moq"; |
| 178 | dir = "jolt-moq"; | 214 | dir = "jolt-moq"; |