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
60
61
62
63
64
65
66
67
68
69
70 |
#!/bin/bash
DIR=/mnt/user/bin
PROG=$DIR/robot
rm -rf $DIR
mkdir -p $DIR
if [ "$1" == "/mnt/usercode/robot.c" ]; then
CODEDIR="usb_stick_cached"
rm -rf /mnt/user/code/${CODEDIR%%/*} >/dev/null
mkdir -p /mnt/user/code/${CODEDIR%%/*} >/dev/null
echo "Compiling ${1}"
/mnt/kiss/usercode/gcc-usercode "${1}" -o /mnt/user/code/${CODEDIR%%/*}/robot 2>&1
if [ -e /mnt/user/code/${CODEDIR%%/*}/robot ]; then
echo "Compile succeeded."
else
echo "Compiling ${1}pp"
/mnt/user/nhs/g++-usercode "${1}pp" -o /mnt/user/code/${CODEDIR%%/*}/robot 2>&1
if [ -e /mnt/user/code/${CODEDIR%%/*}/robot ]; then
echo "Compile succeeded."
else
echo "Compiling ${1}xx"
/mnt/user/nhs/g++-usercode "${1}xx" -o /mnt/user/code/${CODEDIR%%/*}/robot 2>&1
if [ -e /mnt/user/code/${CODEDIR%%/*}/robot ]; then
echo "Compile succeeded."
else
echo "Compile failed."
fi
fi
fi
else
case ${1} in
*/mnt/user/code/*) CODEDIR=${1#*/mnt/user/code/} ; echo "Checking directory ${CODEDIR%%/*} for binary" ;;
esac
if [ ! -e /mnt/user/code/${CODEDIR%%/*}/robot ]; then
echo "Compiling ${1}"
/mnt/kiss/usercode/gcc-usercode "${1}" -o /mnt/user/code/${CODEDIR%%/*}/robot 2>&1
if [ -e /mnt/user/code/${CODEDIR%%/*}/robot ]; then
echo "Compile succeeded."
else
echo "Compiling ${1}pp"
/mnt/user/nhs/g++-usercode "${1}pp" -o /mnt/user/code/${CODEDIR%%/*}/robot 2>&1
if [ -e /mnt/user/code/${CODEDIR%%/*}/robot ]; then
echo "Compile succeeded."
else
echo "Compiling ${1}xx"
/mnt/user/nhs/g++-usercode "${1}xx" -o /mnt/user/code/${CODEDIR%%/*}/robot 2>&1
if [ -e /mnt/user/code/${CODEDIR%%/*}/robot ]; then
echo "Compile succeeded."
else
echo "Compile failed."
fi
fi
fi
fi
fi
echo "Copying /mnt/user/code/${CODEDIR%%/*}/robot to $PROG"
cp /mnt/user/code/${CODEDIR%%/*}/robot $PROG
if [ -e $PROG ]; then
echo "Copy succeeded."
else
echo "Copy failed."
fi |