-
Notifications
You must be signed in to change notification settings - Fork 5
/
make
executable file
·59 lines (55 loc) · 1015 Bytes
/
make
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
test () {
set +e
binary=$(mktemp)
compile_cmd="mi compile --test --disable-optimizations --output $binary"
output=$1
output="$output\n$($compile_cmd $1 2>&1)"
exit_code=$?
if [ $exit_code -eq 0 ]
then
output="$output$($binary)"
exit_code=$?
if [ $exit_code -eq 0 ]
then
rm $binary
else
echo "ERROR: compiled binary for $1 exited with $exit_code"
rm $binary
exit 1
fi
else
echo "ERROR: command '$compile_cmd $1 2>&1' exited with $exit_code"
rm $binary
exit 1
fi
echo "$output\n"
set -e
}
example () {
set +e
compile_cmd="build/trellis"
output=$1
output="$output\n$($compile_cmd $1 2>&1)"
exit_code=$?
if [ $exit_code -ne 0 ]
then
echo "ERROR: command '$compile_cmd $1 2>&1' exited with $exit_code"
echo "$output"
exit 1
fi
echo "$output\n"
set -e
}
case $1 in
test)
test "$2"
;;
example)
example "$2"
;;
*)
>&2 echo "Incorrect argument"
exit 1
;;
esac