#!/usr/bin/env bash # share logic between rec and reopt to set up rebuild configs setglobal MY_OCAML_BUILD = '"-o myocamlbuild'" if test -z $REASON_BUILD_DIR { setglobal REASON_BUILD_DIR = $[ocamlfind query reason] } if test -z $REASON_BUILD_DIR { echo "Couldn't find Reason" exit 1 } # Expand special subtitions like '~' eval REASON_BUILD_DIR=$REASON_BUILD_DIR if [[ "${@: -2}" = "${MY_OCAML_BUILD}" ]] { # # Remove "unix.cmxa" as myocamlbuild is already linked # with the library # # See https://github.com/facebook/Reason/issues/133 # setglobal UNIXIDX = '-1' setglobal i = '1' for var in [@Argv] { if [[ $var =~ "unix.cmxa" ]] { # # If there is already an unix.cmxa linked, remove the second one # if [[ $UNIXIDX -ne -1 ]] { set -- $(@:1:i-1) $(@: i+1) } setglobal UNIXIDX = $i } setglobal i = "$i+1" } # Link reason build rules set -- $(@:1:$#-3) "$REASON_BUILD_DIR/reasonbuild.cmx" $(@: -3) }