From 445843f27798e371d34d91860b05bbf68fa37223 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 15 Feb 2019 15:48:16 -0800 Subject: 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. --- subx/c | 4 ---- subx/cb | 4 ---- subx/cr | 4 ---- subx/dcr | 4 ---- subx/dgen | 23 +++++++++++++++++++---- subx/drun | 5 ++++- subx/edit | 7 +++++-- subx/gen | 23 +++++++++++++++++++---- subx/run | 5 ++++- subx/test_layers | 7 ++++++- 10 files changed, 57 insertions(+), 29 deletions(-) delete mode 100755 subx/c delete mode 100755 subx/cb delete mode 100755 subx/cr delete mode 100755 subx/dcr 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 " + 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 " + echo "Usage: $0 " + 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 " + echo "Usage: $0 " + 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 " + 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 " + echo "Usage: $0 " + 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 -- cgit 1.4.1-2-gfad0 'n113' href='#n113'>113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239