comparison vext @ 1772:128c4544036d

Update Vext
author Chris Cannam
date Fri, 09 Mar 2018 09:00:48 +0000
parents bf4a7015033e
children
comparison
equal deleted inserted replaced
1771:bd14a0f69b60 1772:128c4544036d
5 # shellcheck disable=SC2002 5 # shellcheck disable=SC2002
6 6
7 sml="$VEXT_SML" 7 sml="$VEXT_SML"
8 8
9 set -eu 9 set -eu
10
11 # avoid gussying up output
12 export HGPLAIN=true
10 13
11 mydir=$(dirname "$0") 14 mydir=$(dirname "$0")
12 program="$mydir/vext.sml" 15 program="$mydir/vext.sml"
13 16
14 hasher= 17 hasher=
38 41
39 if [ -x "$gen_out" ]; then 42 if [ -x "$gen_out" ]; then
40 exec "$gen_out" "$@" 43 exec "$gen_out" "$@"
41 fi 44 fi
42 45
43 # We need one of Poly/ML, SML/NJ, or MLton. Since we're running a 46 # We need one of Poly/ML, SML/NJ, MLton, or MLKit. Since we're running
44 # single-file SML program as if it were a script, our order of 47 # a single-file SML program as if it were a script, our order of
45 # preference is based on startup speed, except in the local_install 48 # preference is usually based on startup speed. An exception is the
46 # case where we retain a persistent binary. 49 # local_install case, where we retain a persistent binary
47 50
48 if [ -z "$sml" ]; then 51 if [ -z "$sml" ]; then
49 if [ -n "$local_install" ] && mlton 2>&1 | grep -q 'MLton'; then 52 if [ -n "$local_install" ] && mlton 2>&1 | grep -q 'MLton'; then
50 sml="mlton" 53 sml="mlton"
51 elif sml -h 2>&1 | grep -q 'Standard ML of New Jersey'; then 54 elif sml -h 2>&1 | grep -q 'Standard ML of New Jersey'; then
52 sml="smlnj" 55 sml="smlnj"
53 # We would prefer Poly/ML to SML/NJ, except that Poly v5.7 has a 56 # We would prefer Poly/ML to SML/NJ, except that Poly v5.7 has a
54 # nasty bug that occasionally causes it to deadlock on startup. 57 # nasty bug that occasionally causes it to deadlock on startup.
55 # That appears to be fixed in their repo, so we could promote it 58 # That is fixed in v5.7.1, so we could promote it up the order
56 # up the order again at some point in future 59 # again at some point in future
57 elif echo | poly -v 2>/dev/null | grep -q 'Poly/ML'; then 60 elif echo | poly -v 2>/dev/null | grep -q 'Poly/ML'; then
58 sml="poly" 61 sml="poly"
59 elif mlton 2>&1 | grep -q 'MLton'; then 62 elif mlton 2>&1 | grep -q 'MLton'; then
60 sml="mlton" 63 sml="mlton"
64 # MLKit is at the bottom because it leaves compiled files around
65 # in an MLB subdir in the current directory
66 elif mlkit 2>&1 | grep -q 'MLKit'; then
67 sml="mlkit"
61 else cat 1>&2 <<EOF 68 else cat 1>&2 <<EOF
62 69
63 ERROR: No supported SML compiler or interpreter found 70 ERROR: No supported SML compiler or interpreter found
64 EOF 71 EOF
65 cat 1>&2 <<EOF 72 cat 1>&2 <<EOF
69 76
70 Please ensure you have one of the following SML implementations 77 Please ensure you have one of the following SML implementations
71 installed and present in your PATH, and try again. 78 installed and present in your PATH, and try again.
72 79
73 1. Standard ML of New Jersey 80 1. Standard ML of New Jersey
74 - often found in a distribution package called: smlnj 81 - may be found in a distribution package called: smlnj
75 - executable name: sml 82 - executable name: sml
76 83
77 2. Poly/ML 84 2. Poly/ML
78 - often found in a distribution package called: polyml 85 - may be found in a distribution package called: polyml
79 - executable name: poly 86 - executable name: poly
80 87
81 3. MLton 88 3. MLton
82 - often found in a distribution package called: mlton 89 - may be found in a distribution package called: mlton
83 - executable name: mlton 90 - executable name: mlton
91
92 4. MLKit
93 - may be found in a distribution package called: mlkit
94 - executable name: mlkit
84 95
85 EOF 96 EOF
86 exit 2 97 exit 2
87 fi 98 fi
88 fi 99 fi
113 echo "[Precompiling Vext binary...]" 1>&2 124 echo "[Precompiling Vext binary...]" 1>&2
114 echo "val _ = main ()" | cat "$program" - > "$gen_sml" 125 echo "val _ = main ()" | cat "$program" - > "$gen_sml"
115 mlton -output "$gen_out" "$gen_sml" 126 mlton -output "$gen_out" "$gen_sml"
116 fi 127 fi
117 "$gen_out" "$@" ;; 128 "$gen_out" "$@" ;;
129 mlkit)
130 if [ ! -x "$gen_out" ]; then
131 echo "[Precompiling Vext binary...]" 1>&2
132 echo "val _ = main ()" | cat "$program" - > "$gen_sml"
133 mlkit -output "$gen_out" "$gen_sml"
134 fi
135 "$gen_out" "$@" ;;
118 smlnj) 136 smlnj)
119 cat "$program" | ( 137 cat "$program" | (
120 cat <<EOF 138 cat <<EOF
121 val smlrun__cp = 139 val smlrun__cp =
122 let val x = !Control.Print.out in 140 let val x = !Control.Print.out in