| Build the APK with buck2, from pins rather than from a second checkout a71ef8f nandi 19d ago | 1 | #!/bin/sh |
| Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago | 2 | #_( |
| 3 | exec "$(dirname "$0")/bb" "$0" "$@" |
| 4 | ) |
| Build the APK with buck2, from pins rather than from a second checkout a71ef8f nandi 19d ago | 5 | |
| Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago | 6 | ;; The NDK's clang, as the linker rustc runs for an Android target. |
| 7 | ;; |
| 8 | ;; The buck-side twin of this is toolchains/ndk.sh, which the C toolchain gets |
| 9 | ;; as a dependency; both resolve the same archive, pinned in one place — |
| 10 | ;; android-ndk.dotslash beside this script. rustc reaches it through a shim |
| 11 | ;; instead because -Clinker takes a plain string: rustc_flags cannot carry an |
| 12 | ;; artifact path, so the linker has to be something with a stable name. The cfg |
| 13 | ;; in toolchains/BUCK is what keeps two NDKs from sharing a cache entry. |
| 14 | ;; |
| 15 | ;; ANDROID_NDK_HOME wins if it is set, so a machine that already has an NDK |
| 16 | ;; skips the download. |
| 17 | (require '[babashka.fs :as fs] |
| 18 | '[babashka.process :as p] |
| 19 | '[clojure.string :as str]) |
| 20 | |
| 21 | (def here (fs/parent (fs/canonicalize *file*))) |
| 22 | (def api (or (not-empty (str (System/getenv "JOLT_ANDROID_API"))) "28")) |
| 23 | (def target (or (not-empty (str (System/getenv "JOLT_ANDROID_TARGET"))) "aarch64-linux-android")) |
| 24 | |
| 25 | ;; android-ndk-bin is where the lookup lives, because an APK build wants the |
| 26 | ;; other binaries out of the same archive. |
| 27 | (def bin (str/trim (:out (p/shell {:out :string} (str (fs/path here "android-ndk-bin")))))) |
| 28 | |
| 29 | (System/exit |
| 30 | (:exit @(apply p/process {:inherit true} |
| 31 | (str (fs/path bin "clang")) (str "--target=" target api) |
| 32 | *command-line-args*))) |