aboutsummaryrefslogtreecommitdiff
path: root/bfc.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bfc.sh')
-rwxr-xr-xbfc.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/bfc.sh b/bfc.sh
new file mode 100755
index 0000000..4bc87c1
--- /dev/null
+++ b/bfc.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env sh
+
+set -e
+
+BFC="./build/bfc"
+SRC="$1"
+
+if [ -z "$SRC" ]; then
+ echo "usage: $0 <file.bf>" >&2
+ exit 1
+fi
+
+# silently build compiler if missing
+if [ ! -f "$BFC" ]; then
+ make -s || {
+ echo "build failed" >&2
+ exit 1
+ }
+fi
+
+# compile pipeline
+OUT=$(cat "$SRC" | "$BFC")
+
+echo "$OUT" | gcc -o ./bf.out -x c -