carlos / todomvc-bakeoff Public

Clone
git clone https://amadan.net/carlos/todomvc-bakeoff

Plain git — no account needed to clone.

Download

Download this file

1#!/usr/bin/env bash
2# Runs a command in this app's x86 opam switch (.cache/opam-x86), creating
3# it on first use. The compiler is the bakeoff's OCaml 5.3.0, used as
4# ocaml-system; libraries, SQLite included, are compiled into .cache.
5# tools/x86.sh <command> [args...]
6set -euo pipefail
7app=$(cd "$(dirname "$0")/.." && pwd)
8cache=$app/.cache
9source "$app/../../scripts/env.sh"
10ocaml_bin=$(dirname "$(readlink -f "$(command -v ocamlopt)")")
11unset OPAMSWITCH OPAM_SWITCH_PREFIX OPAM_LAST_ENV CAML_LD_LIBRARY_PATH OCAML_TOPLEVEL_PATH OCAMLTOP_INCLUDE_PATH MANPATH
12export OPAMROOT=$cache/opam-x86 OPAMYES=1 OPAMCOLOR=never DUNE_CACHE=disabled
13
14# opam ignores compilers inside another opam root, so expose this one by
15# symlink. docs-t1 has no pkg-config; Debian's is unpacked into .cache.
16bin=$cache/x86-bin
17if [ ! -x "$bin/pkg-config" ]; then
18 mkdir -p "$bin" "$cache/debs"
19 for f in "$ocaml_bin"/ocaml*; do ln -sf "$f" "$bin/"; done
20 (cd "$cache/debs" && apt-get download -q pkgconf-bin libpkgconf3 >/dev/null)
21 for d in "$cache"/debs/*.deb; do dpkg-deb -x "$d" "$cache/x86-sysroot"; done
22 cat > "$bin/pkg-config" <<EOS
23#!/bin/sh
24root=$cache/x86-sysroot
25LD_LIBRARY_PATH=\$root/usr/lib/x86_64-linux-gnu PKG_CONFIG_LIBDIR=$cache/sqlite-x86/lib/pkgconfig \\
26 exec \$root/usr/bin/pkgconf "\$@"
27EOS
28 chmod +x "$bin/pkg-config"
29fi
30export PATH=$bin:/usr/local/bin:/usr/bin:/bin:$HOME/.local/bin
31
32"$app/tools/sqlite.sh" fetch
33"$app/tools/sqlite.sh" build "$cache/sqlite-x86"
34if [ ! -d "$OPAMROOT/default" ]; then
35 [ -f "$OPAMROOT/config" ] || opam init -q --bare -n --disable-sandboxing default https://opam.ocaml.org
36 opam switch remove -q default >/dev/null 2>&1 || true # forget one make clean-deps deleted
37 opam switch create -q default ocaml-system.5.3.0
38fi
39if [ ! -f "$OPAMROOT/default/.deps-installed" ] || [ "$app/todo_ocaml.opam.locked" -nt "$OPAMROOT/default/.deps-installed" ]; then
40 (cd "$app" && opam install -q --switch default --deps-only --with-test $([ -f todo_ocaml.opam.locked ] && echo --locked) --assume-depexts .)
41 touch "$OPAMROOT/default/.deps-installed"
42fi
43exec opam exec --switch default -- "$@"
44