bootstrap: Add bootstrap build scripts.

* build.sh: New file.
* check-mescc.sh: New file.
* check.sh: New file.
* install.sh: New File.
This commit is contained in:
Jan Nieuwenhuizen 2017-11-24 19:02:58 +01:00
parent c8613299a8
commit 7ab279bf7b
7 changed files with 281 additions and 2 deletions

1
.gitignore vendored
View file

@ -31,6 +31,7 @@
/.tarball-version
/ChangeLog
/a.out
*.mes-out
#keep this: bootstrap
#/mes.mes

35
build.sh Executable file
View file

@ -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

104
check-mescc.sh Executable file
View file

@ -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

58
check.sh Executable file
View file

@ -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

27
install.sh Executable file
View file

@ -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

47
test.sh Executable file
View file

@ -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 ]

View file

@ -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))