| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | if whichscip-shell system . . which. cygpath >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then OCAMLFINDSEP=\;; else OCAMLFINDSEP=:; fi |
| 4 | |
| 5 | if [scip-shell system . . `[`. "${BASH_SOURCE[0]}" ]; then |
| 6 | root="$(dirnamescip-shell system . . dirname. "${BASH_SOURCE[0]}")/../.." |
| 7 | # make path absolute if relative |
| 8 | root=$(cd "$root" && echoscip-shell system . . echo. "$PWD") |
| 9 | elif [scip-shell system . . `[`. -e "$PWD/dev/ci/ci-env.sh" ]; then |
| 10 | root=$PWD |
| 11 | else |
| 12 | >&2 echoscip-shell system . . echo. "BASH_SOURCE not working (too old bash version?)" |
| 13 | >&2 echoscip-shell system . . echo. "update bash or run this script from the rocq repository's root directory" |
| 14 | exit 1 |
| 15 | fi |
| 16 | |
| 17 | |
| 18 | # We can remove setting ROCQLIB and ROCQRUNTIMELIB from here, but better to |
| 19 | # wait until we have merged the coq.boot patch so we can do this in a |
| 20 | # more controlled way. |
| 21 | if [scip-shell system . . `[`. -n "${GITLAB_CI}" ]; |
| 22 | then |
| 23 | # Gitlab build, Rocq installed into `_install_ci` |
| 24 | export COQBIN="$root/_install_ci/bin" |
| 25 | export OCAMLPATH="$root/_install_ci/lib$OCAMLFINDSEP$OCAMLPATH" |
| 26 | export PATH="$root/_install_ci/bin:$PATH" |
| 27 | |
| 28 | # Where we install external binaries and ocaml libraries |
| 29 | # also generally used for dune install --prefix so needs to match coq's expected user-contrib path |
| 30 | CI_INSTALL_DIR="$root/_install_ci" |
| 31 | |
| 32 | export CI_BRANCH="$CI_COMMIT_REF_NAME" |
| 33 | if [[ ${CI_BRANCH#pr-} =~ ^[0-9]*$ ]] |
| 34 | then |
| 35 | export CI_PULL_REQUEST="${CI_BRANCH#pr-}" |
| 36 | fi |
| 37 | elif [scip-shell system . . `[`. -d "$root/_build/install/default/" ]; |
| 38 | then |
| 39 | # Full Dune build, we basically do what `dune exec --` does |
| 40 | export OCAMLPATH="$root/_build/install/default/lib/$OCAMLFINDSEP$OCAMLPATH" |
| 41 | export COQBIN="$root/_build/install/default/bin" |
| 42 | export ROCQLIB="$root/_build/install/default/lib/coq" |
| 43 | export ROCQRUNTIMELIB="$root/_build/install/default/lib/rocq-runtime" |
| 44 | |
| 45 | CI_INSTALL_DIR="$root/_build/install/default/" |
| 46 | |
| 47 | CI_BRANCH="$(gitscip-shell system . . git. rev-parse --abbrev-ref HEAD)" |
| 48 | export CI_BRANCH |
| 49 | fi |
| 50 | |
| 51 | export PATH="$COQBIN:$PATH" |
| 52 | |
| 53 | # Rocq's tools need an ending slash :S, we should fix them. |
| 54 | export COQBIN="$COQBIN/" |