| Lift freeq's AV media plane out of sleek 90f8b89 nandi 19d ago | 1 | set shell := ["bash", "-euo", "pipefail", "-c"] |
| 2 | |
| 3 | # Everything is compiled by zig, including the C and C++ dependencies, so a |
| 4 | # build needs no system toolchain — but bindgen runs libclang directly and does |
| 5 | # not inherit zig's own header search path. `v4l2r` wants `linux/videodev2.h`, |
| 6 | # which lives in /usr/include on a machine with kernel headers installed and |
| 7 | # nowhere at all on one without. Point it at zig's bundled copies instead. |
| 8 | zig_include := `scripts/zig-include` |
| 9 | headers := "-I" + zig_include + " -I" + parent_directory(zig_include) + "/x86-linux-gnu -I" + parent_directory(zig_include) + "/generic-glibc" |
| 10 | |
| 11 | export V4L2R_VIDEODEV2_H_PATH := zig_include |
| 12 | export BINDGEN_EXTRA_CLANG_ARGS := headers |
| 13 | |
| 14 | default: |
| 15 | @just --list |
| 16 | |
| 17 | # The shared objects, ready to be put on a loader search path. |
| 18 | build *args: |
| 19 | cargo build --release {{args}} |
| 20 | |
| Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago | 21 | # buck2, told where the C tools are. They are named by absolute path because |
| 22 | # the prelude re-execs them from a build script's own directory — see the note |
| 23 | # in toolchains/BUCK. rustc is not here: buck fetches it itself now, so it |
| 24 | # needs neither a path nor a place on PATH. |
| Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d ago | 25 | # |
| Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago | 26 | # The zig version goes in for the same reason the paths do not carry it: the |
| 27 | # path stays the same when the binary behind it changes, and the cache cannot |
| 28 | # tell. |
| Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago | 29 | buck *args: |
| Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago | 30 | printf '[jolt]\n scripts = %s\n zig_version = %s\n' \ |
| Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d ago | 31 | "{{justfile_directory()}}/scripts" \ |
| Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago | 32 | "$(scripts/zig version | tr -d '\n')" > .buckconfig.local |
| 33 | scripts/buck2 {{args}} |
| Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago | 34 | |
| Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d ago | 35 | # The same two objects under buck2, staged into one directory a consumer can |
| 36 | # put on its loader path — the same shape `build` leaves in target/release. |
| 37 | # |
| 38 | # Not the default yet, and only for one reason: cpal's `pipewire` feature is |
| 39 | # off here, so device *names* in a call are ALSA PCMs rather than the real OS |
| 40 | # sources. See the note in third-party/rust/Cargo.toml. |
| Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago | 41 | buck-build *args: |
| 42 | @just buck build //:libs {{args}} |
| Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d ago | 43 | mkdir -p build/lib |
| 44 | cp "$(just buck build --show-output //:libvidya | awk '/libvidya.so/{print $2}')" build/lib/libvidya.so |
| 45 | cp "$(just buck build --show-output //:libjoltmoq | awk '/libjoltmoq.so/{print $2}')" build/lib/libjoltmoq.so |
| 46 | @echo "{{justfile_directory()}}/build/lib" |
| 47 | |
| 48 | # Where a consumer points LD_LIBRARY_PATH for the buck2 build. |
| 49 | buck-libdir: |
| 50 | @echo "{{justfile_directory()}}/build/lib" |
| Build under buck2, with the toolchain pinned rather than found 460541b nandi 19d ago | 51 | |
| Let the media plane cross to the phone, camera and all fd0e21a nandi 18d ago | 52 | # Both objects, cross-compiled for a 64-bit Android device and staged where an |
| 53 | # APK build can pick them up. libjoltmoq crosses too now — its camera is |
| 54 | # Camera2 over JNI rather than V4L2, and its audio is cpal's AAudio host rather |
| 55 | # than PipeWire. The camera needs two things from the APK, though, which this |
| 56 | # recipe cannot supply: a `CameraCapture` class in its classes.dex (frq has |
| 57 | # one), and a call to joltmoq_android_init. See android/jolt_main.c. |
| Build libvidya for the phone, and hold the glue that boots it d942053 nandi 19d ago | 58 | # |
| 59 | # The NDK is fetched by buck2 from the pin in scripts/android-ndk.dotslash, so |
| 60 | # the only thing a machine needs installed for this is nothing. |
| 61 | ffi-android: |
| Let the media plane cross to the phone, camera and all fd0e21a nandi 18d ago | 62 | @just buck build //:libs-android |
| Build libvidya for the phone, and hold the glue that boots it d942053 nandi 19d ago | 63 | mkdir -p build/android/arm64-v8a |
| 64 | cp "$(just buck build --show-output //:libvidya-android | awk '/libvidya.so/{print $2}')" \ |
| 65 | build/android/arm64-v8a/libvidya.so |
| Let the media plane cross to the phone, camera and all fd0e21a nandi 18d ago | 66 | cp "$(just buck build --show-output //:libjoltmoq-android | awk '/libjoltmoq.so/{print $2}')" \ |
| 67 | build/android/arm64-v8a/libjoltmoq.so |
| Build libvidya for the phone, and hold the glue that boots it d942053 nandi 19d ago | 68 | @echo "{{justfile_directory()}}/build/android/arm64-v8a" |
| 69 | |
| Let the media plane cross to the phone, camera and all fd0e21a nandi 18d ago | 70 | # Where an APK build finds the Android objects, and the glue beside them. |
| Build libvidya for the phone, and hold the glue that boots it d942053 nandi 19d ago | 71 | android-libdir: |
| 72 | @echo "{{justfile_directory()}}/build/android/arm64-v8a" |
| 73 | |
| Lift freeq's AV media plane out of sleek 90f8b89 nandi 19d ago | 74 | test *args: |
| 75 | cargo test --workspace {{args}} |
| 76 | |
| 77 | # Without PipeWire — for a machine that has neither pkg-config nor PipeWire's |
| 78 | # headers. Device *names* get worse (ALSA PCMs only); everything else is equal. |
| 79 | test-minimal: |
| 80 | cargo test --workspace --no-default-features |
| 81 | |
| 82 | lint: |
| 83 | cargo clippy --workspace --all-targets -- -D warnings |
| 84 | cargo fmt --all --check |
| 85 | |
| 86 | # Where a consumer points LD_LIBRARY_PATH. |
| 87 | libdir: |
| 88 | @echo "{{justfile_directory()}}/target/release" |
| Fetch rustc the way buck can ship it, from what DotSlash already pins 8cf1b33 nandi 19d ago | 89 | |
| 90 | # Regenerate the table buck fetches its toolchains from, after editing any of |
| 91 | # scripts/*.dotslash. DotSlash stays the one place a version is written down; |
| 92 | # this only restates it in a form buck can act on. |
| 93 | sync-dist: |
| 94 | scripts/dotslash-to-buck |