bootstrap: Add bootstrap build scripts.
authorJan Nieuwenhuizen <janneke@gnu.org>
Fri, 24 Nov 2017 18:02:58 +0000 (19:02 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Fri, 24 Nov 2017 18:02:58 +0000 (19:02 +0100)
* build.sh: New file.
* check-mescc.sh: New file.
* check.sh: New file.
* install.sh: New File.

.gitignore
build.sh [new file with mode: 0755]
check-mescc.sh [new file with mode: 0755]
check.sh [new file with mode: 0755]
install.sh [new file with mode: 0755]
test.sh [new file with mode: 0755]
tests/psyntax.test

index c9c64902155be402c7adebb6fc181521a9922b23..4ab37c9137917c0916b89c692f6ef0f114f7206a 100644 (file)
@@ -31,6 +31,7 @@
 /.tarball-version
 /ChangeLog
 /a.out
+*.mes-out
 
 #keep this: bootstrap
 #/mes.mes
diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
index 0000000..b34aea2
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+
+set -ex
+
+HEX2=${HEX2-hex2}
+M1=${M1-M1}
+MES_SEED=${MES_SEED-../mes-seed}
+
+$M1 --LittleEndian --Architecture=1\
+    -f stage0/x86.M1\
+    -f $MES_SEED/crt1.M1\
+    > crt1.hex2
+$M1 --LittleEndian --Architecture=1\
+    -f stage0/x86.M1\
+    -f $MES_SEED/libc-mes.M1\
+    > libc-mes.hex2
+$M1 --LittleEndian --Architecture=1\
+    -f stage0/x86.M1\
+    -f $MES_SEED/mes.M1\
+    > mes.hex2
+$HEX2 --LittleEndian --Architecture=1 --BaseAddress=0x1000000\
+      -f stage0/elf32-header.hex2\
+      -f crt1.hex2\
+      -f libc-mes.hex2\
+      -f mes.hex2\
+      -f stage0/elf32-footer-single-main.hex2\
+      > mes
+chmod +x mes
+
+#TODO: after building from seed, build from src/mes.c
+
+$M1 --LittleEndian --Architecture=1 -f\
+    stage0/x86.M1\
+    -f $MES_SEED/libc-mes+tcc.M1\
+    > libc-mes+tcc.hex2
diff --git a/check-mescc.sh b/check-mescc.sh
new file mode 100755 (executable)
index 0000000..fc6a204
--- /dev/null
@@ -0,0 +1,104 @@
+#! /bin/sh
+
+GUILE=${GUILE-guile}
+MES=${MES-./mes}
+M1=${M1-M1}
+HEX2=${HEX2-hex2}
+MESCC=${MESCC-guile/mescc.scm}
+MES_PREFIX=${MES_PREFIX-.}
+
+tests="
+t
+00-exit-0
+01-return-0
+02-return-1
+03-call
+04-call-0
+05-call-1
+06-call-!1
+10-if-0
+11-if-1
+12-if-==
+13-if-!=
+14-if-goto
+15-if-!f
+16-if-t
+20-while
+21-char[]
+22-while-char[]
+23-pointer
+30-strlen
+31-eputs
+32-compare
+33-and-or
+34-pre-post
+35-compare-char
+36-compare-arithmetic
+37-compare-assign
+38-compare-call
+40-if-else
+41-?
+42-goto-label
+43-for-do-while
+44-switch
+45-void-call
+50-assert
+51-strcmp
+52-itoa
+53-strcpy
+54-argv
+60-math
+61-array
+63-struct-cell
+64-make-cell
+65-read
+70-printf
+71-struct-array
+72-typedef-struct-def
+73-union
+74-multi-line-string
+75-struct-union
+76-pointer-arithmetic
+77-pointer-assign
+78-union-struct
+79-int-array
+7a-struct-char-array
+7b-struct-int-array
+7c-dynarray
+7d-cast-char
+7e-struct-array-access
+7f-struct-pointer-arithmetic
+7g-struct-byte-word-field
+7h-struct-assign
+7i-struct-struct
+7j-strtoull
+7k-for-each-elem
+7l-struct-any-size-array
+7m-struct-char-array-assign
+7n-struct-struct-array
+"
+
+if [ ! -x ./i686-unknown-linux-gnu-tcc ]; then
+    tests=$(echo "$tests" | grep -Ev "02-return-1|05-call-1")
+fi
+
+set +e
+fail=0
+total=0
+for t in $tests; do
+    sh test.sh "$t" &> scaffold/tests/$t.log
+    r=$?
+    total=$((total+1))
+    if [ $r = 0 ]; then
+        echo $t: [OK]
+    else
+        echo $t: [FAIL]
+        fail=$((fail+1))
+    fi
+done
+if [ $fail != 0 ]; then
+    echo FAILED: $fail/$total
+    exit 1
+else
+    echo PASS: $total
+fi
diff --git a/check.sh b/check.sh
new file mode 100755 (executable)
index 0000000..7494c38
--- /dev/null
+++ b/check.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+
+export GUILE=${GUILE-guile}
+export MES=${MES-./mes}
+
+tests="
+tests/read.test
+tests/base.test
+tests/closure.test
+tests/quasiquote.test
+tests/let.test
+tests/scm.test
+tests/display.test
+tests/cwv.test
+tests/math.test
+tests/vector.test
+tests/srfi-1.test
+tests/srfi-13.test
+tests/srfi-14.test
+tests/optargs.test
+tests/fluids.test
+tests/catch.test
+tests/psyntax.test
+tests/pmatch.test
+tests/let-syntax.test
+tests/guile.test
+tests/record.test
+"
+
+slow="
+tests/match.test
+tests/peg.test
+"
+
+tests=$(for t in $tests; do echo $t-guile; echo $t; done)
+
+set +e
+fail=0
+total=0
+for t in $tests; do
+    sh "$t" &> $t.log
+    r=$?
+    total=$((total+1))
+    if [ $r = 0 ]; then
+        echo $t: [OK]
+    else
+        echo $t: [FAIL]
+        fail=$((fail+1))
+    fi
+done
+if [ $fail != 0 ]; then
+    echo FAILED: $fail/$total
+    exit 1
+else
+    echo PASS: $total
+fi
+
+sh check-mescc.sh
diff --git a/install.sh b/install.sh
new file mode 100755 (executable)
index 0000000..deedb97
--- /dev/null
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+set -e
+
+PREFIX=${PREFIX-usr}
+MES_PREFIX=${MES_PREFIX-$PREFIX/share/mes}
+MES_SEED=${MES_SEED-../mes-seed}
+TINYCC_SEED=${TINYCC_SEED-../tinycc-seed}
+
+mkdir -p $PREFIX/bin
+cp mes $PREFIX/bin/mes
+
+mkdir -p $PREFIX/lib
+mkdir -p $MES_PREFIX/lib
+cp $MES_SEED/crt1.M1 $MES_PREFIX/lib/crt1.M1
+cp $MES_SEED/libc-mes.M1 $MES_PREFIX/lib/libc-mes.M1
+cp $MES_SEED/libc-mes+tcc.M1 $MES_PREFIX/lib/libc-mes+tcc.M1
+
+cp crt1.hex2 $MES_PREFIX/lib/crt1.hex2
+cp libc-mes.hex2 $MES_PREFIX/lib/libc-mes.hex2
+cp libc-mes+tcc.hex2 $MES_PREFIX/lib/libc-mes+tcc.hex2
+
+cp scripts/mescc.mes $PREFIX/bin/mescc.mes
+cp guile/mescc.scm $PREFIX/bin/mescc.scm
+
+mkdir -p $MES_PREFIX
+tar -cf- doc guile include lib module scaffold stage0 | tar -xf- -C $MES_PREFIX
diff --git a/test.sh b/test.sh
new file mode 100755 (executable)
index 0000000..37dfc7b
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+
+set -ex
+
+t=${1-t}
+rm -f "$t".i686-unknown-linux-gnu-out
+rm -f "$t".mes-out
+
+M1=${M1-M1}
+HEX2=${HEX2-hex2}
+MESCC=${MESCC-sh guile/mescc.scm}
+
+$MESCC -E -o scaffold/tests/$t.E scaffold/tests/$t.c
+$MESCC -c -o scaffold/tests/$t.M1 scaffold/tests/$t.E
+$M1 --LittleEndian --Architecture=1\
+    -f stage0/x86.M1\
+    -f scaffold/tests/$t.M1\
+    >  scaffold/tests/$t.hex2
+
+$MESCC -E -o lib/crt1.E lib/crt1.c
+$MESCC -c -o lib/crt1.M1 lib/crt1.E
+$M1 --LittleEndian --Architecture=1 \
+    -f stage0/x86.M1\
+    -f lib/crt1.M1\
+    > lib/crt1.hex2
+$MESCC -E -o lib/libc-mes.E lib/libc-mes.c
+$MESCC -c -o lib/libc-mes.M1 lib/libc-mes.E
+$M1 --LittleEndian --Architecture=1\
+    -f stage0/x86.M1\
+    -f lib/libc-mes.M1\
+    > lib/libc-mes.hex2
+
+$HEX2 --LittleEndian --Architecture=1 --BaseAddress=0x1000000\
+      -f stage0/elf32-header.hex2\
+      -f lib/crt1.hex2\
+      -f lib/libc-mes.hex2\
+      -f scaffold/tests/$t.hex2\
+      -f stage0/elf32-footer-single-main.hex2\
+      > scaffold/tests/$t.mes-out
+chmod +x scaffold/tests/$t.mes-out
+
+r=0
+set +e
+scaffold/tests/$t.mes-out
+m=$?
+
+[ $m = $r ]
index 1954b972ce83ea0f92cb01b02ea6caeb4dc557ff..701f0b057705e6d6389b3e5ce2a7d704a2a8c46d 100755 (executable)
@@ -27,10 +27,15 @@ exit $?
 ;;; along with Mes.  If not, see <http://www.gnu.org/licenses/>.
 
 (cond-expand
- (guile-2
+ (guile-2.2
   (define sc-expand identity)
   (define syntax-object->datum syntax->datum)
   (define datum->syntax-object datum->syntax))
+ (guile-2
+  (define sc-expand identity)
+  (define syntax-object->datum syntax->datum)
+  (define datum->syntax-object datum->syntax)
+  (define-macro (with-ellipsis . stuff) #t))
  (guile
   (use-modules (ice-9 syncase))
   (define sc-expand identity))
@@ -206,4 +211,6 @@ exit $?
      '(a 1 2 3)
      (quote-a 1 2 3)))
 
-(result 'report)
+(result 'report (if (and guile?
+                         (equal? (effective-version) "2.0")) 1
+                         0))