#!/usr/bin/env bash # Runs a command in this app's x86 opam switch (.cache/opam-x86), creating # it on first use. The compiler is the bakeoff's OCaml 5.3.0, used as # ocaml-system; libraries, SQLite included, are compiled into .cache. # tools/x86.sh [args...] set -euo pipefail app=$(cd "$(dirname "$0")/.." && pwd) cache=$app/.cache source "$app/../../scripts/env.sh" ocaml_bin=$(dirname "$(readlink -f "$(command -v ocamlopt)")") unset OPAMSWITCH OPAM_SWITCH_PREFIX OPAM_LAST_ENV CAML_LD_LIBRARY_PATH OCAML_TOPLEVEL_PATH OCAMLTOP_INCLUDE_PATH MANPATH export OPAMROOT=$cache/opam-x86 OPAMYES=1 OPAMCOLOR=never DUNE_CACHE=disabled # opam ignores compilers inside another opam root, so expose this one by # symlink. docs-t1 has no pkg-config; Debian's is unpacked into .cache. bin=$cache/x86-bin if [ ! -x "$bin/pkg-config" ]; then mkdir -p "$bin" "$cache/debs" for f in "$ocaml_bin"/ocaml*; do ln -sf "$f" "$bin/"; done (cd "$cache/debs" && apt-get download -q pkgconf-bin libpkgconf3 >/dev/null) for d in "$cache"/debs/*.deb; do dpkg-deb -x "$d" "$cache/x86-sysroot"; done cat > "$bin/pkg-config" </dev/null 2>&1 || true # forget one make clean-deps deleted opam switch create -q default ocaml-system.5.3.0 fi if [ ! -f "$OPAMROOT/default/.deps-installed" ] || [ "$app/todo_ocaml.opam.locked" -nt "$OPAMROOT/default/.deps-installed" ]; then (cd "$app" && opam install -q --switch default --deps-only --with-test $([ -f todo_ocaml.opam.locked ] && echo --locked) --assume-depexts .) touch "$OPAMROOT/default/.deps-installed" fi exec opam exec --switch default -- "$@"