echo "Populating $MO_ROOT/public"
H=`pwd`
+M=`pwd`/../mop
cd $MO_ROOT/public
-rm -rf bin lib cf
+rm -rf cf
mkdir cf
-for a in eval mop ; do
+for a in mop ; do
sed '/^\(TEST_USER\|MO_ROOT\)=/s/^/#/' <$H/cf/$a >cf/$a
done
+rm -rf bin
mkdir bin
-cp -aL $H/bin/{check,submit,compile,status,box,iwrapper} bin/
+cp -aL $M/public/compile bin/
-mkdir lib
-cp -aL $H/lib/libeval.sh lib/
+rm -rf lib
-if [ -n "$REMOTE_SUBMIT" ] ; then
- cp -aL $H/bin/{contest,remote-submit,remote-status} bin/
- cp -aL $H/lib/perl5 lib/
-fi
+rm -rf templater
+cp -aL $M/project/templater.pl bin/
+chmod +x bin/templater.pl
+cp -aL $M/project/templater templater
mkdir -p problems
-if [ `id -u` == 0 ] ; then
- chown -R $EVAL_USER.$EVAL_GROUP .
- chmod 755 .
-fi
+chown -R root.root .
+chmod -R go=rwX .
--- /dev/null
+#!/bin/bash
+# Compile script for MO-P
+# 2015 - Jan Hadrava <had@kam.mff.cuni.cz>
+
+die() {
+ echo "$@" >&2
+ exit 1
+}
+
+[ -n "$1" ] || die "Usage: compile <source-file> [<options>]"
+
+if [ "${1%.*}" == "$1" ]; then
+ die "Source file must have suffix. Can not compile."
+else
+ src="$1"
+ [ -f "$src" ] || die "File \"$src\" doesn't exist"
+ bin="${1%.*}"
+ ext="${1##*.}"
+
+ shift
+
+ cflags="$@"
+
+ case "$ext" in
+ c)
+ comm="gcc -static -DEVAL -O2 -std=gnu11 $cflags $src -o ${bin} -lm" ;;
+ cpp)
+ comm="g++ -static -DEVAL -O2 -std=gnu++11 $cflags $src -o ${bin}" ;;
+ pas)
+ comm="fpc $cflags -XS -dEVAL -O2 -o${bin} $src";;
+ *)
+ die "Unknown suffix \"$ext\"."
+ esac
+
+ echo -e '\e[0;32m'"Compiling..."'\e[0m' >&2
+ echo -e '\e[0;33m'"$comm"'\e[0m' >&2
+ $comm && echo -e '\e[0;32m'"Done."'\e[0m' >&2 || die -e '\e[0;31m'"Compilation failed!"'\e[0m'
+fi