-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrars.in
32 lines (26 loc) · 972 Bytes
/
rars.in
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
#!/bin/sh
# RARS RISC-V support by Evgeny Chugunnyy <chgena@mail.ru>
# Copyright (c) 2016 Alexander Chernov <cher@ejudge.ru>
# using EJUDGE_FLAGS we may pass additional flags
LANG_CONFIG_DIR="/home/judges/compile/conf/lang.d"
[ "${EJUDGE_LANG_CONFIG}" = "" ] && EJUDGE_LANG_CONFIG="${LANG_CONFIG_DIR}/rars.cfg"
if [ -f "${EJUDGE_LANG_CONFIG}" ]
then
. "${EJUDGE_LANG_CONFIG}"
else
version="unknown"
RARSPATH="rars-simulator"
fi
if [ x"${version}" = x ]
then
echo "This language is not supported." >&2
exit 1
fi
source=`cat $1 | base64` # new lines and ' should be interpreted as raw symbols. So base64 encode
echo "#!/bin/bash" > $2
echo "t=\$(mktemp /tmp/XXXXXXX.asm)" >> $2 # RARS needs .asm extension to compile & run program
echo "echo '$source' | base64 -d > \$t" >> $2 # Decode base64 source
echo "${RARSPATH} ${EJUDGE_FLAGS} \$t |sed '1d;\$d' -" >> $2 # cut 1st & last lines: RARS (c) and exit code lines
echo "rm -f \$t" >> $2
chmod +x $2
exit 0