| 1 | #!/usr/bin/env bash |
| 2 | # Runs a command in this app's arm64 opam switch (.cache/opam-arm64) inside |
| 3 | # the emulated Debian arm64 root, creating the switch on first use. The |
| 4 | # compiler is the root's Debian OCaml 5.3.0, used as ocaml-system; every |
| 5 | # library, SQLite included, is compiled from source into .cache, from the |
| 6 | # versions in todo_ocaml.opam.locked and tools/sqlite.sh. |
| 7 | # tools/arm64.sh <command> [args...] |
| 8 | set -euo pipefail |
| 9 | app=$(cd "$(dirname "$0")/.." && pwd) |
| 10 | if [ -z "${IN_ARM64_ROOT:-}" ]; then |
| 11 | "$app/tools/sqlite.sh" fetch |
| 12 | exec "$app/../../scripts/arm64.sh" /usr/bin/env IN_ARM64_ROOT=1 \ |
| 13 | APP_VERSION="${APP_VERSION:-dev}" LINK_FLAGS="${LINK_FLAGS:-}" "$app/tools/arm64.sh" "$@" |
| 14 | fi |
| 15 | # The root is shared: keep dune's cache off so nothing lands in its /root. |
| 16 | export OPAMROOT=$app/.cache/opam-arm64 OPAMYES=1 OPAMCOLOR=never DUNE_CACHE=disabled |
| 17 | # SQLite is compiled here too, not taken from the root's libsqlite3-dev. |
| 18 | "$app/tools/sqlite.sh" build "$app/.cache/sqlite-arm64" |
| 19 | export PKG_CONFIG_PATH=$app/.cache/sqlite-arm64/lib/pkgconfig |
| 20 | if [ ! -d "$OPAMROOT/default" ]; then |
| 21 | [ -f "$OPAMROOT/config" ] || opam init -q --bare -n --disable-sandboxing default https://opam.ocaml.org |
| 22 | opam switch remove -q default >/dev/null 2>&1 || true # forget one make clean-deps deleted |
| 23 | opam switch create -q default ocaml-system.5.3.0 |
| 24 | fi |
| 25 | if [ ! -f "$OPAMROOT/default/.deps-installed" ] || [ "$app/todo_ocaml.opam.locked" -nt "$OPAMROOT/default/.deps-installed" ]; then |
| 26 | (cd "$app" && opam install -q --switch default --deps-only --locked .) |
| 27 | touch "$OPAMROOT/default/.deps-installed" |
| 28 | fi |
| 29 | exec opam exec --switch default -- "$@" |
| 30 | |