nandi/frqpublic Fork 0
b52a754c9c45fddcc0d11b447ef821ad752138d5
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 · 72 lines · 3.5 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})
43 ;; The glue travels with it, for the same reason: editing jolt_main.c
44 ;; should relink libjoltapp, and it cannot if buck only knows a path.
45 (fs/create-dirs (fs/path prebuilt "glue" "android"))
46 (fs/create-dirs (fs/path prebuilt "glue" "include"))
47 (fs/copy (fs/path jolt-native "android" "jolt_main.c")
48 (fs/path prebuilt "glue" "android" "jolt_main.c")
49 {:replace-existing true})
50 (doseq [h (fs/glob (fs/path jolt-native "crates" "jolt-vidya" "include") "*.h")]
51 (fs/copy h (fs/path prebuilt "glue" "include" (fs/file-name h))
52 {:replace-existing true}))
53 "checkout")
54 "pinned"))
55
56;; The boot image's other source roots are outside this cell too; hash them
57;; here so the digest reaches the action. See android/BUCK.
58(def boot-stamp
59 (paths/out (str (fs/path root "android" "build-jolt-boot.bb")) "--stamp"))
60
61(spit (str (fs/path root ".buckconfig.local"))
62 (str "[frq]\n"
63 " jolt_native = " jolt-native "\n"
64 " android_home = " android-home "\n"
65 " chez_android = " chez "\n"
66 " openssl_android = " openssl "\n"
67 " libvidya = " libvidya "\n"
68 " boot_stamp = " boot-stamp "\n"))
69
70(System/exit
71 (:exit @(apply p/process {:inherit true :dir root}
72 (str (fs/path root "scripts" "buck2")) *command-line-args*)))