| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -ex |
| 4 | |
| 5 | rocq=$(command -v rocq) |
| 6 | # NB on cygwin "$rocq" is a cygwin path (/foo/bar) |
| 7 | # but reading files from hash.exe needs windows paths (C:/cygwin/foo/bar) |
| 8 | # we avoid the problem by going through stdin |
| 9 | rocqhash=$(dune exec --root "$(dirname "$0")"/.. -- etc/tools/hash.exe < "$rocq") |
| 10 | |
| 11 | rm -rf .wrappers |
| 12 | mkdir .wrappers |
| 13 | |
| 14 | cat > .wrappers/coqc <<EOF |
| 15 | #!/bin/sh |
| 16 | # hash = $rocqhash |
| 17 | exec rocq c "\$@" |
| 18 | EOF |
| 19 | |
| 20 | cat > .wrappers/coqdep <<EOF |
| 21 | #!/bin/sh |
| 22 | # hash = $rocqhash |
| 23 | exec rocq dep "\$@" |
| 24 | EOF |
| 25 | |
| 26 | cat > .wrappers/coqdoc <<EOF |
| 27 | #!/bin/sh |
| 28 | # hash = $rocqhash |
| 29 | exec rocq doc "\$@" |
| 30 | EOF |
| 31 | |
| 32 | cat > .wrappers/coqpp <<EOF |
| 33 | #!/bin/sh |
| 34 | # hash = $rocqhash |
| 35 | exec rocq pp-mlg "\$@" |
| 36 | EOF |
| 37 | |
| 38 | chmod +x .wrappers/coqc .wrappers/coqdep .wrappers/coqdoc .wrappers/coqpp |
| 39 | |
| 40 | ln -s "$(ocamlfind query rocq-runtime.kernel)" .wrappers/kernel |
| 41 | |
| 42 | # fake coq-core.kernel ... for dune (mode native) |
| 43 | cat > .wrappers/META.coq-core <<EOF |
| 44 | package "kernel" ( |
| 45 | directory = "kernel" |
| 46 | version = "dev" |
| 47 | description = "The Rocq Kernel" |
| 48 | requires = "dynlink rocq-runtime.boot rocq-runtime.lib rocq-runtime.vm" |
| 49 | archive(byte) = "kernel.cma" |
| 50 | archive(native) = "kernel.cmxa" |
| 51 | plugin(byte) = "kernel.cma" |
| 52 | plugin(native) = "kernel.cmxs" |
| 53 | ) |
| 54 | EOF |
| 55 | |
| 56 | export PATH="$PWD/.wrappers:$PATH" |
| 57 | export OCAMLPATH="$PWD/.wrappers:$OCAMLPATH" |
| 58 | |
| 59 | "$@" |