diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-02-15 15:48:16 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-02-15 15:48:16 -0800 |
commit | 445843f27798e371d34d91860b05bbf68fa37223 (patch) | |
tree | 51f1b76a05f33dd6e31217ca345d320febdc5fbd | |
parent | 2dc9b6955b7d2588de65b472d8b9690945ce4107 (diff) | |
download | mu-445843f27798e371d34d91860b05bbf68fa37223.tar.gz |
4971 - clean up a few scripts
Some of them are no longer useful; drop them. For the rest, have useful usage messages. And also be a little more principled in where we introduce CFLAGS, and where we expect it to come in from the commandline. I'm choosing not to call gen/run/dgen/drun from test_layers because it makes test_layers harder for newcomers to read. The scripts aren't the first thing people should see, they're just useful once you're up and running hacking on SubX.
-rwxr-xr-x | subx/c | 4 | ||||
-rwxr-xr-x | subx/cb | 4 | ||||
-rwxr-xr-x | subx/cr | 4 | ||||
-rwxr-xr-x | subx/dcr | 4 | ||||
-rwxr-xr-x | subx/dgen | 23 | ||||
-rwxr-xr-x | subx/drun | 5 | ||||
-rwxr-xr-x | subx/edit | 7 | ||||
-rwxr-xr-x | subx/gen | 23 | ||||
-rwxr-xr-x | subx/run | 5 | ||||
-rwxr-xr-x | subx/test_layers | 7 |
10 files changed, 57 insertions, 29 deletions
diff --git a/subx/c b/subx/c deleted file mode 100755 index ddfde99a..00000000 --- a/subx/c +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env zsh -# Make editing various versions of the Crenshaw compiler even more convenient. - -./edit crenshaw$1 diff --git a/subx/cb b/subx/cb deleted file mode 100755 index 924d9c9e..00000000 --- a/subx/cb +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env zsh -# Make building various versions of the Crenshaw compiler even more convenient. - -gen crenshaw$1 diff --git a/subx/cr b/subx/cr deleted file mode 100755 index e8ccb420..00000000 --- a/subx/cr +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env zsh -# Make running various versions of the Crenshaw compiler even more convenient. - -run crenshaw$1 diff --git a/subx/dcr b/subx/dcr deleted file mode 100755 index 938dbb56..00000000 --- a/subx/dcr +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env zsh -# Make opening various versions of the Crenshaw compiler even more convenient. - -./dgen crenshaw$1 && ./drun crenshaw$1 diff --git a/subx/dgen b/subx/dgen index c4afbfb2..34f49deb 100755 --- a/subx/dgen +++ b/subx/dgen @@ -1,11 +1,26 @@ -#!/usr/bin/env zsh -# Build commonly-used SubX programs in 'debug mode'. +#!/bin/sh +# Little helper to quickly build SubX programs in 'debug mode' from the commandline. +# Only works for programs in some standard places the repo knows about. + +if [ $# -eq 0 ] +then + echo "Usage: $0 <file root without subdirectory or .subx extension>" + echo + echo "Naming convention: Files starting with 'ex' will be assumed to live in examples/ and be self-contained." + echo "Other files will be assumed to live in apps/ and need the standard library." + exit 1 +fi + +# Build in debug mode since the common case at the moment is building small +# files. To override, calling scripts should do their own builds to ensure +# subx_bin is up to date. +export CFLAGS=-g if [[ $1 == 'ex'* ]] then - CFLAGS=-g ./subx --map translate examples/$1.subx -o examples/`echo $1 |sed 's/\..*//'` + ./subx --map translate examples/$1.subx -o examples/`echo $1 |sed 's/\..*//'` exit $? fi -CFLAGS=-g ./subx --map translate *.subx apps/$1.subx -o apps/`echo $1 |sed 's/\..*//'` +./subx --map translate *.subx apps/$1.subx -o apps/`echo $1 |sed 's/\..*//'` exit $? diff --git a/subx/drun b/subx/drun index 87092a9d..82584772 100755 --- a/subx/drun +++ b/subx/drun @@ -3,7 +3,10 @@ if [ $# -eq 0 ] then - echo "drun <binary> <args>" + echo "Usage: $0 <binary name without directory> <args>" + echo + echo "Naming convention: Binaries starting with 'ex' will be assumed to live in examples/" + echo "Other binaries will be assumed to live in apps/" exit 1 fi diff --git a/subx/edit b/subx/edit index ef20d85f..dc434f58 100755 --- a/subx/edit +++ b/subx/edit @@ -1,9 +1,12 @@ #!/usr/bin/env zsh -# Open commonly-used SubX programs. +# Helper to more conveniently open commonly-used SubX programs. if [ $# -eq 0 ] then - echo "edit <file>" + echo "Usage: $0 <file root without subdirectory or .subx extension>" + echo + echo "Naming convention: Files starting with 'ex' will be assumed to live in examples/" + echo "Other files will be assumed to live in apps/" exit 1 fi diff --git a/subx/gen b/subx/gen index 91370ea4..a2f1de4a 100755 --- a/subx/gen +++ b/subx/gen @@ -1,11 +1,26 @@ -#!/usr/bin/env zsh -# Build commonly-used SubX programs. +#!/bin/sh +# Little helper to quickly build SubX programs from the commandline. +# Only works for programs in some standard places the repo knows about. + +if [ $# -eq 0 ] +then + echo "Usage: $0 <file root without subdirectory or .subx extension>" + echo + echo "Naming convention: Files starting with 'ex' will be assumed to live in examples/ and be self-contained." + echo "Other files will be assumed to live in apps/ and need the standard library." + exit 1 +fi + +# Build in debug mode since the common case at the moment is building small +# files. To override, calling scripts should do their own builds to ensure +# subx_bin is up to date. +export CFLAGS=-g if [[ $1 == 'ex'* ]] then - CFLAGS=-g ./subx translate examples/$1.subx -o examples/`echo $1 |sed 's/\..*//'` + ./subx translate examples/$1.subx -o examples/`echo $1 |sed 's/\..*//'` exit $? fi -CFLAGS=-g ./subx translate *.subx apps/$1.subx -o apps/`echo $1 |sed 's/\..*//'` +./subx translate *.subx apps/$1.subx -o apps/`echo $1 |sed 's/\..*//'` exit $? diff --git a/subx/run b/subx/run index 87fa5569..cbb3e576 100755 --- a/subx/run +++ b/subx/run @@ -3,7 +3,10 @@ if [ $# -eq 0 ] then - echo "run <binary> <args>" + echo "Usage: $0 <binary name without directory> <args>" + echo + echo "Naming convention: Binaries starting with 'ex' will be assumed to live in examples/" + echo "Other binaries will be assumed to live in apps/" exit 1 fi diff --git a/subx/test_layers b/subx/test_layers index 5f210c31..306f5d3a 100755 --- a/subx/test_layers +++ b/subx/test_layers @@ -13,9 +13,14 @@ do ./build_and_test_until $f done +# build everything one last time +clean +CFLAGS=$CFLAGS ./build # build optimized by default since we'll be running it repeatedly below + # add SubX files one at a time for f in [0-9]*.subx do echo "=== $f" - CFLAGS=-g ./subx translate $(../enumerate/enumerate --until $f |grep '\.subx$') -o foo && ./subx run foo + ./subx translate $(../enumerate/enumerate --until $f |grep '\.subx$') -o foo && ./subx run foo + echo done |