ref: 0a1ad9624156720395cfdbbb204a179e22a6fb79
parent: 6bc30379e7b4d6df3325b44c423ebba9d11792cb
author: Ori Bernstein <[email protected]>
date: Wed Jul 25 16:04:42 EDT 2012
Split build into library + test program.
--- a/bld.sh
+++ b/bld.sh
@@ -39,19 +39,29 @@
done
}
+# Library source.
ASM=syscall-$SYS.s
-# Myrddin source must be specified in dependency order
MYR="\
types.myr \
sys-$SYS.myr \
die.myr \
- alloc.myr \
- hello.myr"
+ alloc.myr"
+
OBJ="$(echo $ASM | sed 's/\.s/.o /g') $(echo $MYR | sed 's/\.myr/.o /g')"
+USE="$(echo $MYR | sed 's/\.myr/.use /g')"
assem $ASM
use $MYR
build $MYR
-echo $CC -m32 -o hello $OBJ
-$CC -m32 -o hello $OBJ
+echo $MU -mo std $USE
+$MU -mo std $USE
+echo ar -rcs libstd.a $OBJ
+ar -rcs libstd.a $OBJ
+
+# build test program
+build test.myr
+COMP="$CC -m32 -o test test.o -L. -lstd"
+echo $COMP
+$COMP
+
--- a/hello.myr
+++ /dev/null
@@ -1,13 +1,0 @@
-use "sys.use"
-use "alloc.use"
-
-const main = {
- var x
- var i
-
- for i = 0; i < 200; i++
- x = std.bytealloc(32)
- ;;
- std.bytefree(x, 32)
- std.write(1, "Hello world\n")
-}
--- /dev/null
+++ b/test.myr
@@ -1,0 +1,12 @@
+use std
+
+const main = {
+ var x
+ var i
+
+ for i = 0; i < 128; i++
+ x = std.bytealloc(32)
+ ;;
+ std.bytefree(x, 32)
+ std.write(1, "Hello world\n")
+}