-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathq2make
executable file
·57 lines (46 loc) · 839 Bytes
/
q2make
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
#/bin/sh
# Script to handle compiling and assembling Q2 programs.
set -e
findprog() {
PROG=$1
LOCAL="./$PROG/target/debug/$PROG"
if [[ -e $LOCAL ]] ; then
echo $LOCAL
else
echo $PROG
fi
}
Q2ASM=$(findprog q2asm)
Q2LC=$(findprog q2lc)
usage() {
echo "Compile and assembly Q2 programs"
echo "usage: $0 <filename>"
}
if [[ $# != 1 ]] ; then
usage
exit 1
fi
FILENAME=$1
compile() {
echo "Compiling ${BASENAME}.q2l"
$Q2LC "${BASENAME}.q2l"
}
assemble() {
echo "Assembling ${BASENAME}.q2"
$Q2ASM "${BASENAME}.q2"
}
BASENAME=${FILENAME%.*}
if [[ ${FILENAME: -4} == ".q2l" ]] ; then
compile
assemble
elif [[ ${FILENAME: -3} == ".q2" ]] ; then
assemble
elif [[ ${FILENAME: -4} == ".q2p" ]] ; then
return
else
echo
echo "ERROR: File type not recognized: $FILENAME"
echo
usage
exit 1
fi