-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·38 lines (31 loc) · 827 Bytes
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
build() {
# abort if one of the following commands fails
set -e
# the target directory the function should work on
target=$1
# create and/or clean build dir
mkdir -p $target/build
rm -f $target/build/*
# build everthing that has the _start label
for src in `grep -rl $target -e 'global _start'` ; do
obj=$target/build/`basename $src .s`.o
nasm -i lib/src -i $target/src -f elf64 -g -F dwarf -o $obj $src
ld -o ${obj%.o} $obj
rm $obj
done
# the test function bellow should not abort if one of the tests fails
set +e
}
_test() {
for bin in $1/build/*.test ; do
output=`$bin`
exval=$?
echo `[ $exval -eq 0 ] && echo passed || echo failed "($exval)"`: $bin
done
}
case $1 in
test) _test $2 ;;
build) build $2 ;;
*) echo "run: unknown command"
esac