M README.md +1 -1
@@ 168,7 168,7 @@ Further notes
Author, copyright, and licence
------------------------------
-Written by Chris Cannam, copyright 2015-2018.
+Written by Chris Cannam, copyright 2015-2022.
These scripts are provided under the MIT licence:
M mlb-coverage +1 -1
@@ 144,7 144,7 @@ summarise_for() {
if [ "$srcfile" = "" ]; then
summarise_for "sml"
- expand_arg "$mlb" | grep -v '^/' | grep -v '\.sig$' | LANG=C LC_ALL=C sort |
+ expand_arg -u "$mlb" | grep -v '^/' | grep -v '\.sig$' | LANG=C LC_ALL=C sort |
while read x; do
summarise_for "$x" ;
done
M mlb-dependencies +2 -2
@@ 3,7 3,7 @@
# mlb-dependencies - read a MLB file defining an SML program and print
# out a dependency list in Makefile format
#
-# Chris Cannam, 2015-2018. MIT licence
+# Chris Cannam, 2015-2022. MIT licence
set -e
@@ 27,5 27,5 @@ base=$(get_outfile "$arg")
# resolving the distinction (in order to keep regression tests passing
# across platforms) was too much of a faff for a small aesthetic gain
-expand_arg "$arg" | sed 's|^|'"$base"': |'
+expand_arg -u "$arg" | sed 's|^|'"$base"': |'
M mlb-expand +15 -3
@@ 3,14 3,22 @@
# mlb-dependencies - read a MLB file defining an SML program and print
# out a list of the files referred to by it and any subsidiary MLB files
#
-# Chris Cannam, 2015-2018. MIT licence
+# Chris Cannam, 2015-2022. MIT licence
set -e
+unique=no
+if [ "$1" = "-u" ]; then
+ unique=yes
+ shift
+fi
+
arg="$1"
if [ -z "$arg" ]; then
- echo "Usage: $0 file.mlb" 1>&2
+ echo "Usage: $0 [-u] file.mlb" 1>&2
+ echo " where" 1>&2
+ echo " -u: List each file only the first time it appears (unique list)" 1>&2
exit 2
fi
@@ 21,5 29,9 @@ mydir=$(dirname "$0")
base=$(get_outfile "$arg")
-expand_arg "$arg"
+if [ "$unique" = "yes" ]; then
+ expand_arg -u "$arg"
+else
+ expand_arg "$arg"
+fi
M polybuild +25 -4
@@ 2,17 2,38 @@
#
# polybuild - compile a SML program defined in a MLB file using Poly/ML
#
-# Chris Cannam, 2015-2018. MIT licence
+# Chris Cannam, 2015-2022. MIT licence
set -e
usage() {
me=$(basename "$0")
+ echo 1>&2
+ echo "$me: Compile a SML program defined in a MLB file using Poly/ML" 1>&2
+ echo 1>&2
echo "Usage: $me [-o output] file.sml" 1>&2
- echo " $me [-o output] file.mlb" 1>&2
- exit 1
+ echo " $me [-u] [-o output] file.mlb" 1>&2
+ echo " where" 1>&2
+ echo " -u: Unique: \"use\" each file only once, regardless of how many times it" 1>&2
+ echo " appears in the MLB file and its dependencies. The default is to use" 1>&2
+ echo " a file again each time it appears." 1>&2
+ echo " Neither mode complies with the official interpretation for MLB files" 1>&2
+ echo " in this respect (that's much harder to do). Both modes may compile" 1>&2
+ echo " code that the other mode does not!" 1>&2
+ echo " Unique mode is usually faster and is never much slower." 1>&2
+ echo 1>&2
+ echo "This script is not part of Poly/ML and has no official status." 1>&2
+ echo "Written by Chris Cannam, 2015-2022." 1>&2
+ echo 1>&2
+ exit 2
}
+unique_arg=""
+if [ "$1" = "-u" ]; then
+ unique_arg="-u"
+ shift
+fi
+
arg="$1"
[ -n "$arg" ] || usage
@@ 42,7 63,7 @@ tmpobj=$(get_tmpobjfile "$arg")
trap "rm -f ${tmpobj}" 0
-( expand_arg "$arg" |
+( expand_arg $unique_arg "$arg" |
sed 's|^\(.*\)$|use "\1";|' ; # wrap filenames in REPL use calls
echo 'PolyML.export("'"$tmpobj"'", main);' ) | # ask poly to export object file
poly -q --error-exit &&
M polyrepl +25 -8
@@ 3,10 3,31 @@
# polyrepl - load a SML program defined in a MLB file into the Poly/ML
# interactive environment
#
-# Chris Cannam, 2015-2018. MIT licence
+# Chris Cannam, 2015-2022. MIT licence
set -e
+usage() {
+ me=$(basename "$0")
+ echo 1>&2
+ echo "$me: Load a SML program defined in a MLB file into the Poly/ML repl" 1>&2
+ echo 1>&2
+ echo "Usage: $me [-d] file.sml" 1>&2
+ echo " $me [-u] [-d] file.mlb" 1>&2
+ echo "where" 1>&2
+ echo " -u: Unique: \"use\" each file only once, regardless of how many times it" 1>&2
+ echo " appears in the MLB file. See \"polybuild\" for discussion." 1>&2
+ echo " -d: Enable Poly/ML compiler debug mode before reading SML source." 1>&2
+ echo 1>&2
+ exit 2
+}
+
+unique_arg=""
+if [ "$1" = "-u" ]; then
+ unique_arg="-u"
+ shift
+fi
+
debug=no
if [ "$1" = "-d" ]; then
debug=yes
@@ 16,11 37,7 @@ fi
arg="$1"
if [ -z "$arg" ]; then
- echo "Usage: $0 [-d] file.sml" 1>&2
- echo " $0 [-d] file.mlb" 1>&2
- echo "where" 1>&2
- echo " -d: Enable Poly/ML compiler debug mode before reading SML source" 1>&2
- exit 1
+ usage
fi
shift
@@ 32,9 49,9 @@ mydir=$(dirname "$0")
out=$(get_outfile "$arg") # we don't use this, but it does some arg error checking
if [ "$debug" = "yes" ]; then
- rlwrap poly --eval 'PolyML.Compiler.debug := true;' $(expand_arg "$arg" | sed 's/^\(.*\)$/--use \1/') --eval '"Entering trace mode; evaluate `PolyML.Debug.trace false` to leave";' --eval 'PolyML.Debug.trace true;'
+ rlwrap poly --eval 'PolyML.Compiler.debug := true;' $(expand_arg $unique_arg "$arg" | sed 's/^\(.*\)$/--use \1/') --eval '"Entering trace mode; evaluate `PolyML.Debug.trace false` to leave";' --eval 'PolyML.Debug.trace true;'
else
- rlwrap poly $(expand_arg "$arg" | sed 's/^\(.*\)$/--use \1/')
+ rlwrap poly $(expand_arg -u "$arg" | sed 's/^\(.*\)$/--use \1/')
fi
M polyrun +23 -4
@@ 6,12 6,31 @@
set -e
+usage() {
+ me=$(basename "$0")
+ echo 1>&2
+ echo "$me: Run a SML program defined in a MLB file using Poly/ML" 1>&2
+ echo 1>&2
+ echo "Usage: $me file.sml" 1>&2
+ echo " $me [-u] file.mlb" 1>&2
+ echo 1>&2
+ echo "where" 1>&2
+ echo " -u: Unique: \"use\" each file only once, regardless of how many times it" 1>&2
+ echo " appears in the MLB file. See \"polybuild\" for discussion." 1>&2
+ echo 1>&2
+ exit 2
+}
+
+unique_arg=""
+if [ "$1" = "-u" ]; then
+ unique_arg="-u"
+ shift
+fi
+
arg="$1"
if [ -z "$arg" ]; then
- echo "Usage: $0 file.sml" 1>&2
- echo " $0 file.mlb" 1>&2
- exit 2
+ usage
fi
shift
@@ 25,7 44,7 @@ tmpobj=$(get_tmpobjfile "$arg")
tmpout=$(get_tmpfile "$arg")
trap "rm -f ${tmpobj} ${tmpout}" 0
-( expand_arg "$arg" | \
+( expand_arg $unique_arg "$arg" | \
sed 's|^\(.*\)$|use "\1";|' ;
echo 'PolyML.export("'"$tmpobj"'", main);' ) | \
poly -q --error-exit &&
M smlbuild-include.sh +1 -1
@@ 1,6 1,6 @@
#!/bin/bash
#
-# Chris Cannam, 2015-2018. MIT licence
+# Chris Cannam, 2015-2022. MIT licence
# Disable shellcheck warnings for useless-use-of-cat. UUOC is good
# practice, not bad: clearer, safer, less error-prone.
M smlrepl +23 -6
@@ 3,23 3,40 @@
# smlrepl - load a SML program defined in a MLB file into the SML/NJ
# interactive environment
#
-# Chris Cannam, 2015-2018. MIT licence
+# Chris Cannam, 2015-2022. MIT licence
set -e
+usage() {
+ me=$(basename "$0")
+ echo 1>&2
+ echo "$me: Load a SML program defined in a MLB file into the SML/NJ repl" 1>&2
+ echo 1>&2
+ echo "Usage: $me file.sml" 1>&2
+ echo " $me [-u] file.mlb" 1>&2
+ echo "where" 1>&2
+ echo " -u: Unique: \"use\" each file only once, regardless of how many times it" 1>&2
+ echo " appears in the MLB file. See \"polybuild\" for discussion." 1>&2
+ echo 1>&2
+ exit 2
+}
+
if echo | sml | grep -q Jersey ; then :
else
echo "*** Error: SML/NJ binary 'sml' not in path" 1>&2
exit 1
fi
+unique_arg=""
+if [ "$1" = "-u" ]; then
+ unique_arg="-u"
+ shift
+fi
+
arg="$1"
if [ -z "$arg" ]; then
- echo "Usage: $0 [-v] file.sml" 1>&2
- echo " $0 [-v] file.mlb" 1>&2
- echo " where" 1>&2
- exit 1
+ usage
fi
shift
@@ 33,7 50,7 @@ tmpout=$(get_tmpsmlfile "$arg")
trap "rm -f ${tmpout}" 0
-expand_arg "$arg" | \
+expand_arg $unique_arg "$arg" | \
sed 's/^\(.*\)$/use "\1";/' > \
"$tmpout"
M smlrun +25 -8
@@ 2,16 2,37 @@
#
# smlrun - run a SML program defined in a SML or MLB file using SML/NJ
#
-# Chris Cannam, 2015-2018. MIT licence
+# Chris Cannam, 2015-2022. MIT licence
set -e
+usage() {
+ me=$(basename "$0")
+ echo 1>&2
+ echo "$me: Run a SML program defined in a MLB file using SML/NJ" 1>&2
+ echo 1>&2
+ echo "Usage: $me [-v] file.sml" 1>&2
+ echo " $me [-u] [-v] file.mlb" 1>&2
+ echo "where" 1>&2
+ echo " -u: Unique: \"use\" each file only once, regardless of how many times it" 1>&2
+ echo " appears in the MLB file. See \"polybuild\" for discussion." 1>&2
+ echo " -v: Verbose: Do not suppress output from interactive environment." 1>&2
+ echo 1>&2
+ exit 2
+}
+
if echo | sml | grep -q Jersey ; then :
else
echo "*** Error: SML/NJ binary 'sml' not in path" 1>&2
exit 1
fi
+unique_arg=""
+if [ "$1" = "-u" ]; then
+ unique_arg="-u"
+ shift
+fi
+
verbose=no
if [ "$1" = "-v" ]; then
verbose=yes
@@ 21,11 42,7 @@ fi
arg="$1"
if [ -z "$arg" ]; then
- echo "Usage: $0 [-v] file.sml" 1>&2
- echo " $0 [-v] file.mlb" 1>&2
- echo " where" 1>&2
- echo " -v: Do not suppress output from interactive environment" 1>&2
- exit 2
+ usage
fi
shift
@@ 41,7 58,7 @@ trap "rm -f ${tmpout}" 0
case "$verbose" in
yes)
- expand_arg "$arg" | \
+ expand_arg -u "$arg" | \
sed 's/^\(.*\)$/use "\1";/' | # wrap filenames in REPL use calls
(
cat -
@@ 55,7 72,7 @@ EOF
;;
no)
- expand_arg "$arg" | \
+ expand_arg -u "$arg" | \
sed 's/^\(.*\)$/use "\1";/' | # wrap filenames in REPL use calls
(
cat <<EOF