Mercurial > hg > piper-vamp-js-builds
diff repoint @ 55:bbcce33e758d
Update Repoint
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Wed, 16 May 2018 15:51:04 +0100 |
parents | 21e050f82be4 |
children |
line wrap: on
line diff
--- a/repoint Wed May 16 15:50:37 2018 +0100 +++ b/repoint Wed May 16 15:51:04 2018 +0100 @@ -4,12 +4,15 @@ # practice, not bad: clearer, safer, less error-prone. # shellcheck disable=SC2002 -sml="$VEXT_SML" +sml="$REPOINT_SML" set -eu +# avoid gussying up output +export HGPLAIN=true + mydir=$(dirname "$0") -program="$mydir/vext.sml" +program="$mydir/repoint.sml" hasher= local_install= @@ -27,12 +30,12 @@ if [ -n "$local_install" ]; then hash=$(echo "$sml" | cat "$program" - | $hasher | cut -c1-16) - gen_sml=$mydir/.vext-$hash.sml - gen_out=$mydir/.vext-$hash.bin + gen_sml=$mydir/.repoint-$hash.sml + gen_out=$mydir/.repoint-$hash.bin trap 'rm -f $gen_sml' 0 else - gen_sml=$(mktemp /tmp/vext-XXXXXXXX.sml) - gen_out=$(mktemp /tmp/vext-XXXXXXXX.bin) + gen_sml=$(mktemp /tmp/repoint-XXXXXXXX.sml) + gen_out=$(mktemp /tmp/repoint-XXXXXXXX.bin) trap 'rm -f $gen_sml $gen_out' 0 fi @@ -40,10 +43,10 @@ exec "$gen_out" "$@" fi -# We need one of Poly/ML, SML/NJ, or MLton. Since we're running a -# single-file SML program as if it were a script, our order of -# preference is based on startup speed, except in the local_install -# case where we retain a persistent binary. +# We need one of Poly/ML, SML/NJ, MLton, or MLKit. Since we're running +# a single-file SML program as if it were a script, our order of +# preference is usually based on startup speed. An exception is the +# local_install case, where we retain a persistent binary if [ -z "$sml" ]; then if [ -n "$local_install" ] && mlton 2>&1 | grep -q 'MLton'; then @@ -52,36 +55,44 @@ sml="smlnj" # We would prefer Poly/ML to SML/NJ, except that Poly v5.7 has a # nasty bug that occasionally causes it to deadlock on startup. - # That appears to be fixed in their repo, so we could promote it - # up the order again at some point in future + # That is fixed in v5.7.1, so we could promote it up the order + # again at some point in future elif echo | poly -v 2>/dev/null | grep -q 'Poly/ML'; then sml="poly" elif mlton 2>&1 | grep -q 'MLton'; then sml="mlton" + # MLKit is at the bottom because it leaves compiled files around + # in an MLB subdir in the current directory + elif mlkit 2>&1 | grep -q 'MLKit'; then + sml="mlkit" else cat 1>&2 <<EOF ERROR: No supported SML compiler or interpreter found EOF - cat <<EOF + cat 1>&2 <<EOF - The Vext external source code manager needs a Standard ML (SML) + The Repoint external source code manager needs a Standard ML (SML) compiler or interpreter to run. Please ensure you have one of the following SML implementations installed and present in your PATH, and try again. 1. Standard ML of New Jersey - - often found in a distribution package called: smlnj + - may be found in a distribution package called: smlnj - executable name: sml 2. Poly/ML - - often found in a distribution package called: polyml + - may be found in a distribution package called: polyml - executable name: poly 3. MLton - - often found in a distribution package called: mlton + - may be found in a distribution package called: mlton - executable name: mlton + 4. MLKit + - may be found in a distribution package called: mlkit + - executable name: mlkit + EOF exit 2 fi @@ -90,7 +101,7 @@ arglist="" for arg in "$@"; do if [ -n "$arglist" ]; then arglist="$arglist,"; fi - if echo "$arg" | grep -q '[^a-z]' ; then + if echo "$arg" | grep -q '["'"'"']' ; then arglist="$arglist\"usage\"" else arglist="$arglist\"$arg\"" @@ -105,15 +116,23 @@ fi "$gen_out" "$@" else - echo 'use "'"$program"'"; vext ['"$arglist"'];' | + echo 'use "'"$program"'"; repoint ['"$arglist"'];' | poly -q --error-exit fi ;; mlton) if [ ! -x "$gen_out" ]; then + echo "[Precompiling Repoint binary...]" 1>&2 echo "val _ = main ()" | cat "$program" - > "$gen_sml" mlton -output "$gen_out" "$gen_sml" fi "$gen_out" "$@" ;; + mlkit) + if [ ! -x "$gen_out" ]; then + echo "[Precompiling Repoint binary...]" 1>&2 + echo "val _ = main ()" | cat "$program" - > "$gen_sml" + mlkit -output "$gen_out" "$gen_sml" + fi + "$gen_out" "$@" ;; smlnj) cat "$program" | ( cat <<EOF @@ -135,13 +154,13 @@ EOF cat - cat <<EOF -val _ = vext [$arglist]; +val _ = repoint [$arglist]; val _ = OS.Process.exit (OS.Process.success); EOF ) > "$gen_sml" CM_VERBOSE=false sml "$gen_sml" ;; *) - echo "Unknown SML implementation name: $sml"; + echo "ERROR: Unknown SML implementation name: $sml" 1>&2; exit 2 ;; esac