nandi/frqpublic Fork 0
03d5a6b415596ef67c4a9f68cfd4476e3ebd0afb
Commits
Clone
git clone https://git.rickub.com/nandi/frq.git
git clone ssh://git@rickub.com/nandi/frq.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

buck.bb · 79 lines · 3.9 KBBlitzBasic Blame HistoryRaw
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago1#!/bin/sh
2#_(
3exec "$(dirname "$0")/bb" "$0" "$@"
4)
5
6;; buck2, with the machine's paths written where the BUCK files can read them.
7;;
8;; The same arrangement jolt-native uses, and for the same reason: a BUCK file
9;; may not look around the machine, and these answers differ on every one.
10;; Generated rather than committed, so no checkout carries another's paths.
11(require '[babashka.classpath :as cp])
12(cp/add-classpath (str (babashka.fs/parent *file*)))
13(require '[frq.paths :as paths]
14 '[babashka.fs :as fs]
15 '[babashka.process :as p])
16
17(def root (str (fs/canonicalize (fs/path (fs/parent *file*) ".."))))
18(def jolt-native (paths/jolt-native root))
19(def android-home (paths/env "ANDROID_HOME" (str (fs/path (fs/home) ".local" "share" "android-sdk"))))
20(def chez (paths/env "CHEZ_ANDROID" (str (fs/path (fs/home) ".cache" "vidya-chez-android"))))
21(def openssl (paths/env "OPENSSL_ANDROID" (str (fs/path (fs/home) ".cache" "frq-openssl-android" "lib"))))
22
23(paths/require-paths! "path"
24 [(fs/path android-home "build-tools" "36.0.0" "aapt2")
25 (fs/path android-home "platforms" "android-36" "android.jar")
26 (fs/path chez "boot" "tarm64le" "scheme.boot")
27 (fs/path openssl "libssl.so")])
28
29;; A jolt-native checkout wins over the pinned release, so that anyone working
30;; on both repos at once builds what they are editing. It is staged into this
31;; tree because a buck2 cell cannot reach outside its own root, and an action
32;; that shelled out to the other project would have nothing to invalidate on.
33;; With no checkout the release answers instead, fetched by digest — see
34;; toolchains/dist and scripts/libvidya-android.dotslash.
35(def libvidya
36 (if (fs/directory? (fs/path jolt-native "crates"))
37 (let [prebuilt (fs/path root "android" "prebuilt")]
38 (p/shell {:dir jolt-native :out :string} "just" "ffi-android")
39 (fs/create-dirs (fs/path prebuilt "arm64-v8a"))
40 (fs/copy (fs/path jolt-native "build" "android" "arm64-v8a" "libvidya.so")
41 (fs/path prebuilt "arm64-v8a" "libvidya.so")
42 {:replace-existing true})
Carry the media plane, and the class that opens the camera 43ada0b nandi 18d ago43 ;; The media plane, staged the same way. `just ffi-android` builds both.
44 (fs/copy (fs/path jolt-native "build" "android" "arm64-v8a" "libjoltmoq.so")
45 (fs/path prebuilt "arm64-v8a" "libjoltmoq.so")
46 {:replace-existing true})
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago47 ;; The glue travels with it, for the same reason: editing jolt_main.c
48 ;; should relink libjoltapp, and it cannot if buck only knows a path.
49 (fs/create-dirs (fs/path prebuilt "glue" "android"))
50 (fs/create-dirs (fs/path prebuilt "glue" "include"))
51 (fs/copy (fs/path jolt-native "android" "jolt_main.c")
52 (fs/path prebuilt "glue" "android" "jolt_main.c")
53 {:replace-existing true})
Carry the media plane, and the class that opens the camera 43ada0b nandi 18d ago54 ;; Both ABIs' headers: jolt_main.c includes joltmoq.h now, for the
55 ;; symbols it registers and for joltmoq_android_init.
56 (doseq [dir ["jolt-vidya" "jolt-moq"]
57 h (fs/glob (fs/path jolt-native "crates" dir "include") "*.h")]
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago58 (fs/copy h (fs/path prebuilt "glue" "include" (fs/file-name h))
59 {:replace-existing true}))
60 "checkout")
61 "pinned"))
62
63;; The boot image's other source roots are outside this cell too; hash them
64;; here so the digest reaches the action. See android/BUCK.
65(def boot-stamp
66 (paths/out (str (fs/path root "android" "build-jolt-boot.bb")) "--stamp"))
67
68(spit (str (fs/path root ".buckconfig.local"))
69 (str "[frq]\n"
70 " jolt_native = " jolt-native "\n"
71 " android_home = " android-home "\n"
72 " chez_android = " chez "\n"
73 " openssl_android = " openssl "\n"
74 " libvidya = " libvidya "\n"
75 " boot_stamp = " boot-stamp "\n"))
76
77(System/exit
78 (:exit @(apply p/process {:inherit true :dir root}
79 (str (fs/path root "scripts" "buck2")) *command-line-args*)))