-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 16be25e
Showing
7 changed files
with
3,227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
syntax: glob | ||
*~ | ||
.repoint* | ||
ext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
#!/bin/bash | ||
|
||
# Disable shellcheck warnings for useless-use-of-cat. UUOC is good | ||
# practice, not bad: clearer, safer, less error-prone. | ||
# shellcheck disable=SC2002 | ||
|
||
sml="$REPOINT_SML" | ||
|
||
set -eu | ||
|
||
# avoid gussying up output | ||
export HGPLAIN=true | ||
|
||
mydir=$(dirname "$0") | ||
program="$mydir/repoint.sml" | ||
|
||
hasher= | ||
local_install= | ||
if [ -w "$mydir" ]; then | ||
if echo | sha256sum >/dev/null 2>&1 ; then | ||
hasher=sha256sum | ||
local_install=true | ||
elif echo | shasum >/dev/null 2>&1 ; then | ||
hasher=shasum | ||
local_install=true | ||
else | ||
echo "WARNING: sha256sum or shasum program not found" 1>&2 | ||
fi | ||
fi | ||
|
||
if [ -n "$local_install" ]; then | ||
hash=$(echo "$sml" | cat "$program" - | $hasher | cut -c1-16) | ||
gen_sml=$mydir/.repoint-$hash.sml | ||
gen_out=$mydir/.repoint-$hash.bin | ||
trap 'rm -f $gen_sml' 0 | ||
else | ||
gen_sml=$(mktemp /tmp/repoint-XXXXXXXX.sml) | ||
gen_out=$(mktemp /tmp/repoint-XXXXXXXX.bin) | ||
trap 'rm -f $gen_sml $gen_out' 0 | ||
fi | ||
|
||
if [ -x "$gen_out" ]; then | ||
exec "$gen_out" "$@" | ||
fi | ||
|
||
# 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 | ||
sml="mlton" | ||
elif sml -h 2>&1 | grep -q 'Standard ML of New Jersey'; then | ||
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 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="polyml" | ||
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 1>&2 <<EOF | ||
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 | ||
- may be found in a distribution package called: smlnj | ||
- executable name: sml | ||
2. Poly/ML | ||
- may be found in a distribution package called: polyml | ||
- executable name: poly | ||
3. 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 | ||
fi | ||
|
||
arglist="" | ||
for arg in "$@"; do | ||
if [ -n "$arglist" ]; then arglist="$arglist,"; fi | ||
if echo "$arg" | grep -q '["'"'"']' ; then | ||
arglist="$arglist\"usage\"" | ||
else | ||
arglist="$arglist\"$arg\"" | ||
fi | ||
done | ||
|
||
case "$sml" in | ||
polyml) | ||
if [ -n "$local_install" ] && polyc --help >/dev/null 2>&1 ; then | ||
if [ ! -x "$gen_out" ]; then | ||
polyc -o "$gen_out" "$program" | ||
fi | ||
"$gen_out" "$@" | ||
else | ||
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 | ||
val smlrun__cp = | ||
let val x = !Control.Print.out in | ||
Control.Print.out := { say = fn _ => (), flush = fn () => () }; | ||
x | ||
end; | ||
val smlrun__prev = ref ""; | ||
Control.Print.out := { | ||
say = fn s => | ||
(if String.isSubstring " Error" s | ||
then (Control.Print.out := smlrun__cp; | ||
(#say smlrun__cp) (!smlrun__prev); | ||
(#say smlrun__cp) s) | ||
else (smlrun__prev := s; ())), | ||
flush = fn s => () | ||
}; | ||
EOF | ||
cat - | ||
cat <<EOF | ||
val _ = repoint [$arglist]; | ||
val _ = OS.Process.exit (OS.Process.success); | ||
EOF | ||
) > "$gen_sml" | ||
CM_VERBOSE=false sml "$gen_sml" ;; | ||
*) | ||
echo "ERROR: Unknown SML implementation name: $sml" 1>&2; | ||
exit 2 ;; | ||
esac | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"libraries": { | ||
"sml-buildscripts": { | ||
"pin": "0753a33f4456" | ||
}, | ||
"sml-stringinterpolate": { | ||
"pin": "b2ef1dd1d62b" | ||
}, | ||
"sml-log": { | ||
"pin": "0084064e40bf" | ||
}, | ||
"sml-smlnj-containers": { | ||
"pin": "2c094258f541" | ||
}, | ||
"sml-trie": { | ||
"pin": "f78215386849" | ||
}, | ||
"sml-utf8": { | ||
"pin": "45d450aedb1f" | ||
}, | ||
"sml-ttl": { | ||
"pin": "16094f9666fc" | ||
}, | ||
"sml-svg": { | ||
"pin": "991249a8486e" | ||
}, | ||
"sml-simplejson": { | ||
"pin": "3ea6adb289e9" | ||
}, | ||
"sml-subxml": { | ||
"pin": "900f74b5b2ef" | ||
}, | ||
"sml-wavefile": { | ||
"pin": "e4e284191d2a" | ||
}, | ||
"sml-fft": { | ||
"pin": "47eeecf2ab8c" | ||
}, | ||
"bsq-signalbits": { | ||
"pin": "d9f2f73d8ec1" | ||
}, | ||
"bsq-test": { | ||
"pin": "b0e0c40c247e" | ||
}, | ||
"bsq-resampler": { | ||
"pin": "7586aaa85906" | ||
}, | ||
"bsq-matrix": { | ||
"pin": "4031e1729486" | ||
}, | ||
"bsq-bq": { | ||
"pin": "7e77d0494330" | ||
}, | ||
"bsq-samplestreams": { | ||
"pin": "241dd32db315" | ||
}, | ||
"bsq-cqt": { | ||
"pin": "2abe00cc31b4" | ||
}, | ||
"ext/bqvec": { | ||
"pin": "95499bc80035" | ||
}, | ||
"ext/bqfft": { | ||
"pin": "5a5fb028fee3" | ||
}, | ||
"ext/bqaudiostream": { | ||
"pin": "5e95bb2b5297" | ||
}, | ||
"ext/bqaudioio": { | ||
"pin": "367419ef92e9" | ||
}, | ||
"ext/bqresample": { | ||
"pin": "4b5d980c766b" | ||
}, | ||
"ext/bqthingfactory": { | ||
"pin": "427e5dc9e564" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
{ | ||
"config": { | ||
"extdir": "." | ||
}, | ||
"libraries": { | ||
"sml-buildscripts": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"sml-stringinterpolate": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"sml-log": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"sml-smlnj-containers": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"sml-trie": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"sml-utf8": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"sml-ttl": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"sml-svg": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"sml-simplejson": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"sml-subxml": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"sml-wavefile": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"sml-fft": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"bsq-signalbits": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"bsq-test": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"bsq-resampler": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"bsq-matrix": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"bsq-bq": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"bsq-samplestreams": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"bsq-cqt": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "cannam" | ||
}, | ||
"ext/bqvec": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "breakfastquay" | ||
}, | ||
"ext/bqfft": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "breakfastquay" | ||
}, | ||
"ext/bqaudiostream": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "breakfastquay" | ||
}, | ||
"ext/bqaudioio": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "breakfastquay" | ||
}, | ||
"ext/bqresample": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "breakfastquay" | ||
}, | ||
"ext/bqthingfactory": { | ||
"vcs": "hg", | ||
"service": "sourcehut", | ||
"owner": "breakfastquay" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dpn0.ps1' %*"; | ||
|
Oops, something went wrong.